Jump to content

Recommended Posts

Hi,

Perhaps I'm going about this the wrong way.

I have a script that reads in lines from the "systeminfo" command, then assigns each line to a variable (e.g. $Line_35... $Line_100).

I then take that line, run a test on it to look for a particular value using a StringMid, and if the value is in my Case tests, it'll either pass or fail.

Trying to create a For loop so I can reduce the lines of code, I created a variable ($linenum) and set a counter at the line number ($num) I want to start at, then increase the count number for the $num so that I can make my way through the line numbers.

this procedure creates a name for the Line_Number variables I set originally

( $linenum = "$Line_" & $num) actually prints out as "$Line_35")

But when I try to read in the value of that Line_Number in my test

$Test = StringMid( $linenum, 28, 4)

I get nada.

So, when using the $linenum in the test, I'm really trying to get a peek at the value for the $Line_35 variable, but it's not working.

variable of a variable? is this possible?

Any suggestions?

thanks,

max

Link to post
Share on other sites

You want to look into using arrays so you can reference things like this:

$mydata[$linenum]

Check the help for the Dim statement for some info. Also, you can probably learn a lot about syntax by looking at the array-oriented User Defined Functions.

BlueBearrOddly enough, this is what I do for fun.
Link to post
Share on other sites

So, when using the $linenum in the test, I'm really trying to get a peek at the value for the $Line_35 variable, but it's not working.

variable of a variable? is this possible?

Sounds like you're looking for the Eval() function.

... but there are much better ways to accomplish what you're aiming for.

Why not use an array instead of 100+ variables?

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...