Techniques for Developing for Server
Posted: Thu Jul 11, 2013 6:16 pm
I am curious to hear what people are doing when it comes to developing for Server.
Since I am not using On-Rev for my stuff I have been doing all my development in the desktop IDE and then copying and pasting things into server . lc scripts once I am done. However, I keep getting strange errors and differences in the output between the two, so I am hoping that by talking about some of this from a technique/process standpoint we might identify and document some of the traps.
Some things I do today:
I generally start with a blank stack and create a field/fields that mirror the fields my application web page. I make no attempt for this to actually look like my page or anything, it's just the data fields and the submit button stuff that I am trying to duplicate, without using HTML/get/post/etc.
Then I create a button that contains the script that would be in my submit cgi (a .lc file) This also contains all of the environment setup stuff that, on the server, would normally be a separate include - it's easier to put it here than to call it as a function or something.
I put all of my library stuff into the stack script as functions. This is all code that when I move to the server is actually in one or more includes that are called from my submit cgi.
I try to separate out as much of the static HTML as I can into text files that my .lc CGI loads and use merge or replace to put my dynamic data into the template.
On the server the CGI would spit back out an HTML page with my results to the browser using the put command, but when I am working on the desktop I just have the CGI spit the raw HTML in the message box (so I don't have to edit the put command later when I deploy). Makes it harder to read while developing, and I suppose I could also create an output field in my stack that I set the htmltext of.
Once I have the livecode portion of the web app working, I start to work on porting it to the server. This involves putting together the web pages, putting in all the get and post stuff that is specific to a web implementation of what I have in the desktop IDE, copying the scripts out of the IDE and commenting out anything that was desktop specific and commenting in anything that was server specific.
If I am really lucky, then when I access the apps web page through the browser I can enter data into the web page, click submit and get a result that duplicates what I had on the desktop. Usually though, I don't and I end up having to spend the next couple of days adding debugging code to the server scripts so they display the values of certain variables during execution so I can see where things are going wrong. Sometimes it's because I made a mistake in the stuff that had to be edited/added to migrate for desktop to server, sometimes it seem to be because server is actually doing something differently than the desktop engine did, so I have to code a server specific work around that becomes another thing to comment in/out when moving between desktop and server.
What I am not sure about is where my technique might be messing me up. For example, is there a difference in the way an include operates versus a bunch of functions in a stack script? There doesn't seem to be in practice, but I am not sure.
What are other people doing? Are there third party tools that you have found useful for working with server? Are there any tips that anyone might have for using Ajax to give webpages some of the dynamic interaction and feedback that normally comes with a livecode desktop application? For example, I have a web app that performs several queries and takes a while to complete and I would love to provide the user with a status bar that updates as the background stuff goes on and I am sure Ajax provide the ability to do this, but I haven't had the time to teach myself javascript and really learn about Ajax yet.
Anyway, I just wanted to sort of open up this topic for people to add to There has been some discussion about his in other threads, But I didn't see anything dedicated to tip and tricks about developing and debugging for deployment on server.
Since I am not using On-Rev for my stuff I have been doing all my development in the desktop IDE and then copying and pasting things into server . lc scripts once I am done. However, I keep getting strange errors and differences in the output between the two, so I am hoping that by talking about some of this from a technique/process standpoint we might identify and document some of the traps.
Some things I do today:
I generally start with a blank stack and create a field/fields that mirror the fields my application web page. I make no attempt for this to actually look like my page or anything, it's just the data fields and the submit button stuff that I am trying to duplicate, without using HTML/get/post/etc.
Then I create a button that contains the script that would be in my submit cgi (a .lc file) This also contains all of the environment setup stuff that, on the server, would normally be a separate include - it's easier to put it here than to call it as a function or something.
I put all of my library stuff into the stack script as functions. This is all code that when I move to the server is actually in one or more includes that are called from my submit cgi.
I try to separate out as much of the static HTML as I can into text files that my .lc CGI loads and use merge or replace to put my dynamic data into the template.
On the server the CGI would spit back out an HTML page with my results to the browser using the put command, but when I am working on the desktop I just have the CGI spit the raw HTML in the message box (so I don't have to edit the put command later when I deploy). Makes it harder to read while developing, and I suppose I could also create an output field in my stack that I set the htmltext of.
Once I have the livecode portion of the web app working, I start to work on porting it to the server. This involves putting together the web pages, putting in all the get and post stuff that is specific to a web implementation of what I have in the desktop IDE, copying the scripts out of the IDE and commenting out anything that was desktop specific and commenting in anything that was server specific.
If I am really lucky, then when I access the apps web page through the browser I can enter data into the web page, click submit and get a result that duplicates what I had on the desktop. Usually though, I don't and I end up having to spend the next couple of days adding debugging code to the server scripts so they display the values of certain variables during execution so I can see where things are going wrong. Sometimes it's because I made a mistake in the stuff that had to be edited/added to migrate for desktop to server, sometimes it seem to be because server is actually doing something differently than the desktop engine did, so I have to code a server specific work around that becomes another thing to comment in/out when moving between desktop and server.
What I am not sure about is where my technique might be messing me up. For example, is there a difference in the way an include operates versus a bunch of functions in a stack script? There doesn't seem to be in practice, but I am not sure.
What are other people doing? Are there third party tools that you have found useful for working with server? Are there any tips that anyone might have for using Ajax to give webpages some of the dynamic interaction and feedback that normally comes with a livecode desktop application? For example, I have a web app that performs several queries and takes a while to complete and I would love to provide the user with a status bar that updates as the background stuff goes on and I am sure Ajax provide the ability to do this, but I haven't had the time to teach myself javascript and really learn about Ajax yet.
Anyway, I just wanted to sort of open up this topic for people to add to There has been some discussion about his in other threads, But I didn't see anything dedicated to tip and tricks about developing and debugging for deployment on server.