Including Library in LiveCode Server Script

Are you using LiveCode to create server scripts or CGIs?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dcpbarrington
Posts: 87
Joined: Tue Nov 13, 2007 6:40 pm

Including Library in LiveCode Server Script

Post by dcpbarrington » Thu Feb 07, 2013 3:38 am

Forum,

I've set up LiveCode 5.3 server on a WAMP environment and have verified that is able to receive and send XML messages with a POST command. I'm now trying to get basic XML processing working and want to inlcude a library of XML functions that I've used and verified in a stand alone application. Here is my very basic code.

Code: Select all

<?lc set the errorMode to "inline" ?>
<?lc
local tRequestBody, theActID, tAccountArray, tempID
local tResponseMsg

	require (the defaultFolder & "/" & "saverXMLControl.livecode")
   -- Make sure that libraries are started
	if "XMLControl" is not among the lines of the stacksInUse then
		--start using stack (the defaultFolder & "/" & "saverXMLControl.livecode")
		go stack "saverXMLControl.livecode"
	end if


	put $_POST_RAW into tRequestBody
	-- Verify that data has been received
	if tRequestBody is Empty then
		put "ERROR: No Data Received"
		exit to top
	end if
-----------------------------------------------------------------------------
-- Convert the XML request to a XML Tree
-- Get the SPHR data from file and build the XML TREE
-----------------------------------------------------------------------------
	put revCreateXMLTree( tRequestBody, false, true, false) into theActID
	put getXMLAccount( theActID ) into tAccountArray
	CheckForError tAccountArray
	if the result is not Empty then
		put "ERROR: Account Access "
		exit to top
	end if
       put tAccountArray["FirstName"] && tAccountArray["LastName"]
NOTE: start using stack gives the following error message
file "C:/UniServer/www/Server/saver_newact_1_0.lc"
file "C:\UniServer\www\Server\saverXMLControl.livecode"
row 9, col 9: Chunk: can't find stack
row 9, col 1: start: can't find object
row 8, col 1: if-then: error in statement


however go stack "stack file name" does not have an error

The function getXMLAccount() is in the saverXMLControl.livecode file, but the server is not including it and give the following error response.

REVO5500<pre>
file "C:/UniServer/www/Server/saver_newact_1_0.lc"
file "C:\UniServer\www\Server\saverXMLControl.livecode"
row 25, col 6: Function: error in function handler (getXMLAccount)
row 25, col 1: put: error in expression
</pre>


When I display the stacksInUse the list is BLANK, so the stack is not being started. The Stack is not included or started.

Do I need to do something special to the saverXMLControl.livecode library to allow it to be recognized by the LiveCode server?
What is causing the "Start Using Stack" commend to fail?
What is causing LiveCode server to not including the library functions. This must be a simple setup issue.
Does anyone have a basic LiveCode server example that includes function libraries?

Thanks in advance for the help.

Klaus
Posts: 13866
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Including Library in LiveCode Server Script

Post by Klaus » Thu Feb 07, 2013 12:29 pm

Hi,

I'm not a LC server pro but some gerenal hints and considerations:
...
require (the defaultFolder & "/" & "saverXMLControl.livecode")
...
"the defaultfolder" is the current folder, so this might not be neccessary, or even wrong!
Try this:
...
require "saverXMLControl.livecode"
## Presumed this file is in the same folder as the current LC script!
...
The Server is GUI-less, so I am not sure that "go stack XYZ" is even valid snytax!


Best

Klaus

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Including Library in LiveCode Server Script

Post by sturgis » Thu Feb 07, 2013 3:55 pm

If the stack is saved in the new stack format, you won't be able to use it with livecode server
You have to save it in legacy format at which point the problem should go away.

There is a setting in lc preferences that says "preserve stack file version when saving.." or something like that. Forget the exact wording.

If you turn that on, and then save the stack as legacy I think you can then work on it and save it and all without having to "save as".. every time to force legacy mode.

EDIT:
If you don't mind the "library" being in clear text, you can just type it out as another .lc file and require it. MIght be easier than messing with using a stack.

dcpbarrington
Posts: 87
Joined: Tue Nov 13, 2007 6:40 pm

Re: Including Library in LiveCode Server Script

Post by dcpbarrington » Thu Feb 07, 2013 6:30 pm

Thank You for the Quick Reply. Dead ON.

I did the following as Sturgis instructed.

LiveCode -> Edit -> Preferences
Select the Files and Memory Tab
Check "Preserver Stack File Version on Stacks Saved in Legacy Format"

I then selected SaveAS for the library stack and configured the output to be "Legacy LiveCode Stack (2.7)

The legacy stacks are identified by LiveCode Server.

NOTE there is no mention of this requirement in the PDF documentation Rev 16 dated 2011-12-12 that is included with the LiveCode Server.

Thanks for the help

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Including Library in LiveCode Server Script

Post by sturgis » Thu Feb 07, 2013 6:43 pm

Yeah unfortunately, the last revision of lc server was just before the change in the stack format. Hopefully the LC opensource stuff will go through and current stack format support will be added to lc server (along with lots of other stuff!)

I'd love to see GD or some other graphics library integration.

EDIT: Interestingly enough, the lc server engine can create and save stackfiles in its own right. I didn't test much though, so don't know where the current "script limit" rules come into play. I suspect the script limits are part of the current lc server stuff, but once the open source stuff happens (crosses fingers) the possibilities suddenly become very interesting.

Post Reply

Return to “CGIs and the Server”