Jump to content

Variable name to include a variable value


 Share

Recommended Posts

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

$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...

Link to comment
Share on other sites

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]

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...