electing a field

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Glenn Boyce
Posts: 137
Joined: Thu Jul 24, 2008 11:22 pm

electing a field

Post by Glenn Boyce » Wed Feb 18, 2009 11:47 pm

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


Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Thu Feb 19, 2009 1:52 am

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Glenn Boyce
Posts: 137
Joined: Thu Jul 24, 2008 11:22 pm

Post by Glenn Boyce » Thu Feb 19, 2009 2:11 am

Thanks Mark. I like the shortened version of my clear button. Shows my level of scripting expertise!

Post Reply