Page 1 of 1
How do I save in HTML5?
Posted: Sun Jun 27, 2021 1:11 pm
by achraf911
hello, I'm trying to create an application where I can send homework's and save them, so when students enters the app they can see the homework that has been written to them. I tried to create a launcher but unfortunately it doesn't open the "mainStack .livecode". (There is no space between mainstack and .livecode)
Here is the code of my Launcher:
Code: Select all
on OpenStack
set the itemDel to "/"
if the environment is "standalone application" then
if the platform is "Windows" or "Linux" or "Android" or "Kali Linux" or "ios" or "macOS" or "ipadOS" or "html" or "Debian" then
set the folder to item 1 to -5 of the filename of this stack
else
set the folder to item 1 to -2 of the filename of this stack
end if
else
set the folder to item 1 to -2 of the filename of this stack
end if
open stack "postEleve .livecode" -- open the stack mainStack .livecode (There is no space between postEleve and .livecode)
close stack "TheLauncher"
end OpenStack
Re: How do I save in HTML5?
Posted: Sun Jun 27, 2021 4:41 pm
by bogs
Well, just quickly looking at it,
should actually read
also, "the platform" doesn't cover nearly as many entries as you have....
The possible values returned by the platform function are:
"Win32" on any version of Windows
"Linux" on all Linux distributions
"MacOS" on any version of Mac OS X
"iphone" on iPhones, iPads and other iOS devices
"android" on smartphones, tablets and other Android devices
"HTML5" when running in a web browser
and lastly, I'd ditch that "if / or" statement you have for a switch / case if you really had to test all that out, but you almost certainly don't have to for this type of problem.
Re: to @bogs
Posted: Sun Jun 27, 2021 5:01 pm
by achraf911
Thank you for your reply @bogs but I don't know why it still doesn't open the mainStack.
I modified my launcher code:
Code: Select all
on OpenStack
set the itemDel to "/"
if the environment is "standalone application" then
if the platform is "Win32" or "Linux" or "MacOS" or "iphone" or "android" or "HTML5" then
set the default folder to item 1 to -5 of the filename of this stack
else
set the default folder to item 1 to -2 of the filename of this stack
end if
else
set the default folder to item 1 to -2 of the filename of this stack
end if
open stack "postEleve .livecode" -- open the stack mainStack .livecode (There is no space between postEleve and .livecode)
close stack "TheLauncher"
end OpenStack
Re: How do I save in HTML5?
Posted: Sun Jun 27, 2021 5:32 pm
by Klaus
Hi achraf911,
actually it is ->
the DEFAULTFOLDER (ONE word!)
But there is really no need to mess around with that folder!
I guess you added all your files and folder to your standalone via the "
Copy files" tab in the "
Standalone Application Settings", right?
If yes then you will find all of these in ->
specialfolderpath("resources") in your standalone on ANY platform and that even works in the IDE, where it points to the folder the current stack is in!
So you could do something like this:
Code: Select all
on OpenStack
put specialfolderpath("resources") & "/postEleven.livecode" into tStack
go stack tStack
close stack "TheLauncher"
end OpenStack
But remeber that even this way, you will not be able to SAVE that stack "postEleven.livecode", if that is what you want to.
If installed into the target OS application directory, we have no write permisson here!
Best
Klaus
Re: How do I save in HTML5?
Posted: Sun Jun 27, 2021 5:42 pm
by bogs
Klaus wrote: ↑Sun Jun 27, 2021 5:32 pm
actually it is -> the DEFAULTFOLDER (ONE word!)
That will teach me to knock out a quick response and not proof read it

Re: How do I save in HTML5?
Posted: Sun Jun 27, 2021 5:43 pm
by jacque
Code: Select all
if the platform is "Windows" or "Linux" or "Android" or "Kali Linux"
or "ios" or "macOS" or "ipadOS" or "html" or "Debian" then
While this won't necessarily throw an error, the syntax is wrong for what you want and it will always return false. Each option needs to have "or the platform is" preceding it. Alternately use "is among the items of" and then provide the options in a comma-delimited list.
But as mentioned, you probably don't need it anyway for a couple of reasons.
Re: How do I save in HTML5?
Posted: Sun Jun 27, 2021 6:46 pm
by achraf911
Hello Klaus, thank you for your reply, the launcher launch the mainStack but like you said it doesn't save what I submit in the app
How can I save what I submit?
Re: How do I save in HTML5?
Posted: Sun Jun 27, 2021 6:51 pm
by Klaus
Sorry, I never worked with HTML5, so no idea how to save a stack there.
I am not sure if the principles that work for desktop runtimes will also apply to HTML5.
Since all of the files are actually on the SERVER I am not sure if we can save a stack this way at all.
Re: How do I save in HTML5?
Posted: Sun Jun 27, 2021 11:49 pm
by achraf911
Ok thank you for the reply klaus!

Re: How do I save in HTML5?
Posted: Tue Jun 29, 2021 6:24 pm
by Bernard
achraf911 wrote: ↑Sun Jun 27, 2021 6:46 pm
Hello Klaus, thank you for your reply, the launcher launch the mainStack but like you said it doesn't save what I submit in the app
How can I save what I submit?
You are probably going to need one the following commands:
or
According to the Dictionary this works on HTML5.
However POSTing to a URL requires that the server which serves up your Livecode app also knows what to do with form-data/files that are sent to it.
These (PUT, POST) are the mechanisms by which virtually every web page that processes data from the browser is using. When you're running something in the browser (either Javascript or just a plain HTML form) you really don't have much option other than to send data back to a server with these HTTP verbs.
But if you're new to coding you might not want to have some server open on the internet that is receiving and processing data. If your students are in a classroom using an internal network that is firewalled from the internet, that will (probably) be less risky.
Re: How do I save in HTML5?
Posted: Wed Jun 30, 2021 12:33 am
by Bernard
Hmm... seems you can't use Livecode's POST command in html5.
viewtopic.php?f=120&t=36003
So you would probably have to use Javascript's POST, which may be far more complexity than you are wanting.