'show fields' Question

Cubist at aol.com Cubist at aol.com
Fri Apr 25 16:13:01 EDT 2003


sez DSmith at cvm.tamu.edu:
>This is a MIME message. If you are reading this text, you may want to 
>consider changing to a mail reader or gateway that understands how to 
>properly handle MIME multipart messages.
   I realize this is a chunk of automated boilerplate, but *you* may want to 
consider changing to an email prog which only MIME-izes those messages that 
*need* to be MIME'd...
   Moving right along:

>I am trying to find ways to condense the number of script lines per
>object to get around the 10 lines of script per object limit I face with
>my trial version. I was wondering if it is possible to 'show' and/or
>'hide' multiple fields per script line. For example, is there a way to
>condense the following lines of script to one line:
>
>hide field "Stage 1"
>hide field "Stage 3"
>hide field "Stage 4"
>hide field "Etapa 1"
   Hmmm. The earlier suggestion about grouping the fields, so you can 
show/hide the lot with one "show group Fred" command, should do the job... 
but if grouping doesn't do the job, there are alternatives. In this case, you 
can definitely use fewer than 4 lines -- like so:

repeat with K1 = 1 to 4
  hide field (item K1 of "stage 1,stage 3,stage 4,etapa 1")
end repeat

   This trick is nice because you can generalize it out to as many different 
fields as you need. And if you convert the whole thing into a handler in your 
stack script, not only can you take care of arbitarily many fields in one go, 
it's functionally reduced to one line in every *other* script you've got! 
Like so:

on ToggleFields DaList,ShowVal
  # DaList is a comma-delimited list of field names
  # ShowVal is a boolean (true/false) value
  repeat with K1 = 1 to the number of items in DaList
    # look, Ma -- we don't CARE how many items are in DaList!
    set the visible of field (item K1 of DaList) to ShowVal
    # and this is why I went with a boolean value, instead of
    # hard-coding "show"/"hide" into the thing
  end repeat
end ToggleFields

   With this handler in the stack script, one single line...
ToggleFields ("stage 1,stage 3,stage 4,etapa 1",false)
   ...does what you need anywhere else.
   This specific code may not work "as is" in Rev (I'm too much of a 
HyperCard victim...), but the idea should be fairly clear, right?
   Hope this helps...



More information about the use-livecode mailing list