Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get which option was pressed
#6
Talk to Gintaras...he's the man!
By the way...you actually end up with 45 days on the free trial. Fun little freebie!
The program is only $40 and that gives you license to use it on I think three computers.


As far as the tid bit there...

In layman's terms...
the "for" statement: "for(i 0 a.len)"
"for" is the command followed by it's flags (i 0 a.len)
"i" is the index of the items in the array. (which in this case is a[i] = a[0] on the first run, a[1] on the second, and a[2] on the third) this is known as the "counter" variable.
"0" is the index where counter starts. This is called the initial value.
"a.len" is the length of "a" or really the the number of items in the array. It is saying what value where the counter will stop running. In this case it is going to run every item in the array "a"

From the help files:
Quote:for counter initvalue finalvalue [step]
Parts
counter - counter variable. Type - int, long, or unsigned int (lpstr or pointer).
initvalue - initial counter value. Type - type of counter.
finalvalue - final counter value. Type - type of counter.
step - value to add to counter after each loop. Type - int. Default: 1.
statements - one or more statements (commands).

Anything that is in [brackets] is optional, which usually means it has a default. You can see that [step] is optional and has a default of 1. You could change this to 2. In that case in your example only the buttons "Option 1" and "Option 3" would work because the counter would go 0 (a[0] or "Option 1") then 0+2=2 (a[2] or "Option 3")

The statements encompasses the work you would like to get done to each of the items in the array.
so here it is:
if a[i] = 1048592
where in each run the index of "a" will change per counter...
on first run its really like saying:
if a[0] = 1048592
second:
if a[1] = 1048592
third:
if a[2] = 1048592

Then there is just a simple format here applied to the global string variable _s
_s.format("Option %i was selected" i+1)
whatever is in "quotations" is the text you are formatting to _s. If % is in there somewhere...that's the dynamic text that will change per variable. Here you see %i...that's what's going to change. The rest is static text. at the end where there is "i+1" that's what gets inserted for %i. In this case i=0 where the button text="Option 1" so adding 1 to i allows the message text to say..."Option 1 was selected" instead of "Option 0 was selected"

Then the "mes _s" not too hard to understand...

The "ret" tells the function to stop running...this is necessary to prevent the following from running if one of the above criteria were met.
if(a[0] and a[1] and a[2]=1048576)
,mes "No options were selected" "Please Pick Something" "!"
Go ahead and take out the "ret" and run your dialog...you'll see exactly what I mean.

Well...I hope that sheds some light on it for you. I know how much I struggled with this when I started...so I figured I'd pass what I had figured out on...Oh and by the way...Gintaras really is the man...without him, I would not have ever figured any of this out.


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)