Jump to content
Sign in to follow this  
AcidCorps

Amount of lines set in $var

Recommended Posts

AcidCorps

Ok this ones a bit hard to explain, I have a $var that will be set to a number by iniread. I need to have it so that if that number is 1 it will add 1 line, if that number is 2 it will add 2 lines, 3 add 3 lines, ect.

example:

if it says Lines=1 then have it

$line1 = blah

if it says Lines=2 then have it

$lines1 = blah

$lines2 = blahblah

Lines=3 then

$lines1 = blah

$lines2 = blahblah

$lines3 = blahblahblah

What I'm attempting to do is make it so that the script can update itself from the setup.ini file so i need it to be able to insert the $lines# itself too. if anybody has a different way of doing this I'm open to suggestions.

Edited by AcidCorps

Share this post


Link to post
Share on other sites
poisonkiller

Look for arrays in help file, this is what you are looking for. Or you can look up Eval().

Share this post


Link to post
Share on other sites
SpookMeister

Like this?

it will give a compile error because the var's have not been created yet, but it works if you continue

$var = 3
$filler = "blah"
For $i = 1 To $var
    $string = ""
    For $x = 1 To $i
        $string &= $filler
    Next
    Assign("line" & $i, $string)
Next
MsgBox(4096,"", $line1 & @CRLF & $line2 & @CRLF & $line3)
Edited by SpookMeister

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites
poisonkiller

I tried it and it works perfectly, no errors.

Share this post


Link to post
Share on other sites
SpookMeister

I tried it and it works perfectly, no errors.

wierd... well I might be using an older version. Need to fix that :)

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites
AcidCorps

Thanks for your help I'll be trying it when I get home

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  

×