# Simple If-Then

## Recommended Posts

Thanks for all the help. It's working.

Edited by Idea

##### Share on other sites

Q1:You have 3 times \$[] in stead of \$c[] ...

Q2: This \$t = \$c[1] & \$c[2] & \$c[3] & \$c[4] creates a string becaue your concatenate the 4 values as strings.

PS your example in Q2 gives an error because you dim \$a[4] which means \$a[0] - \$a[3]

Live for the present,
Dream of the future,
Learn from the past.

##### Share on other sites

Q1:You have 3 times \$[] in stead of \$c[] ...

It is still not working:

```If Number(IsNumber(\$c[1] + \$c[2] + \$c[3] + \$c[4])) And _;2005
(\$c[5] == "-") And _                  ;-
Number(IsNumber(\$c[6] + \$c[7])) And _             ;09
(\$c[8] == "-") And _                  ;-
Number(IsNumber(\$c[9] + \$c[10])) And _                ;19
(\$c[11] == "") And _                  ;
Number(IsNumber(\$c[12] + \$c[13])) And _               ;08
(\$c[14] == ":") And _                 ;:
Number(IsNumber(\$c[15] + \$c[16])) And _               ;57
(\$c[17] == ":") And _                 ;:
Number(IsNumber(\$c[18] + \$c[19])) And _               ;43
(\$c[20] == "") And _                  ;
(\$c[21] == ":") And _                 ;:
(\$c[22] == "") And _                  ;
StringIsUpper( \$c[23] & \$c[24] ) And _      ;IN
(\$c[25] == "`") And _                 ;`
Number(IsNumber(\$c[26] + \$c[27] + \$c[28] + _;1234567
\$c[29] + \$c[30] + \$c[31] + \$c[32] + _
\$c[33])) And _
(\$c[34] == "`") Then                   ;`
MsgBox(0, "ok!", "ok")
EndIf```

Same error as before.

Q2: This \$t = \$c[1]& \$c[2] & \$c[3] & \$c[4] creates a string becaue your concatenate the 4 values as strings.

How do I concatenate as numbers then? Using + will add them literally 2 and 3 become 5 instead of 23 for example.

Thank you.

Edited by Idea

##### Share on other sites

How do I concatenate as numbers then? Using + will add them literally 2 and 3 become 5 instead of 23 for example.

Thank you.

create your numeric string the way you already are, then explicitly typecast it as a number with the Number() function

##### Share on other sites

create your numeric string the way you already are, then explicitly typecast it as a number with the Number() function

Thank you. I wrongly assumed I didn't have to preform typecasting in AutoIt.

I updated the code (see 2nd post) to include the typecasting and I get a new error now. Line 10 Error: "If" statements must have a "Then" keyword.

Well the Then keyword is there so I do not see why it is incorrect. Thanks for your time.

Edited by Idea

##### Share on other sites

Thank you. I wrongly assumed I didn't have to preform typecasting in AutoIt.

typically you don't since all variables are variants, but i believe that when you typecast a variable by concatenating it, or performing mathematical calculations on it, to use it any other way you have to re-cast it.

##### Share on other sites

Same error as before.

Maybe you can explain what you want to do with Number(IsNumber()) logic , because I don't understand ?

I do not get any AutoIt3 error when i runn this code...

Edited by JdeB

Live for the present,
Dream of the future,
Learn from the past.

##### Share on other sites

Maybe you can explain what you want to do with Number(IsNumber()) logic , because I don't understand ?

I do not get any AutoIt3 error when i runn this code...

seems like it should be... IsNumber(Number()).... else it would just return a 0 right?

##### Share on other sites

seems like it should be... IsNumber(Number()).... else it would just return a 0 right?

Er, yeah. The error I'm getting is the If has no matching Then statement. I'm not useing the beta so maybe it somehow works on the beta? :\

##### Share on other sites

Er, yeah. The error I'm getting is the If has no matching Then statement. I'm not useing the beta so maybe it somehow works on the beta? :\

3.1.1.0 doesn't support comments on continuation lines......

Edited by JdeB

Live for the present,
Dream of the future,
Learn from the past.

##### Share on other sites

How do I concatenate as numbers then?

```\$a = 2
\$b = 3
\$c = string(\$a) & string(\$b)
\$d = int(\$c)
MsgBox(1,"",\$c & " " & \$d)```

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

##### Share on other sites

3.1.1.0 doesn't support comments on continuation lines......

Well that would be why! Does the beta support this feature?

##### Share on other sites

Well that would be why! Does the beta support this feature?

yeap...

Live for the present,
Dream of the future,
Learn from the past.

## Create an account

Register a new account