Page 1 of 1
Need Help with certain code
Posted: Wed Aug 22, 2007 12:08 am
by Taz
Ok, im going to explain this best i can -
THE SCENARIO
Lets say i have 5 small rectangular fields on my stack card.
I create a code, which enables me to put data on each of the fields one by one.
It asks the question "what would you like in this field" and i will type it in.
I get to field 2 out of 5. I then cancel it.
Now, i want to be able to click the execute button again, but start from field 3, instead of all the way to field 1.
Now, i use this command in a repeat code -
Code: Select all
if "field" is not empty then (go back to repeat loop)
the stuff in brackets is the part i don't know... how do i make a repeat loop restart, mid point in the actual repeat script.
I hope you undestand what im trying to say.
Posted: Wed Aug 22, 2007 12:53 am
by Mark
Dear Taz,
Probably, this is what you want:
Code: Select all
repeat with x = 1 to 5
if fld x is not empty then exit repeat
end repeat
repeat with y = x to 5
-- do your stuff here
end repeat
Best,
Mark
Posted: Wed Aug 22, 2007 4:58 pm
by Taz
nope, what that code did was, go through the 5 fields, if it's not empty, it just exits the script.
So say if field 1 has something in it, then instead of skipping it and going to field 2, it jus exits the repeat.
Do you understand what im trying to say
I want it to be able to go down the fields, and know that if the field has something in it, then it must skip to the next field, and if there's nothing in the field, i want it to ask me the question -
"what would u like to input in this field".
Posted: Wed Aug 22, 2007 5:10 pm
by Mark
Taz,
Did you replace "do you stuff" with something else?
Mark
Posted: Wed Aug 22, 2007 5:43 pm
by Taz
in the do ur stuff part, i placed the actual script there.
The script basically cycles through the fields, and asks me a question, in which i input data, and it inputs it into the field.
so it's like -
Code: Select all
repeat counter = 1 to 5
ask "question here"
put it into "field"
Now, if the field is not empty, i want it to stop, and skip straight to the next field. If that field is not empty, then i want it to skip again, until it finds an empty field and then asks me to input data into it.
Posted: Wed Aug 22, 2007 10:14 pm
by BvG
Code: Select all
repeat with counter = 1 to 5
if field counter = "" then
ask "question here"
put it into field counter
end if
end repeat
untested
Posted: Thu Aug 23, 2007 12:52 pm
by Taz
K let me try to explain in another way.
I want to be able to know how to put a "if" or any command, that i could place in the MIDDLE of a repeat loop, to make the repeat loop go from the beginning, instead of carrying on through the script.
Posted: Thu Aug 23, 2007 1:57 pm
by malte
Hi Taz,
now I am getting confused. Could you please try to explain exactly what you want to do? (Using bold does not really help me understand your question)
I understood you wanted to examine if a field already has been filled in and if so, continue with the next empty field. Both Marks and Björnkes Script will let you do just that.
However, if you want to go back to the start of the loop, your repeat construct needs to look a bit differently:
on mouseUp
local i
put 1 into i
repeat until i=5
if fld i is not empty then
-- go back to start
put 0 into i
end if
add 1 to i
end repeat
end mouseUp
However, I'm sure what you want is Marks or Björnkes Script. Have you actually tried them?
All the best,
Malte
[edit]Fixed typo.[/edit].
Posted: Thu Aug 23, 2007 6:54 pm
by Janschenkel
Hi Taz,
Would 'next repeat' do the trick? It will skip the rest of the repeat statements and go straighyt back top the beginning - like the 'continue' command in Java.
Code: Select all
on mouseUp
repeat for each word tWord in field "foobar"
if tWord is "SKIPTHIS" then next repeat
-- do whatever you like for other words
put upper(tWord) & return after field "snafu"
end repeat
end mouseUp
If you were to execute the above when field "foobar" contains the following:
Code: Select all
If only I could SKIPTHIS - then things would be fine
Then the field "snafu" would contain:
Code: Select all
If
only
I
could
-
then
things
would
be
fine
Hope this helped,
Jan Schenkel.
Posted: Fri Aug 24, 2007 6:43 pm
by Taz
Thank you very VERY much Janschenkel, that is exactly what i was looking for and wanted.
.
Still much appreciation to maltem, BvG, Mark for all trying to help me.
Sorry for making it sound so complicated :S
Thanks once again.
Posted: Thu May 01, 2008 8:20 pm
by ThinKolistic
Taz wrote:Thank you very VERY much Janschenkel, that is exactly what i was looking for and wanted.
.
Still much appreciation to maltem, BvG, Mark for all trying to help me.
Sorry for making it sound so complicated :S
Thanks once again.
Wouldn't it be great if we could make a video of the behaviour that we hope for: post it on Google Collaborator and link to the forum ?