Repeat question

zryip theSlug zryip.theslug at gmail.com
Tue May 4 15:02:58 EDT 2010


2010/5/4  <Roger.E.Eller at sealedair.com>:
> On 05/04/2010 at 02:15 PM, Steve Jones wrote:
>> An area I never mastered with SuperCard and still have
>> trouble with in RR is using the repeat control structure...
>> I want to check every field on a card before it closes
>> to be sure none are EMPTY. I know the structure would be
>>
>> REPEAT for the number of fields on the card
>>    if field 1 is empty
>>       put up an alert
>>    else
>>       go to next field
>>    end if
>> end repeat
>>
>> or something similar.
>> How do I refer to the fields?  Their IDs aren't sequential
>> and there names aren't "numbered".
>>
>> Thanks!
>>
>> Steve
>
> on mouseUp
>   REPEAT with i = 1 to the number of fields of this card
>      if field i is empty then
>         answer "Field" && (the name of fld i) && "is empty!"
>      end if
>   end repeat
> end mouseUp
>
> ~Roger Eller

You can also decide to place the insertion point in the first empty
field found by the loop, to let the user correct the required field.

   repeat with i = 1 to the number of fields of this card
      if (field i is empty) then
         answer "Field" && (the name of fld i) && "is empty!"
         select text of field i -- Places the insertion point in the empty field
         exit repeat -- Stops the loop after the first empty field found
      end if
   end repeat


Regards,
-- 
-Zryip TheSlug- wish you the best! 8)
http://www.aslugontheroad.co.cc



More information about the use-livecode mailing list