Why won't my very simple stack work in HTML5?

Bringing your stacks to the web

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

mbossiere
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 44
Joined: Wed Aug 01, 2007 2:15 am
Location: Tucson Arizona US

Why won't my very simple stack work in HTML5?

Post by mbossiere » Mon Jan 29, 2024 6:49 pm

I'm new here. Been using Livecode for years, and I've had success in the past with simple test stacks compiled for HTML5 but I'm running into a problem with a simple stack for converting the date to a special format I like and outputting it to a field.
The stack consists of a button, a field, and 2 functions that work fine in the LC IDE. But when compiled and run via a browser - nothing.

I also notice that copy and paste commands don't work in HTML versions.

Can anyone tell me what I'm overlooking? My button script is :

on mouseUp
get secsToMyLongStamp(the secs)
set the clipBoardData to it
put it into fld 1
end mouseUp

and my functions are as follows:

function secsToMyLongStamp tSecs
put tSecs into tDate
put tSecs into tTime
convert tDate to short date
put myNumFormat(tDate) into tDate
set twelveHourTime to false
convert tTime to long time
set the itemDelimiter to ":"
put item 1 of tTime & item 2 of tTime & item 3 of tTime into tTime -- remove colons
if tDate = "not a date" then return tDate else return tDate & "@" & tTime
end secsToMyLongStamp

function myNumFormat input
if input is not a date then -- error
return "not a date"
exit myNumFormat
end if
convert input to short date -- ex., "8/6/15", in case it is not
set the itemDelimiter to "/"
put item 3 of input into stamp -- the year
get item 1 of input
if the number of chars in it = 1 then put "0" before it
put "-" & it after stamp -- the month
get item 2 of input
if the number of chars in it = 1 then put "0" before it
put "." & it after stamp -- the day
return stamp
end myNumFormat

In the IDE the result would be "24-01.29@104727" (for an example)
In the browser version, nothing happens at all.
See :
https://wildcard.on-rev.com/my/Emscript ... yDate.html
“You do what you do out of your own private passion for the thing itself”
A Dillard (source: https://educheer.com/essays/annie-dillard-s-handed-my-own-life/)

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4003
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Why won't my very simple stack work in HTML5?

Post by bn » Mon Jan 29, 2024 7:40 pm

Hi mbossiere,

it seem like this line in your mouseUp handler is the offending line

Code: Select all

set the clipBoardData to it
I do not know why this is so. But maybe you find another way to get at the data of field 1

Kind regards
Bernd

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

Re: Why won't my very simple stack work in HTML5?

Post by Klaus » Mon Jan 29, 2024 8:16 pm

Yes, "clipboarddata" is not supported on HTML5, neither is "copy" and "paste".

mbossiere
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 44
Joined: Wed Aug 01, 2007 2:15 am
Location: Tucson Arizona US

Re: Why won't my very simple stack work in HTML5?

Post by mbossiere » Mon Jan 29, 2024 8:36 pm

I see. Can you suggest another method by which I can "simulate" the clipboard property?

If I can successfully put my result in fld 1 then how can a user collect that result?
“You do what you do out of your own private passion for the thing itself”
A Dillard (source: https://educheer.com/essays/annie-dillard-s-handed-my-own-life/)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9670
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Why won't my very simple stack work in HTML5?

Post by dunbarx » Mon Jan 29, 2024 9:51 pm

Yipes.

I do not use HTML5, but that seems like an important property not to support. ''Is the "fullClipboardData" or the "rawClipBoardData" supported?

Craig

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

Re: Why won't my very simple stack work in HTML5?

Post by Klaus » Mon Jan 29, 2024 9:54 pm

dunbarx wrote:
Mon Jan 29, 2024 9:51 pm
''Is the "fullClipboardData" or the "rawClipBoardData" supported?
Nope!

Is you dictionary broken, Craig? :-D

mbossiere
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 44
Joined: Wed Aug 01, 2007 2:15 am
Location: Tucson Arizona US

Re: Why won't my very simple stack work in HTML5?

Post by mbossiere » Mon Jan 29, 2024 11:38 pm

Actually, I'm trying to just get the script to put it's output into fld 1, first, then perhaps I can find a way to all the user to get it out.
The stack, as written, should put a result INTO fld 1. In the IDE, I can of course just copy the result from fld 1 to use it. In the browser, the button script (and functions) don't seem to put any data in fld 1 so the stack appears not to work at all.

As an experiment, I typed into the perennially empty fld 1 of the browser version of the stack, and I can type there. But trying to collect it (Command-C) simply leaves a "c" in the fld. I understand that HTML5 Livecode apparently does not do cut/paste but how are others working around this limitation?

I'd also like to know how, in the browser version does one collect "the secs" for example?
thanks
marc
bn wrote:
Mon Jan 29, 2024 7:40 pm
But maybe you find another way to get at the data of field 1
“You do what you do out of your own private passion for the thing itself”
A Dillard (source: https://educheer.com/essays/annie-dillard-s-handed-my-own-life/)

mbossiere
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 44
Joined: Wed Aug 01, 2007 2:15 am
Location: Tucson Arizona US

Re: Why won't my very simple stack work in HTML5?

Post by mbossiere » Tue Jan 30, 2024 12:09 am

Ok, I modified my btn script to

on mouseUp
put the secs into tSecs
get secsToMyLongStamp(tSecs)
put it into fld 1
end mouseUp

Now it works as exepected:
https://wildcard.on-rev.com/my/EmscriptenX/myDate.html

but how do I get the result from this field? (in the browser)
“You do what you do out of your own private passion for the thing itself”
A Dillard (source: https://educheer.com/essays/annie-dillard-s-handed-my-own-life/)

mbossiere
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 44
Joined: Wed Aug 01, 2007 2:15 am
Location: Tucson Arizona US

Re: Why won't my very simple stack work in HTML5?

Post by mbossiere » Tue Jan 30, 2024 12:26 am

One other question of interest: is there a dictionary that delineates legal and illegal parts of the LC language when building for HTML5 output? That would be handy!!
For example, another question that comes to my mind is, does revGoURL work inside such a web-app? It would be nice to look up such things rather than laboriously compiling test stacks!
marc
“You do what you do out of your own private passion for the thing itself”
A Dillard (source: https://educheer.com/essays/annie-dillard-s-handed-my-own-life/)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9670
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Why won't my very simple stack work in HTML5?

Post by dunbarx » Tue Jan 30, 2024 5:12 am

Klaus.

Lazy, you know.

Craig

mbossiere
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 44
Joined: Wed Aug 01, 2007 2:15 am
Location: Tucson Arizona US

Re: Why won't my very simple stack work in HTML5?

Post by mbossiere » Tue Jan 30, 2024 6:24 am

dunbarx wrote:
Tue Jan 30, 2024 5:12 am
Lazy, you know.
Haha! Me too
“You do what you do out of your own private passion for the thing itself”
A Dillard (source: https://educheer.com/essays/annie-dillard-s-handed-my-own-life/)

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

Re: Why won't my very simple stack work in HTML5?

Post by Klaus » Tue Jan 30, 2024 10:18 am

Bonjour Marc,

some hints:
1. No need to GET something first.
You can put the result of your function directly into a field!

2. Please use the CODE tags*** after pasting your script(s) here, that way the indenting will be preserved
and the scripts are better readable. ***In the little toolbar above this text field -> <>

Code: Select all

on mouseUp
   put the secs into tSecs
   ## get secsToMyLongStamp(tSecs)
   ## put it into fld 1
   put secsToMyLongStamp(tSecs) into fld 1
end mouseUp
3.
One other question of interest: is there a dictionary that delineates legal and illegal parts of the LC language when building for HTML5 output? That would be handy!!
Unfortunately not, but:
For example, another question that comes to my mind is, does revGoURL work inside such a web-app?
Look up the term in the dictionary and check the PLATFORMS entry. It tells you on what platform this command/function/whatever is supported.
dictionary.png
Best

Klaus

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4003
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Why won't my very simple stack work in HTML5?

Post by bn » Tue Jan 30, 2024 1:34 pm

Hi Marc,

I played around with the problem of the user copying a value from the field. I could not get it directly.

A very ugly workaround is to "put" the content of the field.

Code: Select all

on mouseUp
   get secsToMyLongStamp(the secs)
   put it into fld 1
   put it ## puts 'it' into the black area below your stack
end mouseUp
This puts it into the black area below your stack. From there you are able to copy the value.
It is not nice but at least a way to get at the value.

Kind regards
Bernd

I tested locally (local host) so I do not know if that hack works across the network. There are many security precautions in browsers against a lot of stuff.
Attachments
put in html.png
put in html.png (11.38 KiB) Viewed 1269 times

mbossiere
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 44
Joined: Wed Aug 01, 2007 2:15 am
Location: Tucson Arizona US

Re: Why won't my very simple stack work in HTML5?

Post by mbossiere » Tue Jan 30, 2024 4:20 pm

Klaus wrote:
Tue Jan 30, 2024 10:18 am
One other question of interest: is there a dictionary that delineates legal and illegal parts of the LC language when building for HTML5 output? That would be handy!!
Unfortunately not, but:
For example, another question that comes to my mind is, does revGoURL work inside such a web-app?
Look up the term in the dictionary and check the PLATFORMS entry. It tells you on what platform this command/function/whatever is supported.
dictionary.png
Best
Klaus
Thanks Klaus. "Server" indicates HTML5 support, yes?
yes I figured out how people are doing the quoted script snippets - very useful
“You do what you do out of your own private passion for the thing itself”
A Dillard (source: https://educheer.com/essays/annie-dillard-s-handed-my-own-life/)

mbossiere
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 44
Joined: Wed Aug 01, 2007 2:15 am
Location: Tucson Arizona US

Re: Why won't my very simple stack work in HTML5?

Post by mbossiere » Tue Jan 30, 2024 4:27 pm

bn wrote:
Tue Jan 30, 2024 1:34 pm
Hi Marc,
I played around with the problem of the user copying a value from the field. I could not get it directly.
A very ugly workaround is to "put" the content of the field.

Code: Select all

on mouseUp
   get secsToMyLongStamp(the secs)
   put it into fld 1
   put it ## puts 'it' into the black area below your stack
end mouseUp
This puts it into the black area below your stack. From there you are able to copy the value.
It is not nice but at least a way to get at the value.
Kind regards
Bernd
I tested locally (local host) so I do not know if that hack works across the network. There are many security precautions in browsers against a lot of stuff.
Thanks. Yes, I agree - it's ugly but this would be fine in some circumstances. I will try it across a network. So the black band acts like Msg box - very handy to know (As I said, I'm new to this type of deployment)
“You do what you do out of your own private passion for the thing itself”
A Dillard (source: https://educheer.com/essays/annie-dillard-s-handed-my-own-life/)

Post Reply

Return to “HTML5”