Calling a function in LC Server

Are you using LiveCode to create server scripts or CGIs?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Calling a function in LC Server

Post by bogs » Tue Feb 19, 2019 9:31 pm

bogs wrote:
Tue Feb 12, 2019 12:44 pm
Someone else also had information on Lc server, but I think that was more basic. If I remember it, I'll stop in with the link.
This was pretty basic http://livecode.byu.edu/internet/revservercripting.php I think they have more on it (but you have to go through the index for that). There was also https://activethought.net/livecode-server/introduction , which is kind of an 'unofficial' guide, not sure how accurate the information is, but it was linked (inaccurately) from BYU as well, so I'd be thinking it probably isn't a waste of time.
Image

fritzdekatt
Posts: 57
Joined: Fri Feb 09, 2018 2:28 am

Re: Calling a function in LC Server

Post by fritzdekatt » Tue Feb 26, 2019 11:19 pm

FourthWorld wrote:
Tue Feb 19, 2019 7:12 pm
fritzdekatt wrote:
Tue Feb 19, 2019 12:27 am
RE: Calling functions
Indeed, I ended up just translating directly from PHP to call my functions, as you suggested, which works fine except for some cases of AJAX, which I have trouble doing in PHP also.
Was the difficulty on the AJAX side or the PHP side? I've used XMLHttpRequest to call LC Server routines, so I may be able to help once I learn more about where the trouble lies.
I have trouble on the AJAX side because my javascript stinks.
I was mislead (or mislead myself) by a statement that one could call stacks from the server
LC has very good socket support, with async options similar in some respects to Node.js' single-threaded message-based operations. Most commonly used in clients, LC's flexible socket commands can also lend themselves well to working behind a reverse proxy on a server, such as Node.js or NgineX, or for lighter loads even take on the role of handling external network I/O directly (I once wrote an HTTPd script as an exercise and was pleased with the results, though not surprisingly Apache outperformed it in my tests by more than double; still a worthy use of time, as for certain microservices a completely LC-based solution may offer some development advantages).

So while LC Server is designed to work optimally with CGI, the full range of things that can be done for client-server tasks with sockets is quite broad. And now that we have the ability to specify UDP ports many P2P options are available as well.

I'm often tempted to write a book-long post about all the things one could do in this area - client-server is a big part of my work, and I'm prone to over-enthusiasm. :)

So instead, given how many ways there are to do so many things with LC, let's start first with the most important one: What would you like to do?

For example, since the notion of "calling a stack on a server" captured your attention, what would that look like in terms of the user experience you're envisioning?
I didn't envision how I would apply it particularly, since I didn't know how calling a stack would be any different than including a library file like you would in PHP. I hoped that the Cloud video tutorials would fill in the blanks there, but I haven't finished the example projects yet.

An HTTPd server in LC would be cool. Making one in Node is obviously trivial, but making one that does anything besides basic pages is a different thing. As far as Nginx and all that goes, I run that on my local server but I'm not qualified at the moment to configure those things safely on a web host. Didn't know about UDP support, so I'll have to check that out.

Bottom line, I'm so far from entertaining the notion of doing anything novel with LC server. I'm turning some simple PHP apps into LC analogues just for giggles.

Obviously, if some veteran did write a "book-long post" on these subjects, it would probably be a popular read.

Thank you for the tips.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9801
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Calling a function in LC Server

Post by FourthWorld » Wed Feb 27, 2019 12:24 am

fritzdekatt wrote:
Tue Feb 26, 2019 11:19 pm
FourthWorld wrote:
Tue Feb 19, 2019 7:12 pm
Was the difficulty on the AJAX side or the PHP side? I've used XMLHttpRequest to call LC Server routines, so I may be able to help once I learn more about where the trouble lies.
I have trouble on the AJAX side because my javascript stinks.
It's not you. It's JavaScript. :)

But seriously, in LC we most commonly submit requests to servers with GET and POST. These are built-in commands in LC. Give 'em a whirl and let us know if you run into any snags.
Bottom line, I'm so far from entertaining the notion of doing anything novel with LC server. I'm turning some simple PHP apps into LC analogues just for giggles.
To get started, let me know: are you running a VPS, dedicated server, or on a shared host?

With your background in Node.js I'm guessing not shared.

Also: how far have you gotten so far with LC Server? Able to submit requests and get replies?

As for stack on a sever, there are two main ways they're useful:

1. On the server, a stack file can be a good way to keep multiple scripts in one place. And if you have an Indy or Business license, those scripts can be encrypted as well, making server solutions deliverable to customers if you're in that sort of business. Stacks can also be used to generate custom graphics based on user inputs.

2. In an LC client app, stacks can be downloaded from a server quite easily. This allows many of the same benefits of web delivery, in terms of instant updates so your users always have the latest UI. There's an example living on your hard drive right now: in LC, see Development -> Plugins -> GoLiveNet. The initial progress window you see is the only thing in the plugin itself. From that point on everything you see is downloaded on the fly from one of my servers to run locally on your computer. Of course this won't help if your target is the browser, but if you're also making LC standalones that are already network-dependent, being able to download stacks dynamically over the web has many advantages.
Obviously, if some veteran did write a "book-long post" on these subjects, it would probably be a popular read.
Lordy, how I wish I could. Find my someone to pay my bills for a couple months and I'll actually write a full book.

For now, I eek out what time I can here and hope it helps.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

fritzdekatt
Posts: 57
Joined: Fri Feb 09, 2018 2:28 am

Re: Calling a function in LC Server

Post by fritzdekatt » Wed Feb 27, 2019 12:28 am

bogs wrote:
Tue Feb 19, 2019 9:31 pm
bogs wrote:
Tue Feb 12, 2019 12:44 pm
Someone else also had information on Lc server, but I think that was more basic. If I remember it, I'll stop in with the link.
This was pretty basic http://livecode.byu.edu/internet/revservercripting.php I think they have more on it (but you have to go through the index for that). There was also https://activethought.net/livecode-server/introduction , which is kind of an 'unofficial' guide, not sure how accurate the information is, but it was linked (inaccurately) from BYU as well, so I'd be thinking it probably isn't a waste of time.
Nothing's too basic for me, Bogs. I saw these sites awhile back, but circling around for another look I find some new ways to apply what I've learned lately. Ditto for the LC Supersite you mentioned. There was a link to Server stacks, which took me back to the LC site, where they did give a brief overview of how to use them (though not a reason why to use them over includes). The bottom line is I'll just have to implement one and see how it goes.

On the BYU site they have a great calendar example (which you'd think would be the last thing you'd want to try on your first outing with a new language). I remember my first PHP calendar (just the grid) took me days to debug. This one was a half hour, with a little CSS thrown in. Am I just a better programmer now? I doubt it. For some reason, it took less code, but I don't know why. PHP is pretty straightforward with loops and conditionals, but this was just easier.

Thanks for looking these sites up. BYU is particularly useful for the novice (me), but the trouble is you can only access a small portion of the site. I think I saw on the LC site that you can actually take this whole course. Maybe I'll check this out after I finish the Cloud Academy (which, at the rate I'm going, will be the beginning of summer).

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Calling a function in LC Server

Post by bogs » Wed Feb 27, 2019 12:24 pm

fritzdekatt wrote:
Wed Feb 27, 2019 12:28 am
BYU is particularly useful for the novice (me), but the trouble is you can only access a small portion of the site.
Hm, I seem to remember the index being completely open, through at least the 210 materials. You mean that has changed?
Image

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Calling a function in LC Server

Post by bogs » Fri Mar 01, 2019 3:04 pm

Hey Fritzdekatt,
Check your private message box :D
Image

fritzdekatt
Posts: 57
Joined: Fri Feb 09, 2018 2:28 am

Re: Calling a function in LC Server

Post by fritzdekatt » Tue Mar 05, 2019 12:45 pm

bogs wrote:
Wed Feb 27, 2019 12:24 pm
fritzdekatt wrote:
Wed Feb 27, 2019 12:28 am
BYU is particularly useful for the novice (me), but the trouble is you can only access a small portion of the site.
Hm, I seem to remember the index being completely open, through at least the 210 materials. You mean that has changed?
This text on the main page at:
http://livecode.byu.edu/

BYU DigHT Course Websites:
For BYU students enrolled in DigHT courses. (Login required.)

DigHT 210 - Instructional Applications Programming I: Beginning Programming in LiveCode
Section 1 (D. Asay/R. Hansen)
DigHT 310 - Instructional Applications Programming II: Advanced LiveCode Programming

The text above links to this:
https://cas.byu.edu/cas/login?service=h ... t%2Chome.0

Now, it clearly says it's part of a BYU course, so I have no problem with that. There's plenty of free information they do provide, and I believe I've gone through all of it. Seeing that I gained something from the free stuff, however, I'd love to get at the other stuff (for which I would happily pay). I do believe, as I mentioned, that the LC site had a link to a paid BYU course, which may reference the links I just posted. I haven't seen it for awhile, and I'm taking the Cloud course now so it's not a priority.

Thanks for pointing this out to me and sending me the link.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Calling a function in LC Server

Post by bogs » Tue Mar 05, 2019 1:36 pm

Ah, your looking at the wrong link on the page you sent me. Look above what your talking about -
Selection_001.png
Dis must be da place!
Click on that link, and you'll be taken to this page -
Selection_002.png
Ah HAH!
Waayy down on that page, you'll see this section -
Selection_003.png
Internetty stuff and like that...
Hope that helps :D
Image

fritzdekatt
Posts: 57
Joined: Fri Feb 09, 2018 2:28 am

Re: Calling a function in LC Server

Post by fritzdekatt » Mon Mar 11, 2019 12:23 pm

bogs wrote:
Tue Mar 05, 2019 1:36 pm
Ah, your looking at the wrong link on the page you sent me. Look above what your talking about -
Selection_001.png
Click on that link, and you'll be taken to this page -
Selection_002.png
Waayy down on that page, you'll see this section -
Selection_003.png

Hope that helps :D
I get what you mean. That's a lot of information that is totally open to the public.
I was specifically referring to the part that wasn't totally open, just because you mentioned that you recalled it being completely accessible. I was just wondering what kind of course it was that was only accessible by BYU students. Nevertheless, I'm sure that the information they do offer there for free is enough to engage me for quite some time.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Calling a function in LC Server

Post by bogs » Mon Mar 11, 2019 1:29 pm

fritzdekatt wrote:
Mon Mar 11, 2019 12:23 pm
I was specifically referring to the part that wasn't totally open, just because you mentioned that you recalled it being completely accessible.
Yes, I believe both ways to access it are exactly the same lessons, I think the difference is that in the actual BYU course available to the students, references to example lessons and script submissions (that are on the Uni server for students with logins to said server) aren't accessible to the 'free' version of the course.

The course itself seemed feature complete to me, and the lessons seem to be the exact same lessons as far as the textual parts go.
Image

fritzdekatt
Posts: 57
Joined: Fri Feb 09, 2018 2:28 am

Re: Calling a function in LC Server

Post by fritzdekatt » Wed Mar 20, 2019 1:49 am

FourthWorld wrote:
Wed Feb 27, 2019 12:24 am
fritzdekatt wrote:
Tue Feb 26, 2019 11:19 pm
FourthWorld wrote:
Tue Feb 19, 2019 7:12 pm
Was the difficulty on the AJAX side or the PHP side? I've used XMLHttpRequest to call LC Server routines, so I may be able to help once I learn more about where the trouble lies.
I have trouble on the AJAX side because my javascript stinks.
It's not you. It's JavaScript. :)

But seriously, in LC we most commonly submit requests to servers with GET and POST. These are built-in commands in LC. Give 'em a whirl and let us know if you run into any snags.
Bottom line, I'm so far from entertaining the notion of doing anything novel with LC server. I'm turning some simple PHP apps into LC analogues just for giggles.
To get started, let me know: are you running a VPS, dedicated server, or on a shared host?
I've got a dedicated server in my office
With your background in Node.js I'm guessing not shared.
As you imply, Node.js does not yet play well with others.
Also: how far have you gotten so far with LC Server? Able to submit requests and get replies?
Oh yeah, I can get and post from my MySQL database just like PHP. Except I can't do named placeholders for queries. Oh well...
As for stack on a sever, there are two main ways they're useful:

1. On the server, a stack file can be a good way to keep multiple scripts in one place. And if you have an Indy or Business license, those scripts can be encrypted as well, making server solutions deliverable to customers if you're in that sort of business. Stacks can also be used to generate custom graphics based on user inputs.

2. In an LC client app, stacks can be downloaded from a server quite easily. This allows many of the same benefits of web delivery, in terms of instant updates so your users always have the latest UI. There's an example living on your hard drive right now: in LC, see Development -> Plugins -> GoLiveNet. The initial progress window you see is the only thing in the plugin itself. From that point on everything you see is downloaded on the fly from one of my servers to run locally on your computer. Of course this won't help if your target is the browser, but if you're also making LC standalones that are already network-dependent, being able to download stacks dynamically over the web has many advantages.
Now I know why they feature shared stacks on a web server, rather than just do 'includes'. From a client desktop standpoint, that makes perfect sense.
Obviously, if some veteran did write a "book-long post" on these subjects, it would probably be a popular read.
Lordy, how I wish I could. Find my someone to pay my bills for a couple months and I'll actually write a full book.
You could write a book on LC in a couple of months? Move to Nevada. The government there paid some yardbird to write cowboy poetry. Gave him half a mil. Surely, for a book with actual purpose they'd at least hand you a million or two.
For now, I eek out what time I can here and hope it helps.
Well, keep on eeking. At least I learned something today, book or no book.

Post Reply

Return to “CGIs and the Server”