Script command to create button

Want to move your code and projects to LiveCode but don't know where to start?

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller

Post Reply
jpalme
Posts: 6
Joined: Sun Feb 22, 2009 6:14 pm
Location: Stockholm, Sweden
Contact:

Script command to create button

Post by jpalme » Sun Feb 22, 2009 7:32 pm

I am converting a hypercard application. Much seems to work very well when I import into Revolution, much better than with SuperCard which I was very disappointed with.

However, I got stuck with one piece of code. It looks like this in Hypetalk:

Code: Select all

on mouseUp
  global lastnewbutton, markedheader, markedcard
  send "doMenu New Button" to HyperCard
  put "on mouseUp" into line 1 of thescript
  put "go to card ID " & markedcard into line 2 of thescript
  put "end mouseUp" into line 3 of thescript
  set script of button lastnewbutton to thescript
  set the name of button lastnewbutton to markedheader
end mouseUp
This code creates a new button, and gives the new buttom a simple script which says

Code: Select all

on mouseUp
go to card ID NNNN
end mouseup
where NNNN gets the value of the global variable markedcard

My code stops at the command:
"send "doMenu New Button" to HyperCard" which creates a new button.

What is the corresponding command in the script language of Revolution?

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Location: Aalst, Belgium
Contact:

Post by Janschenkel » Mon Feb 23, 2009 6:50 am

It's much easier in Revolution, as we have the create command and the templateButton.

Code: Select all

on mouseUp 
  global lastnewbutton, markedheader, markedcard 
  put "on mouseUp" &return & \ 
      "   go to card ID " & markedcard & return & \
      "end mouseUp" into thescript 
  set the script of the templateButton to thescript 
  set the name of the templateButton to markedheader
  create button
end mouseUp
Basically, you set all the properties on the templateButton and then create your button.

Note that in Revolution, standalones, you cannot set the script of a control to anything longer than 10 lines. This is their way of protecting themselves from someone blatantly using Revolution to create a competing development environment.

HTH,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Post Reply

Return to “Converting to LiveCode”