Jump to content

is there any way to compact this piece of code?


mike1305
 Share

Recommended Posts

$variables = $program[1][0] & "|" & $program[2][0] & "|" & $program[3][0] & "|" & $program[4][0] & "|" & $program[5][0] & "|" & $program[6][0] & "|" & $program[7][0] & "|" & $program[8][0] & "|" & $program[9][0] & "|" & $program[10][0] & "|" & $program[11][0] & "|" & $program[12][0] & "|" & $program[13][0] & "|" & $program[14][0] & "|" & $program[15][0] & "|" & $program[16][0] & "|" & $program[17][0] & "|" & $program[18][0] & "|" & $program[19][0] & "|" & $program[20][0] & "|" & $program[21][0] & "|" & $program[22][0] & "|" & $program[23][0] & "|" & $program[24][0] & "|" & $program[25][0] & "|" & $program[26][0] & "|" & $program[27][0] & "|" & $program[28][0] & "|" & $program[29][0] & "|" & $program[30][0] & "|" & $program[31][0] & "|" & $program[32][0]

    GUICtrlSetData($combo, $variables, "Main Programs")

the only way I can think of would be to make an input field, use a for..next loop to send the array to the input, then read from the input...that is just dumb though. I cant think of any other ways.. :P

Amp Energy Drink: the official sponsor of me scripting at 2AM.

Link to comment
Share on other sites

  • Developers

$variables = $program[1][0]
For $x = 2 to 32
    $variables &=  "|" & $program[$x][0]
Next
GUICtrlSetData($combo, $variables, "Main Programs")

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Sweet, thanks! How do you guys figure out this stuff? I never saw anything about it in the help file, but then again, I really didnt know what to search for as far as key words go...

thanks!

Amp Energy Drink: the official sponsor of me scripting at 2AM.

Link to comment
Share on other sites

Sweet, thanks! How do you guys figure out this stuff? I never saw anything about it in the help file, but then again, I really didnt know what to search for as far as key words go...

thanks!

simple, your repeating the same thing over and over, therefor a loop, either for next loop or while depending on the situation.

in this situation you need to keep adding to the string or concatinate, look for Language Reference then Operators in the help.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

They probably have A) Done other programming before or B) Just made sense of the help file. I personally havnt had to use the help file much(except for syntax on some things) because i've done coding in a ton of other languages.

Edited by mwpeck
Link to comment
Share on other sites

simple, your repeating the same thing over and over, therefor a loop, either for next loop or while depending on the situation.

in this situation you need to keep adding to the string or concatinate, look for Language Reference then Operators in the help.

I am referring to the whole "&=" syntax.

Amp Energy Drink: the official sponsor of me scripting at 2AM.

Link to comment
Share on other sites

They probably have A) Done other programming before or :P Just made sense of the help file. I personally havnt had to use the help file much(except for syntax on some things) because i've done coding in a ton of other languages.

C) Both

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

  • Developers

Sweet, thanks! How do you guys figure out this stuff? I never saw anything about it in the help file, but then again, I really didnt know what to search for as far as key words go...

thanks!

A Helpfile is not intended to teach you how to program, its a refference for how to code the different functions.

To learn a programming language is all about what syntax ('Words") to use, but learning to create a program is all about learning to think in steps and how to code these steps.....

:P

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

The script is at about 80% right now. So far it is two seperate scripts (I'm nervous of any complications with varaibles or the likes) and a seperate ini file. About 1,000 lines of code, nicely formatted and labeled. :P

I will make sure to note every line of the code before I post in the scripts section. I think it will be useful to any other people who are in the same situation I am in (repeated installs of programs on multiple systems) which seems like more than a few.

Amp Energy Drink: the official sponsor of me scripting at 2AM.

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