Comma in variable

Started by siocnarf, November 25, 2016, 12:46:37 PM

Previous topic - Next topic

siocnarf

Hi,

I have a string with a comma

MyDialogFormat=`WWWDLGED,6.2`
;Pour conserver la fenêtre sur le dessus
IntControl(54,"",1,0,0)

MessageFile="C:\Program Files\Organisation\InstTrousses\Trousses\Test1.0_Frv1\msg.txt"
handle=fileopen(MessageFile,"READ")
Count=0

While @True
Line=FileRead(handle)
if Line =="*EOF*"
Break
Else
Count=count+1
Endif
If Count== 1
MessageP=Line
Endif
If Count== 2
MessageSec=Line
Endif
EndWhile
FileClose(Handle)
;MessageSec="En cliquant sur le bouton OK, votre session se fermera automatiquement."
MessageSec="En cliquant sur le bouton OK votre session se fermera automatiquement."

;Title=Param1
;WindowOnTop(Title,1)

MyDialogCaption=Param1
MyDialogX=002
MyDialogY=060
MyDialogWidth=438
MyDialogHeight=136
MyDialogNumControls=004
MyDialogProcedure=`DEFAULT`
MyDialogFont=`Microsoft Sans Serif|9728|70|34`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,255|255|255`
MyDialogConfig=0

MyDialog001=`193,117,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,@csDefButton,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`003,009,414,060,STATICTEXT,"StaticText_2",DEFAULT,%MessageP%,DEFAULT,30,DEFAULT,"Microsoft Sans Serif|8192|70|34",DEFAULT,"255|255|255"`
MyDialog003=`005,101,410,012,STATICTEXT,"StaticText_4",DEFAULT,"________________________________________________________________________________________",DEFAULT,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog004=`077,077,278,024,STATICTEXT,"StaticText_5",DEFAULT,%messagesec%,DEFAULT,50,@csCenter,"Microsoft Sans Serif|8192|70|34","255|0|0","255|255|255"`

ButtonPushed=Dialog("MyDialog")



This is making my script crash: MessageSec="En cliquant sur le bouton OK, votre session se fermera automatiquement."
This is making my script working: MessageSec="En cliquant sur le bouton OK votre session se fermera automatiquement."

The difference is the comma.
Is it a way to make the script accept the comma?

Thanks,

François

td

The problem isn't a comma in a string.  The problem is a comma in a string variable used in substitution.  This is one of the many reasons why the use of substitution is discouraged by all but the most advanced WinBatch users.  In your case, if you insist on using substitution, you need to either use triple double quotes you use too kinds of quote marks:

MessageSec="""En cliquant sur le bouton OK, votre session se fermera automatiquement."""

or

MessageSec='"En cliquant sur le bouton OK, votre session se fermera automatiquement."'

If it is unclear why you need to do this, you may want to consider using something besides substitution or spending some time getting up to speed on how substitution works.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade