Trying to edit the script of field in one stack from a different (dialog) stack

Alan Gayne alanira9 at mac.com
Fri Jan 6 20:11:53 EST 2012


Happy New Year everyone.

I have working on a special dialog similar the "Field Attributes" dialog that was part of the old Reports DataPro product.

In addition to editing and saving the usual field properties, I also want to be able to edit the script of the field that is referenced in the dialog stack whilst the dialog stack is open, and can't seem to get this to work.

Here's what I have been doing:  When the "Field Attributes" dialog is called, the long name (or long id) if the target field is put into a variable that is then used to populate a field in the dialog stack (fld "Field Identifier").

A button on the dialog named "Script…" contains this handler:

on mouseUp
  editFldScript 
end mouseUp

on editFldScript 
   put fld "Field Identifier" into whichFld
   delete word 1 of whichFld
   if the environment is development then 
      edit the script of fld whichFld
   end if
end editFldScript

But this doesn't work. Nor does any of variation of referencing the field in the main stack that I have been able to come up with.

This is the error message:

button "Script…": execution error at line 10 (Chunk: no such object) near "id 1264 of card id 1002 of stack "CoverHolder RLD"", char 16

The dialog stack is currently a substack of the main stack.  Not sure if this makes a difference.

Presuming that it is actually possible to edit the script of a field in another stack , it seems likely that the way I am referencing the field is the culprit.  But after trying a lot of different reference variations, I can't seem to find one that works.

If not, I could use some help with a workaround that would give me utility of a script editor whilst in the dialog stack, with the edited script being automatically stored as a custom property of the dialog stack.  

I have set up fld "Script Holder" in the dialog stack for the purpose of editing, and which I call with a simple "edit the script of fld 'Script Holder'", but haven't found any way to automatically set a custom property to the edited script when script editor is closed and the script is saved.  I could do this after the fact with a button, but that's a far from elegant solution since it is not automatic.

This would be pretty easy if there was something like a "scriptChanged", "scriptSaved or "closeScript" message generated by LiveCode, but I haven't found anything like that in the dictionary.

Anyone got any ideas?

Kind regards,
Alan Gayne




More information about the use-livecode mailing list