sarahr at genesearch.com.au
Sun Jun 23 22:45:01 EDT 2002
It seems to me that you are asking too much in expecting the same code
to handle a reference no matter whether it is a short reference or a
long reference, and a name, number or ID. If you have a field called
"Data" and you pass it's short name to this script, it's parameter is
going to be "Data" which won't work.
I would start by insisting on a single reference type, say ID. Once your
basic script is working properly, perhaps you could put in some sort of
testing to see what sort of reference was being passed and convert the
reference to a standard form for use in the rest of your script.
When testing your script altered in this way, I had a weird problem with
your variable names: f1Text & f2Text didn't work properly. They appeared
twice in the Script Debug variable list. One of each got set correctly
to the contents of the field, the other pair got left empty. Once I
changed the variable names, the following script worked fine:
put the ID of fld "Start" into startID
put the ID of fld "End" into endID
equalizeNlines startID, endID
-- this just swaps the contents of the fields
on equalizeNlines f1, f2
-- f1 and f2 are short IDs of fields
if there is a field ID f1 and there is a field ID f2 then
put fld ID f1 into var1
put fld ID f2 into var2
put var1 into fld ID f2
put var2 into fld ID f1
Note that if your script has:
put "field 1" into field "New field"
then the text "field 1" will go into the field.
If you leave off the quotes and say
put field 1 into field "New field"
then the contents of field 1 will be used.
On Monday, June 24, 2002, at 06:50 AM, Ivers, Doug E wrote:
> Here's a code snippet that I'm currently working on:
> on equalizeNlines f1, f2
> -- f1 and f2 are any valid field references
> -- note that I want to be able to pass in short name, ID, or number or
> long name, ID, or number
> if exists(f1) and exists(f2) then
> put value(f1) into f1Text -- slightly goofy
> put value(f2) into f2Text -- slightly goofy
> do "put f1Text into "& f1 -- very goofy -- wish for: put f1Text
> into object(f1)
> do "put f1Text into "& f2 -- very goofy -- wish for: put f2Text
> into object(f2)
More information about the Use-livecode