How do you declare a string, e.g. '1998-2004' ?

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
tomasz
Newbie
Posts: 3
Joined: Wed May 19, 2004 4:26 pm
Location: san diego
Contact:

How do you declare a string, e.g. '1998-2004' ?

Post by tomasz » Wed May 19, 2004 4:55 pm

Let>text=1998-2004
MessageModal>%text%


will show the value of '-6' because the variable 'text'
automatically evaluates to an integer.
The following workarounds are ok within one script,
but when I pass the variable to another script, it gets
evaluated as an integer again.


// Workaround 1
Let>text=1
// ConCat makes the variable text into a string for this script
ConCat>text,998-2004
MessageModal>%text%
// But this makes it back into an integer
Macro>NextScript /var1=%text%




// Workaround 2
// The hidden character makes this into a string, ok for this script
Let>text=1998-2004%CR%
MessageModal>%text%
// But this makes it back into an integer
Macro>NextScript /var1=%text%



Thanks,
tomasz

Lumumba

Post by Lumumba » Sun May 23, 2004 6:58 am

Have you checked if the same occurs if you use a real hyphon (ANSI 151=ALT+0151=â€â€

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Sun May 23, 2004 7:14 am

Hi,

Quicker way to replace the non-numeric-operator character with the hyphon:

VBEval>Replace("%CopyRightDate%","§","-"),CopyRightDate

Just one line needed each way.
MJT Net Support
[email protected]

Lumumba

Post by Lumumba » Sun May 23, 2004 7:23 am

And of course, this should work as well ... :oops:

Macro /FromYear=1998 /ToYear=2004 /Hyphon=â€â€

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sun May 23, 2004 2:25 pm

I posted this reply on May 19 in the duplicate posting made in Technical/Scripting forum. I have removed that reply to consolidate replies.
I think the only way is to include a non-number character.

Can you use 1998_2004 or 1998~2004 instead?
Then can do a replace after if the "-" is really needed.

If not doing math, can you use the letter "l" vs. the number "1" ?
End up with l998-2004.

I know, these workarounds are only good for some specific conditions,
doesn 't really come up with a real solution.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

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