Page 1 of 1

Create new object by code

Posted: Fri Dec 02, 2011 5:07 am
by Linh
Good morning,

I want to create a new label object by code, not drag and drop from tools. Could I decide position, text color, content and name of this label? I tried to search, but I can't find any document about this, so I have to bother you guys again :(.

Thank you,
Linh

Re: Create new object by code

Posted: Fri Dec 02, 2011 5:28 am
by dunbarx
Howdy.

Check up on the "create" command in the dictionary.

Craig Newman

Re: Create new object by code

Posted: Fri Dec 02, 2011 1:16 pm
by Dixie
Linh...

As Craig mentioned look at the 'create' command... also have a look at the 'templateField' keyword in the dictionary... The script below will create a 'label' field for you... say from within the script of a button, but there again... it could be from anywhere

Code: Select all

on mouseUp
   set the text of the templateField to "label:"
   set the width of the templateField to 100
   set the height of the templateField to 21
   set the visible of the templateField to true
   set the dontwrap of the templateField to true
   set the locktext of the templateField to true
   set the threeD of the templateField to true
   set the showfocusborder of the templateField to false
   set the showborder of the templateField to false
   set the traversalOn of the templateField to false
   set the textAlign of the templateField to right
   set the loc of the templateField to the loc of this card
   
   create field "boo"
end mouseUp
Hope it helps...

Dixie

Re: Create new object by code

Posted: Fri Dec 02, 2011 7:09 pm
by mwieder
...and afterwards it's usually good form to

Code: Select all

reset the templateField
:wink:

Re: Create new object by code

Posted: Fri Dec 02, 2011 8:11 pm
by Dixie
Mark...

I like it when I learn something new... thanks for that, it is something I had never considered... :)

take care

Dixie

Re: Create new object by code

Posted: Fri Dec 02, 2011 8:24 pm
by mwieder
I like to put things back the way I found them - it cuts down on surprises from the Law of Unintended Consequences.

:shock:

Re: Create new object by code

Posted: Wed Dec 07, 2011 2:27 am
by Linh
Thank you very much. You're beautiful!

Re: Create new object by code

Posted: Wed Dec 07, 2011 7:29 am
by Linh
I'm sorry to ask you again. How could I delete all fields of a card by code? I tried 'select' and 'delete' keyword, but I only could delete one field / a time. Is there any keyword to select and delete all fields of a card?

Regards,
Linh

Re: Create new object by code

Posted: Wed Dec 07, 2011 8:05 am
by Linh
I found the solution

Code: Select all

   clear card 2 of this stack
   create card "normal_page"
Anyway thank you guys!

Linh

Re: Create new object by code

Posted: Wed Dec 07, 2011 10:37 am
by jmburnod
Hi Linh,

You can use this script to delete all flds

Code: Select all

on DelAllFlds
   put the num of flds into nbF
   repeat with i = nbF down to 1
      delete fld i
   end repeat
end DelAllFlds
Best regards

Jean-Marc