No CR in Livecode server script

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
raugert
Posts: 112
Joined: Thu May 26, 2016 9:30 pm
Location: Winnipeg, Canada

No CR in Livecode server script

Post by raugert » Tue Apr 11, 2017 5:07 pm

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
Livecode Indy 9.6.11 (Stable)
MacOS Sonoma 14.2
Xcode 15.0.1 SDK 17.0

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

Re: No CR in Livecode server script

Post by Klaus » Tue Apr 11, 2017 6:03 pm

Hi raugert,

1. welcome to the forum! :D

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

raugert
Posts: 112
Joined: Thu May 26, 2016 9:30 pm
Location: Winnipeg, Canada

Re: No CR in Livecode server script

Post by raugert » Tue Apr 11, 2017 9:02 pm

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. :cry:

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

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

Re: No CR in Livecode server script

Post by Klaus » Tue Apr 11, 2017 9:37 pm

Hi raugert,

sorry, I have very little knowledge about all this web-stuff, so no idea what:
PHP "echo" and HTML "addEventListener"
actually is or does.
It seems like Livecode server is more HTML / text based
Not really, it outputs HTML (just like PHP :D ) but can do a lot more of course.
But, see above... :oops:


Best

Klaus

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: No CR in Livecode server script

Post by SparkOut » Tue Apr 11, 2017 9:53 pm

Think of LiveCode Server as exactly like php and you will not be far wrong.

Code: Select all

<?lc put "Some plain text" ?> 
is equivalent to

Code: Select all

<?php echo "Some plain text"; ?>
Just the same as

Code: Select all

<?lc put "<div>Some html text<br />split over two lines</div>" ?> 
is equivalent to

Code: Select all

<?php echo "<div>Some html text<br />split over two lines</div>" ?>
and

Code: Select all

<?lc put "Some variable text" into tVar
put "<div>" & tVar & "</div>" ?> 
is equivalent to

Code: Select all

<?php $var = "Some variable text";
echo "<div>".$var."</div>" ?>
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.

Mariasole
Posts: 235
Joined: Tue May 07, 2013 9:38 pm

Re: No CR in Livecode server script

Post by Mariasole » Thu Apr 13, 2017 2:58 pm

Wow!
SparkOut you are a Rosetta Stone of coding! :D
very very interesting!!!

Mariasole
( ^..^)ノ
"I'm back" - The Cyberdyne Systems Model 101 Series 800 Terminator

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”