Page 1 of 3

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

Posted: Mon Jan 29, 2024 6:49 pm
by mbossiere
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

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

Posted: Mon Jan 29, 2024 7:40 pm
by bn
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

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

Posted: Mon Jan 29, 2024 8:16 pm
by Klaus
Yes, "clipboarddata" is not supported on HTML5, neither is "copy" and "paste".

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

Posted: Mon Jan 29, 2024 8:36 pm
by mbossiere
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?

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

Posted: Mon Jan 29, 2024 9:51 pm
by dunbarx
Yipes.

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

Craig

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

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

Is you dictionary broken, Craig? :-D

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

Posted: Mon Jan 29, 2024 11:38 pm
by mbossiere
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

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

Posted: Tue Jan 30, 2024 12:09 am
by mbossiere
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)

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

Posted: Tue Jan 30, 2024 12:26 am
by mbossiere
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

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

Posted: Tue Jan 30, 2024 5:12 am
by dunbarx
Klaus.

Lazy, you know.

Craig

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

Posted: Tue Jan 30, 2024 6:24 am
by mbossiere
dunbarx wrote:
Tue Jan 30, 2024 5:12 am
Lazy, you know.
Haha! Me too

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

Posted: Tue Jan 30, 2024 10:18 am
by Klaus
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

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

Posted: Tue Jan 30, 2024 1:34 pm
by bn
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.

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

Posted: Tue Jan 30, 2024 4:20 pm
by mbossiere
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

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

Posted: Tue Jan 30, 2024 4:27 pm
by mbossiere
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)