How do I save in HTML5?

Bringing your stacks to the web

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
achraf911
Posts: 4
Joined: Sun Jun 27, 2021 12:38 pm

How do I save in HTML5?

Post by achraf911 » Sun Jun 27, 2021 1:11 pm

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



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

Re: How do I save in HTML5?

Post by bogs » Sun Jun 27, 2021 4:41 pm

Well, just quickly looking at it,

Code: Select all

set the folder to...
should actually read

Code: Select all

set the default folder to...
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.
Image

achraf911
Posts: 4
Joined: Sun Jun 27, 2021 12:38 pm

Re: to @bogs

Post by achraf911 » Sun Jun 27, 2021 5:01 pm

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

Attachments
Screenshot 2021-06-27 185750.png
this is my standalone app files

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

Re: How do I save in HTML5?

Post by Klaus » Sun Jun 27, 2021 5:32 pm

Hi achraf911,

actually it is -> the DEFAULTFOLDER (ONE word!) 8)
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

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

Re: How do I save in HTML5?

Post by bogs » Sun Jun 27, 2021 5:42 pm

Klaus wrote:
Sun Jun 27, 2021 5:32 pm
actually it is -> the DEFAULTFOLDER (ONE word!) 8)
That will teach me to knock out a quick response and not proof read it Image
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6119
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: How do I save in HTML5?

Post by jacque » Sun Jun 27, 2021 5:43 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

achraf911
Posts: 4
Joined: Sun Jun 27, 2021 12:38 pm

Re: How do I save in HTML5?

Post by achraf911 » 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 :cry:

How can I save what I submit?

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

Re: How do I save in HTML5?

Post by Klaus » Sun Jun 27, 2021 6:51 pm

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.

achraf911
Posts: 4
Joined: Sun Jun 27, 2021 12:38 pm

Re: How do I save in HTML5?

Post by achraf911 » Sun Jun 27, 2021 11:49 pm

Ok thank you for the reply klaus! :D

Bernard
Posts: 308
Joined: Sat Apr 08, 2006 10:14 pm
Location: London, England

Re: How do I save in HTML5?

Post by Bernard » Tue Jun 29, 2021 6:24 pm

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

How can I save what I submit?
You are probably going to need one the following commands:

Code: Select all

post data to URL destinationURL
or

Code: Select all

put value into URL destinationURL
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.

Bernard
Posts: 308
Joined: Sat Apr 08, 2006 10:14 pm
Location: London, England

Re: How do I save in HTML5?

Post by Bernard » Wed Jun 30, 2021 12:33 am

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.

Post Reply

Return to “HTML5”