Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
check variable type
How can I check what type a variable is?
Macro Macro9
Copy      Help
ARRAY(int) i

;. code

out "i is 'ARRAY'"

I want to check if file names or folder names end with a number.
I have this code
Macro Macro8
Copy      Help
str check_string="test_name0"
int x=val(check_string)
out x

whith this function
Function get_last_char
Copy      Help

function str&check_string

str char
int q=len(check_string)
char.get(check_string q-1 1)


The problem is that the string "check_string" contains a string that ends with '0' (zero).
The 'val' command returns a zero if number is to big or it is not a number.
If I had a string that was "setup_v1.0" the "out x" would result in 0 in the output window.
But how do I know that zero is based on error or actually based on integer value zero?
1. No. Why need it? If the variable is VARIANT, can check its vt member.

Macro Macro1836
Copy      Help
str s="setup_v1.0"
if s.len and isdigit(s[s.len-1])
,out "ends with a number"

When need val:
int i j
i=val(s 0 j)
if j
,out "valid number, value %i, number string ends at %i" i j
Ok thank you!
(i needed the first example to check if string or check if int, but there are other ways for that)
I have another rather similar question :

Suppose a string variable s contains the name of another int variable.

Is it possible to output this int variable through s ?

Thanks in advance
No. For normal variables, at run time exists only address, not name.

If need variables where you can have name at run time, can use environment variables, window properties, registry. See QM Help, Variable storage and scope (2). Also can try IStringMap.
Dear Gintaras,

Many thanks for your very prompt reply.
Let me mention that I overcame this case using the following :

Macro temp
Trigger SF12     Help - how to add the trigger to the macro
Copy      Help
int tBM1=15
str s="tBM1"
str text.from("out " s)
mac newitem("temp_varout" text "Function" "" "\User\Temp" 1|128)

Best regards
It works when the variable is global.

int+ tBM1=15
Correct, I am sorry I did not say that in the beginning.

Forum Jump:

Users browsing this thread: 1 Guest(s)