Need Help Getting LiveCode Server to Write to a File

Devin Asay devin_asay at byu.edu
Wed Nov 13 17:40:05 CET 2013


On Nov 13, 2013, at 6:56 AM, Gregory Lypny wrote:

> Hello everyone,
> 
> I have LiveCode Server working on my Mac. I have a test page that works fine by displaying the date and time in Safari, but I cannot get the script to create and write to a file.  When I insert the following line in the script I get an error output to Safari.
> 
> put the long time into url “file://HardDrive/Library/WebServer/share/httpd/myData/testFile.txt”
> 
> The error message I get is
> 
> file "/Library/WebServer/Documents/myServerTest.lc"
>  row 19, col 28: script: not a command (://)
> 
> So, I figured I must be using the wrong syntax for the file path. I tried different combinations of slashes and colons to no avail.
> 
> When I change the data to be written from the long time to “Hello world.” I get the following
> 
> file "/Library/WebServer/Documents/myServerTest.lc"
>  row 19, col 14: Expression: bad factor
>  row 19, col 14: param: bad expression
>  row 19, col 14: Commands: bad parameter
>  row 19, col 14: Commands: bad parameters
>  row 19, col 14: script: bad command
> 
> where column 14 is the position of the letter r in the word world. What am I doing wrong? I set read and write permissions (in the Info window) for the share folder, the httpd folder, and the myData folder.
> 
> Any advice and perhaps an example would be much appreciated.

Gregory,

I don't think LC Server scripts are "aware" of the full file system on your HD, only the web root and child directories to it. (Someone will correct me if I'm wrong about this, I'm sure. :) ) Try writing to a folder/file relative to the defaultFolder of the LC script file. 

put "foo" into url "file:my folder/myFile.txt"

As an aside, I'm assuming that the "curly quotes" in your message were added by you email client, and weren't there in your script?

Devin

Devin Asay
Learn to code with LiveCode University
http://university.livecode.com




More information about the use-livecode mailing list