Page 1 of 1

How do openXXX messages work on server?

Posted: Thu Jul 24, 2014 5:14 pm
by edgore
I noticed that the openStack & openCard messages show in the dictionary as supported on server, but I am not sure what they are supposed to do there. My assumption was that since server doesn't have stacks or cards that one (maybe both?) of these message might get sent when a script was opened.

This would have been handy since it would make it much easier to develop on the desktop (where there is a debugger) and port to server. When developing on the desktop I could put all of the server-specific stuff into an openStack or openCard handler enclosed by an 'if the environment is "Server"' condition.

However, it seems that things don't work like that at all. The following script:

Code: Select all

   on openStack
   put "Got an openStack Message" & return
   end openStack
   on openCard
   put "Got an openCard Message" & return
   end openCard
put "finished"
outputs just "finished". Clearly neither message gets sent. are these supported in server? Also, is there a message that does get sent when a server script is opened that I could use like this?

Edit - Also tried the same with the startUp message - it also doesn't do anything

Re: How do openXXX messages work on server?

Posted: Thu Jul 24, 2014 6:43 pm
by FourthWorld
System messages like openCard are part of the GUI event loop, which is not in play when running from the command line as with LiveCode Server.

Instead, you can simply put your LiveCode commands within your LC tags to execute - see the examples here in the LiveCode Server Guide:

Re: How do openXXX messages work on server?

Posted: Thu Jul 24, 2014 7:48 pm
by edgore
Oh yeah, I know that. Mainly I was just wondering why these are marked as supported on server when I can't find any use for them, or any effect they have.

Also, I am always trying to find any way that I can write code on the desktop (with a debugger), have it work there, and paste it directly over to a text file between livecode tags without any fiddling to change it to work on server.

Seeing that opencard/stack/startup list as supported in server raised the hope I would be able to get away with a script like:

Code: Select all

on openStack --or openCard, or startUp
  if environment is server 
     do server specific stuff
  end if
  if environment is desktop
   do desktop specific stuff
  end if
  do environment independent stuff
end openstack

function myfunction
  do function stuff
end function
If openStack actually did anything on server that script could potentially be copied an pasted right between livecode tags with no edits. As it is I have to go in and remove the on and end for whatever handler is enclosing the stuff in the first section that makes it work with desktop (usually an on mouseUp these days).

Re: How do openXXX messages work on server?

Posted: Fri Oct 03, 2014 7:21 pm
by sturgis
The opencard openstack messages are supported because you can "go stack..." from a script, at which point the stack you go to executes its opencard/stack/whatever handlers. You can also library a stack which means that you can do much of your coding in the LC ide, save the library stack to wherever your server is, and use it as if it was a regular old library. Which it is. (start using ....)