Looping
Alex Tweedly
alex at tweedly.net
Tue Apr 18 10:56:27 EDT 2006
Jeff Honken wrote:
>Thanks to all of those that helped me out on the "adding one hour" to a
>variable. Now I'm moving on further and I need to loop my times.
>Looping one item is confusing to me so looping two is really tough.
>Here's what I'm trying to do.
>
>I'm getting five inputs from fields and buttons.
>1. If it's AM or PM for start "SAmPm"
>2. The start time of the Table "STime"
>3. What Intervals the time should be incrementing in "Intervals"
>4. If it's AM or PM for the End Time "EAmPm"
>5. The finish time of the table "ETime"
>
>What I want the program to do is take the three inputs and fill a table
>with the answers until the end time has been reached. The answers
>should populate the table "MyTable" in descending order. I know I have
>to use a loop to get the results but I'm confused on how to loop both
>the time and the line number of the field. Also I'm not sure how to end
>the loop at the designated end time. Any help would be greatly
>appreciated. Jeff
>
>
You want something like
put STime && SAmPm into startTime
convert startTime to seconds
put ETime && EAmPm into endTime
convert endTime to seconds
-- assume Intervals is already in seconds - if not, do something here
repeat with theTime = startTime to endTime step Intervals
put theTime into temp
convert temp to short time
put temp & cr after field MyTable
end repeat
Note that you can avoid worrying about which line of the table you want
by simply putting the new time after the current contents.
If you haven't already seen them, you may find it worthwhile working
your way through the tutorial conferences at
http://downloads.runrev.com/section/scriptingconferences.php
The first 2 or 3 of these give you a good intro to simple scripting, and
save you from the frustration of getting stuck. (And you'd have an idea
of which of the later ones would help with specific topics if you needed
them).
--
Alex Tweedly http://www.tweedly.net
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.4.3/316 - Release Date: 17/04/2006
More information about the use-livecode
mailing list