Page 1 of 1

electing a field

Posted: Wed Feb 18, 2009 11:47 pm
by Glenn Boyce
I have used this command before but it won't work now. reason given:

compiling at 11:41:09 AM
Type Chunk: can't create a variable with that name (explicitVariables?)
Object Clear
Line select before the text of fld "partNo"
Hint text

I just want to clear a bunch of flds and set the cursor to the first one.

Code: Select all

on mouseUp
  
  put "" into fld "partNo" 
  put "" into fld "description" 
  put "" into fld "Qty" 
  set the label of button "UOM" to ""
  put "" into fld "No" 
  put "" into fld "DateRcd" 
  put "" into fld "DueDate" 
  put "" into fld "DateAllocated" 
  put "" into fld "TotalQTY" 
  set the label of button "UOM2" to ""
  put "" into fld "$/UOM" 
  put "" into fld "$" 
  set the label of button "region" to ""
  set the label of button "Store"  to ""
  put "" into fld "Location" 
  select before the text of fld "partNo"
end mouseUp


Posted: Thu Feb 19, 2009 1:52 am
by Mark
Hi Glenn,

It looks like the error is wrong. The error should have been something like "wrong object reference" or "can't find object". The reason is that "the text of fld x" actually contains the text and no object reference. You want the text cursor to appear in a particular object and therefore you need to refer to that object rather than it's text:

Code: Select all

select before fld "PartNo"
Btw you can make a list with all field names and another list with all button names and use a repeat loop (two, actually). This would look like the following.

Code: Select all

put "partNo,description,Qty,and more fields" into myFieldList
repeat for each item myField in myFieldList
  put empty into fld myField
end repeat
put "UOM,UOM2,region,Store" into myButtonList
repeat for each item myButton in myButtonList
  set the label of btn myButton to empty
end repeat
select before fld "PartNo"
Best,

Mark

Posted: Thu Feb 19, 2009 2:11 am
by Glenn Boyce
Thanks Mark. I like the shortened version of my clear button. Shows my level of scripting expertise!