WriteLn> and %CRLF%

Ideas for new features & functions

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

WriteLn> and %CRLF%

Post by JRL » Wed Apr 30, 2008 10:40 pm

Could there be a new WriteLn> variable that allows the text "%CRLF%" to be written without causing a line feed? Something similar to the WLN_NOCRLF variable that prevents a line feed from being added during a WriteLn>.

As an example, the following code will write a script but the resulting script will be incorrect because one line contains several instances of "%CRLF%".

Code: Select all

WriteLn>%temp_dir%temp.scp,wres,Dialog>Dialog1
WriteLn>%temp_dir%temp.scp,wres,   Caption=Write this to a file
WriteLn>%temp_dir%temp.scp,wres,   Width=204
WriteLn>%temp_dir%temp.scp,wres,   Height=236
WriteLn>%temp_dir%temp.scp,wres,   Top=0
WriteLn>%temp_dir%temp.scp,wres,   Left=0
WriteLn>%temp_dir%temp.scp,wres,   RadioGroup=msRadioGroup1,msRadioGroup1,48,32,97,105,Item1%CRLF%Item2%CRLF%Item3,-1
WriteLn>%temp_dir%temp.scp,wres,EndDialog>Dialog1

WriteLn>%temp_dir%temp.scp,wres,Show>dialog1,res1
Running the previous script will result in the following incorrect code being written to the %temp_dir%temp.scp file.

Code: Select all

Dialog>Dialog1
   Caption=Write this to a file
   Width=204
   Height=236
   Top=0
   Left=0
   RadioGroup=msRadioGroup1,msRadioGroup1,48,32,97,105,Item1
Item2
Item3,-1
EndDialog>Dialog1
Show>dialog1,res1
Thanks for listening,
Dick

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu May 01, 2008 7:05 am

Two workarounds:

1. Redefine CRLF to a plain string first:

Code: Select all

Let>CRLF={"CRLF"}
WriteLn>%temp_dir%temp.scp,wres,   RadioGroup=msRadioGroup1,msRadioGroup1,48,32,97,105,Item1%CRLF%Item2%CRLF%Item3,-1
You may still need the real CRLF later in the script so you could do:

Code: Select all

Let>realCRLF=CRLF
Let>CRLF={"CRLF"}

WriteLn>%temp_dir%temp.scp,wres,   RadioGroup=msRadioGroup1,msRadioGroup1,48,32,97,105,Item1%CRLF%Item2%CRLF%Item3,-1

//Put CRLF back
Let>CRLF=realCRLF
2. Split the string up:

Code: Select all

WriteLn>%temp_dir%temp.scp,wres,{"   RadioGroup=msRadioGroup1,msRadioGroup1,48,32,97,105,Item1%" + "CRLF" + "%Item2%" + "CRLF" + "%Item3,-1"}
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri May 02, 2008 5:05 am

Marcus wrote:1. Redefine CRLF to a plain string first:

Let>CRLF={"CRLF"}
Thanks for the ideas. I like the first one. I've been using a variation of the second one for quite a while and I've never liked it, it gets confusing. The first one is good enough that I'll rescind my request.
Marcus wrote:You may still need the real CRLF later in the script so you could do:

Let>realCRLF=CRLF
Let>CRLF={"CRLF"}

WriteLn>%temp_dir%temp.scp,wres, RadioGroup=msRadioGroup1,msRadioGroup1,48,32,97,105,Item1%CRLF%Item2%CRLF%Item3,-1

//Put CRLF back
Let>CRLF=realCRLF
Or, since CR and LF also are built in variables, there's no need to pre-save the value. You could simply do:

Code: Select all

Let>CRLF={"CRLF"}

WriteLn>%temp_dir%temp.scp,wres,   RadioGroup=msRadioGroup1,msRadioGroup1,48,32,97,105,Item1%CRLF%Item2%CRLF%Item3,-1

//Put CRLF back
Let>CRLF=%CR%%LF%

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts