SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Auto conversion String-> Number

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
Auto conversion String-> Number
Author Message
Robbert de GROOT



Joined: 13 Dec 2000
Posts: 53

Post Auto conversion String-> Number Reply with quote

Support, goodday,

In the below copied sample the 24x7 scheduler blocks on
a "Type Mismatch" error although the variable 'a' has been
declared as a string type. Why ??

Robbert de GROOT
Publicis Group - Paris (France)

DIM is_empty, boolean
DIM A, string

set a,"1234"
IsEqual (a, "", is_empty)

LoopUntil (is_empty, END_LOOP2)

// ...

// ...

// ...

// ...
END_LOOP2:

Mon Oct 04, 2004 7:50 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7969

Post Re: Auto conversion String-> Number Reply with quote

This is because "1234" is automatically converted to a number and then conversion of a number against an empty string fails.

Here are several workarounds.

1. If you run 3.4.21 or later change the IsEqual line to
IsEqual ("", a, is_empty)

or

2. Use Length() method instead of IsEqual, for example,
Dim non_zero_length, number
Length( a, non_zero_length )

LoopUntil (non_zero_length, END_LOOP2)

or

3. Append some non-digit characters to the test string and then compare it, for example
Concat( a, "x", a)
IsEqual(a, "x", is_empty)

: Support, goodday,

: In the below copied sample the 24x7 scheduler blocks on
: a "Type Mismatch" error although the variable 'a' has been
: declared as a string type. Why ??

: Robbert de GROOT
: Publicis Group - Paris (France)

: DIM is_empty, boolean
: DIM A, string

: set a,"1234"
: IsEqual (a, "", is_empty)

: LoopUntil (is_empty, END_LOOP2)

: // ...

: // ...

: // ...

: // ...
: END_LOOP2:

Mon Oct 04, 2004 10:15 am View user's profile Send private message
Robbert de GROOT



Joined: 13 Dec 2000
Posts: 53

Post Re: Auto conversion String-> Number Reply with quote

Thanks for responding so quickly.

Solution 1 doesn't work (after installing v3.4.22) Same error message
Solution 2 Seems to work
Solution 3 Inacceptable. Doesn't permit to test empty string to know no files are remaning to handle

I'm quite astonished that 24x7 is doing an auto conversion. why is done ? there must be no reason that
a scripting machine converting automatically a STRING into a NUMBER. Why then is variable and type defining
obliged ?

: This is because "1234" is automatically converted to a number and
: then conversion of a number against an empty string fails.

: Here are several workarounds.

: 1. If you run 3.4.21 or later change the IsEqual line to
: IsEqual ("", a, is_empty)

: or

: 2. Use Length() method instead of IsEqual, for example,
: Dim non_zero_length, number
: Length( a, non_zero_length )

: LoopUntil (non_zero_length, END_LOOP2)

: or

: 3. Append some non-digit characters to the test string and then compare it,
: for example
: Concat( a, "x", a)
: IsEqual(a, "x", is_empty)

Mon Oct 04, 2004 11:26 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7969

Post Re: Auto conversion String-> Number Reply with quote

That's a long story. The data-type auto-conversion was invented in version 2.something. After that version it does not really matter how you define the type, but the syntax is preserved for backward compatibility. The only difference I can think of is the initial value.

For example if you do the following

Dim my_var, number
MessageBox my_var

You will get "0" displayed.

If you do the following

Dim my_var, string
MessageBox my_var

You will get an empty message. Yet you can define it as

Dim my_var, string, "0"
MessageBox my_var

and the result will be exactly the same. You can then do
Add my_var, 5, my_var
MessageBox my_var

and you will see "5"

: Thanks for responding so quickly.

: Solution 1 doesn't work (after installing v3.4.22) Same error message
: Solution 2 Seems to work
: Solution 3 Inacceptable. Doesn't permit to test empty string to know no files
: are remaning to handle

: I'm quite astonished that 24x7 is doing an auto conversion. why is done ?
: there must be no reason that
: a scripting machine converting automatically a STRING into a NUMBER. Why then
: is variable and type defining
: obliged ?

Mon Oct 04, 2004 1:21 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.