Jump to content
Sign in to follow this  
Lee Evans

Variable name to include a variable value

Recommended Posts

Lee Evans

Can anyone help me I have a variable that is a line from a file that is comma seperated. This line may contain up to 400 comma deliminated entrys so I cannot read it into an array as this is limited to 64 values. I want to trim to a seperator the line and pass the value to a variable which I would like to name $glob then a number so that I can track the variable according to the position in the line.

$GlobalLine = Job,Lee,Size,1230mm,Height,2340mm,Name,Wardrobe etc

I wanted to do this like this but can't

$g=1

If StringIsSpace ( $GlobalLine )= 0 then

$Glob($g) = _TrimToSeperator($GlobalLine,",")

$g = $g+1

EndIf

MsgBox(0, "AutoIt", "Global"&$g& "-")&$Glob($g))

Gives Error:Expected a "=" operator in assignment statement for the line $Glob($g) = _TrimToSeperator($GlobalLine,",")

I have seen previous posts concerning Eval and Assign but I cannot see how these will achieve what I want.

Has anyone got any ideas?

Share this post


Link to post
Share on other sites
sugi

Arrays are limited to 64 dimensions, not to 400 values. So just read them into an array.

Arrays: 64 dimensions and/or a total of 16 million elements

Also arrays are used like this:
$Glob[$g]=_TrimToSeperator($GlobalLine,",")

EDIT: After five edits I hope I finally got everything right.

Edited by sugi

Share this post


Link to post
Share on other sites
phillip123adams

Can anyone help me I have a variable that is a line from a file that is comma seperated. This line may contain up to 400 comma deliminated entrys so I cannot read it into an array as this is limited to 64 values. I want to trim to a seperator the line and pass the value to a variable which I would like to name $glob then a number so that I can track the variable according to the position in the line.

$GlobalLine = Job,Lee,Size,1230mm,Height,2340mm,Name,Wardrobe etc

I wanted to do this like this but can't

$g=1

If StringIsSpace ( $GlobalLine )= 0 then

  $Glob($g) = _TrimToSeperator($GlobalLine,",")

  $g = $g+1

EndIf

MsgBox(0, "AutoIt", "Global"&$g& "-")&$Glob($g))

Gives Error:Expected a "=" operator in assignment statement for the line  $Glob($g) = _TrimToSeperator($GlobalLine,",")

I have seen previous posts concerning Eval and Assign but I cannot see how these will achieve what I want.

Has anyone got any ideas?

<{POST_SNAPBACK}>

To fix the errors:

1. Arrays require square brackets, "[" and "]", not parenthesis.

2. The MsgBox line has a closing parenthesis that does not belong.

To make a variable from two strings use the Assign function:

$g="Glob"

$n="123"

$Value="This is an example"

Assign($g & $n, $value)

MsgBox(4096, "", $Glob123)


Phillip

Share this post


Link to post
Share on other sites
Lee Evans

Thanks for all the help but I am confused as to what 64 dimensions are as mentioned in the help.

I am not a programmer so some terminology is new to me.

Share this post


Link to post
Share on other sites
sugi

$a[10] <- 1 dimension

$a[10][15] <- 2 dimensions

$a[30][40][50] <- 3 dimensions

For the first example think of a line with a defined number of points.

For the second example think of a coordinate system with two axes like a map where you need two parameters to define a point.

And for the third dimension remember the map and think of the height as the third dimension.

For the fourth dimension you could add the time.

And so on...

Share this post


Link to post
Share on other sites
Wolvereness

This is why in the help file they should further explain what a dimension is, not just three little ...


Offering any help to anyone (to my capabilities of course)Want to say thanks? Click here! [quote name='Albert Einstein']Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.[/quote][quote name='Wolvereness' date='7:35PM Central, Jan 11, 2005']I'm NEVER wrong, I call it something else[/quote]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.