Getting all the fields/buttons

Ken Ray kray at sonsothunder.com
Wed May 8 12:28:01 EDT 2002


Doug,

Sorry... I forgot you needed all the fields *across all the cards* in the
stack. My code just gives you all the fields (both in groups and not in
groups) ona single card.

One approach you can do is to note the ID of the field (store a list in a
variable), and when you go to the next card and get the next set of fields,
check to see if the field has already been "tagged" (i.e. its ID is already
stored in the list).

Don't know if this is better or worse than your original version... it seems
a bit better to me.

on listAllFields theStackName
  put empty into theFieldList
  put empty into IDtracker
  set the wholeMatches to true
  repeat with i = 1 to the number of cards of stack theStackName
    repeat with j = 1 to the number of fields of card i of stack
theStackName
      if lineOffset ((the short id of field j of card i of stack
theStackName),IDTracker) <> 0 then next repeat
      put (the long id of field j of card i of stack theStackName) & cr
after theFieldList
      put (the short id of field j of card i of stack theStackName) & cr
after IDTracker
    end repeat
  end repeat
  put theFieldList
end listAllFields

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/
----- Original Message -----
From: "Ivers, Doug E" <Doug_Ivers at lord.com>
To: <use-revolution at lists.runrev.com>
Sent: Wednesday, May 08, 2002 10:01 AM
Subject: RE: Getting all the fields/buttons


> Ok, first I added "of stack theStackName" back in...
>
> on listAllFields theStackName
>   put empty into theFieldList
>   repeat with i = 1 to the number of fields of stack theStackName
>     put (the long name of field i of stack theStackName) &cr after
theFieldList
>   end repeat
>   put theFieldList
> end listAllFields
>
> ... but this doesn't seem to get all the fields in my testing.
>
>
> -- D
>
>
> > -----Original Message-----
> > From: Ken Ray [mailto:kray at sonsothunder.com]
> > Sent: Wednesday, May 08, 2002 10:34 AM
> > To: use-revolution at lists.runrev.com
> > Subject: Re: Getting all the fields/buttons
> >
> >
> > Doug,
> >
> > In Rev, all fields can be retrieved at once... there
> > technically aren't any
> > "card fields" or "background fields" (although you can use
> > those references
> > to retain older HyperCard/SuperCard scripting techniques).
> > You can get all
> > the fields this way:
> >
> > on listAllFields theStackName
> >   put empty into theFieldList  -- Note this is not necessary as all
> > first-used variables are empty by default
> >   repeat with i = 1 to the number of fields
> >     put (the long name of field i) &cr after theFieldList
> >   end repeat
> >   put theFieldList
> > end listAllFields
> >
> > BTW: Unless you really need the names, I would recommend
> > using "long id"
> > rather than "long name" - it is more accurate and less prone
> > to confusion
> > (for example, if you have two fields named "Test", they would
> > both have the
> > same long name).
> >
> > Hope this helps,
> >
> > Ken Ray
> > Sons of Thunder Software
> > Email: kray at sonsothunder.com
> > Web Site: http://www.sonsothunder.com/
> >
> > ----- Original Message -----
> > From: "Ivers, Doug E" <Doug_Ivers at lord.com>
> > To: <use-revolution at lists.runrev.com>
> > Sent: Wednesday, May 08, 2002 8:09 AM
> > Subject: Getting all the fields/buttons
> >
> >
> > > Is this the best way to "get" all the fields of a stack
> > once and only
> > once?
> > > (Ultimately, I want to be able to change the font of all
> > the fields in a
> > > stack, but for now this just lists them.)
> > >
> > >
> > > on listAllFields theStackName
> > >   put empty into theFieldList
> > >   -- bg fields
> > >   repeat with i = 1 to the number of backgrounds of stack
> > theStackName
> > >     repeat with j = 1 to the number of fields of background
> > i of stack
> > theStackName
> > >       get the long name of field j of background i of stack
> > theStackName
> > >       put it&return after theFieldList
> > >     end repeat
> > >   end repeat
> > >   -- cd fields
> > >   repeat with i = 1 to the number of cards of stack theStackName
> > >     repeat with j = 1 to the number of fields of card i of stack
> > theStackName
> > >       get the owner of field j of card i of stack theStackName
> > >       if (word 1 of it is "group") then next repeat
> > >       get the long name of field j of card i of stack theStackName
> > >       put it&return after theFieldList
> > >     end repeat
> > >   end repeat
> > >   -- output
> > >   put theFieldList
> > > end listAllFields
> > > _______________________________________________
> > > use-revolution mailing list
> > > use-revolution at lists.runrev.com
> > > http://lists.runrev.com/mailman/listinfo/use-revolution
> > >
> >
> > _______________________________________________
> > use-revolution mailing list
> > use-revolution at lists.runrev.com
> > http://lists.runrev.com/mailman/listinfo/use-revolution
> >
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list