No CR in Livecode server script
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
No CR in Livecode server script
I'm trying to use Livecode server instead of PHP but can't get the Carriage Return to work...
<?lc
put URL "file:/applications/mamp/htdocs/scroller/sse/play" into play
put "event: " & "event1" & CR & "data: " & play into ptext
put ptext
?>
This outputs : event: event1 data: play
instead of:
event: event1
data: play
<?lc
put URL "file:/applications/mamp/htdocs/scroller/sse/play" into play
put "event: " & "event1" & CR & "data: " & play into ptext
put ptext
?>
This outputs : event: event1 data: play
instead of:
event: event1
data: play
Livecode Indy 9.6.11 (Stable)
MacOS Sonoma 14.2
Xcode 15.0.1 SDK 17.0
MacOS Sonoma 14.2
Xcode 15.0.1 SDK 17.0
Re: No CR in Livecode server script
Hi raugert,
1. welcome to the forum!
2. in a server script "put" will output HTML and HTML does not know what CR means!
Do this:
<?lc
put URL "file:/applications/mamp/htdocs/scroller/sse/play" into play
put "event: " & "event1" & "<br>" & "data: " & play into ptext
put ptext
?>
Important hint:
"play" is a reserved word, so use another name for the variable or this may cause some inconvenience!
Best
Klaus
1. welcome to the forum!
2. in a server script "put" will output HTML and HTML does not know what CR means!
Do this:
<?lc
put URL "file:/applications/mamp/htdocs/scroller/sse/play" into play
put "event: " & "event1" & "<br>" & "data: " & play into ptext
put ptext
?>
Important hint:
"play" is a reserved word, so use another name for the variable or this may cause some inconvenience!
Best
Klaus
Re: No CR in Livecode server script
Thanks for the quick response Klaus.
I think I need to change my thinking to use Livecode server for server sent events (sse). I guess it's not like PHP "echo" and HTML "addEventListener" ?
Here's what I am currently doing:
1. I have an HTML file that scrolls a bottom line 'ticker" for television.
2. I have made a Livecode app to input the data (text size, font, text elements, speed, etc.) . Each element is sent to a separate file. This works well so far.
3. I then read these files with jQuery AJAX calls to put the variables into <div> and CSS
4. I then use a simple PHP "get_file_contents" and "echo" for getting the control codes like (play, pause, reset) and then use addEventListener in my HTML to execute the functions . This also works OK
BUT.. I would like to use more Livecode to accomplish this rather than PHP. It seems like Livecode server is more HTML / text based ?
I think I might be going about this the wrong way. Sorry for so many questions. I haven't received the books yet.
Hope this makes some sense
thanks for your help,
I think I need to change my thinking to use Livecode server for server sent events (sse). I guess it's not like PHP "echo" and HTML "addEventListener" ?
Here's what I am currently doing:
1. I have an HTML file that scrolls a bottom line 'ticker" for television.
2. I have made a Livecode app to input the data (text size, font, text elements, speed, etc.) . Each element is sent to a separate file. This works well so far.
3. I then read these files with jQuery AJAX calls to put the variables into <div> and CSS
4. I then use a simple PHP "get_file_contents" and "echo" for getting the control codes like (play, pause, reset) and then use addEventListener in my HTML to execute the functions . This also works OK
BUT.. I would like to use more Livecode to accomplish this rather than PHP. It seems like Livecode server is more HTML / text based ?
I think I might be going about this the wrong way. Sorry for so many questions. I haven't received the books yet.
Hope this makes some sense
thanks for your help,
Livecode Indy 9.6.11 (Stable)
MacOS Sonoma 14.2
Xcode 15.0.1 SDK 17.0
MacOS Sonoma 14.2
Xcode 15.0.1 SDK 17.0
Re: No CR in Livecode server script
Hi raugert,
sorry, I have very little knowledge about all this web-stuff, so no idea what:
But, see above...
Best
Klaus
sorry, I have very little knowledge about all this web-stuff, so no idea what:
actually is or does.PHP "echo" and HTML "addEventListener"
Not really, it outputs HTML (just like PHP ) but can do a lot more of course.It seems like Livecode server is more HTML / text based
But, see above...
Best
Klaus
Re: No CR in Livecode server script
Think of LiveCode Server as exactly like php and you will not be far wrong.
is equivalent to
Just the same as
is equivalent to
and
is equivalent to
Where you might find some confusion is in php's interpretation of \n as a linefeed within the php code, but I don't think it renders like "<br />" would on the page anyway. Also php can interpret variables within the string literal as well as concatentating, as above. LC has to concatenate always.
Code: Select all
<?lc put "Some plain text" ?>
Code: Select all
<?php echo "Some plain text"; ?>
Code: Select all
<?lc put "<div>Some html text<br />split over two lines</div>" ?>
Code: Select all
<?php echo "<div>Some html text<br />split over two lines</div>" ?>
Code: Select all
<?lc put "Some variable text" into tVar
put "<div>" & tVar & "</div>" ?>
Code: Select all
<?php $var = "Some variable text";
echo "<div>".$var."</div>" ?>
Re: No CR in Livecode server script
Wow!
SparkOut you are a Rosetta Stone of coding!
very very interesting!!!
Mariasole
( ^..^)ノ
SparkOut you are a Rosetta Stone of coding!
very very interesting!!!
Mariasole
( ^..^)ノ
"I'm back" - The Cyberdyne Systems Model 101 Series 800 Terminator