Re: LC Web integration is not good enough

2018-05-01 Thread Monte Goulding via use-livecode

> On 2 May 2018, at 9:20 am, Andre Garzia  wrote:
> 
> The problem is that no web api expects an object with numeric keys, it 
> expects an honest, real, array. The fact that LC arrays are actually hashmaps 
> is awesome, I love them as well, but it still makes it impossible to export 
> arrays from LC which are really common on Web APIs. JSONExport library should 
> check if the keys of a given array level are all numeric and cast it to a 
> list type.

I think that’s what Mark ended up agreeing with on the bug report. JSONExport 
probably needs a LCB API does what you expect with the types it is passed and a 
LCS API that does some of this fudging like checking if a string is a number of 
if it’s true or false or an array is a list… etc.
> 
> Thats is what I say when RunRev web integration is not good enough. They 
> provide a json import and export function but it doesn't work well enough for 
> you to call any API that expects an array... We always go like 70% or 80% of 
> the way in a feature and then there is a new LC Infinite Ultra Campaign to 
> get some new stuff in when the current stuff is not yet ready.

You did see what I wrote about ArrayToJSON? It’s included in LiveCode also and 
is also significantly faster than JSONExport.
> 
> Same thing with executing JS inside a WebView Widget, we need to use the "do 
> in widget" statement but this doesn't have a way to bind values, so you end 
> up assembling a JS string by hand in hopes that you got all the correct 
> quotes right because you need to inline all params as literal objects...

Can you open a feature request for this. I presume you mean:

do “something(:1,:2)” in widget “foo” with “bar”,”baz”

Seems quite feasible. The best way to get what you want is to ask for it ;-)

Cheers

Monte
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: LC Web integration is not good enough

2018-05-01 Thread Andre Garzia via use-livecode
Monte,

The problem is that no web api expects an object with numeric keys, it
expects an honest, real, array. The fact that LC arrays are actually
hashmaps is awesome, I love them as well, but it still makes it impossible
to export arrays from LC which are really common on Web APIs. JSONExport
library should check if the keys of a given array level are all numeric and
cast it to a list type.

Thats is what I say when RunRev web integration is not good enough. They
provide a json import and export function but it doesn't work well enough
for you to call any API that expects an array... We always go like 70% or
80% of the way in a feature and then there is a new LC Infinite Ultra
Campaign to get some new stuff in when the current stuff is not yet ready.

Same thing with executing JS inside a WebView Widget, we need to use the
"do in widget" statement but this doesn't have a way to bind values, so you
end up assembling a JS string by hand in hopes that you got all the correct
quotes right because you need to inline all params as literal objects...

:-(

On Mon, Apr 30, 2018 at 10:42 PM, Monte Goulding via use-livecode <
use-livecode@lists.runrev.com> wrote:

>
>
> > On 1 May 2018, at 11:29 am, Mark Wieder via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> >
> > On 04/30/2018 03:15 PM, Ralph DiMola via use-livecode wrote:
> >> Andre,
> >> I'm using JSONToArray and ArrayToJSON for round trip with no problems.
> I'm
> >> storing an LC config array in a JSON text file, then later read the file
> >> back into an LC array. The only criticism I have is the formatting of
> the
> >> JSON in the text file could be better for manual changes with a text
> editor.
> >> Other than that it faithfully saves/recreates the LC array.
> >
> > ... as long as you don't have to deal with JSON lists.
> >
> > https://quality.livecode.com/show_bug.cgi?id=19698
>
> ArrayToJSON deals with JSON list differently to JSONExport. ArrayToJSON
> uses mergJSON which checks if the array keys are a numeric sequence and
> assumes it’s a list. There is a way to force it to be an object if
> required.
>
> JSONExport on the other hand is done in LCB and LCB has a proper list
> type. The issue is when passing a LCS array to LCB there is no way for the
> engine to know for sure if your array is a list or map so it keeps it as a
> map with string keys. In the long run if we ever get proper lists in LCS
> then JSONExport will likely do as you are expecting.
>
> Cheers
>
> Monte
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



-- 
http://www.andregarzia.com -- All We Do Is Code.
http://fon.nu -- minimalist url shortening service.
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: LC Web integration is not good enough

2018-05-01 Thread Mark Wieder via use-livecode

On 04/30/2018 06:42 PM, Monte Goulding via use-livecode wrote:


ArrayToJSON deals with JSON list differently to JSONExport. ArrayToJSON uses 
mergJSON which checks if the array keys are a numeric sequence and assumes it’s 
a list. There is a way to force it to be an object if required.


Ah, right. Thanks. It was indeed JSONExport (or more properly 
JSONImport) I was thinking of.


--
 Mark Wieder
 ahsoftw...@gmail.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: LC Web integration is not good enough

2018-04-30 Thread Monte Goulding via use-livecode


> On 1 May 2018, at 11:29 am, Mark Wieder via use-livecode 
>  wrote:
> 
> On 04/30/2018 03:15 PM, Ralph DiMola via use-livecode wrote:
>> Andre,
>> I'm using JSONToArray and ArrayToJSON for round trip with no problems. I'm
>> storing an LC config array in a JSON text file, then later read the file
>> back into an LC array. The only criticism I have is the formatting of the
>> JSON in the text file could be better for manual changes with a text editor.
>> Other than that it faithfully saves/recreates the LC array.
> 
> ... as long as you don't have to deal with JSON lists.
> 
> https://quality.livecode.com/show_bug.cgi?id=19698

ArrayToJSON deals with JSON list differently to JSONExport. ArrayToJSON uses 
mergJSON which checks if the array keys are a numeric sequence and assumes it’s 
a list. There is a way to force it to be an object if required. 

JSONExport on the other hand is done in LCB and LCB has a proper list type. The 
issue is when passing a LCS array to LCB there is no way for the engine to know 
for sure if your array is a list or map so it keeps it as a map with string 
keys. In the long run if we ever get proper lists in LCS then JSONExport will 
likely do as you are expecting.

Cheers

Monte
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: LC Web integration is not good enough

2018-04-30 Thread Mark Wieder via use-livecode

On 04/30/2018 03:15 PM, Ralph DiMola via use-livecode wrote:

Andre,

I'm using JSONToArray and ArrayToJSON for round trip with no problems. I'm
storing an LC config array in a JSON text file, then later read the file
back into an LC array. The only criticism I have is the formatting of the
JSON in the text file could be better for manual changes with a text editor.
Other than that it faithfully saves/recreates the LC array.


... as long as you don't have to deal with JSON lists.

https://quality.livecode.com/show_bug.cgi?id=19698

--
 Mark Wieder
 ahsoftw...@gmail.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: LC Web integration is not good enough

2018-04-30 Thread Bob Sneidar via use-livecode


> On Apr 30, 2018, at 14:30 , Andre Garzia via use-livecode 
>  wrote:
> 
> Hi Friends,
> 
> This is a bit of a rant because I can't believe no one stopped by these
> kind of problems before.



Sounds like what I went through getting MacOS Livecode to tell Applescript to 
tell Acrobat to run a Javascript! Talk about convoluted!! But it works so I 
close my eyes and click my heels and keep repeating, "There's no place like 
Starbucks! There's no place like Starbucks...)

Bob S


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


RE: LC Web integration is not good enough

2018-04-30 Thread Ralph DiMola via use-livecode
Andre,

I'm using JSONToArray and ArrayToJSON for round trip with no problems. I'm
storing an LC config array in a JSON text file, then later read the file
back into an LC array. The only criticism I have is the formatting of the
JSON in the text file could be better for manual changes with a text editor.
Other than that it faithfully saves/recreates the LC array.

Ralph DiMola
IT Director
Evergreen Information Services
rdim...@evergreeninfo.net

-Original Message-
From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On Behalf
Of Andre Garzia via use-livecode
Sent: Monday, April 30, 2018 5:30 PM
To: How to use LiveCode
Cc: Andre Garzia
Subject: LC Web integration is not good enough

Hi Friends,

This is a bit of a rant because I can't believe no one stopped by these kind
of problems before.

First of all, the JS Handlers for a browser widget are one way only. There
is no way to call a LiveCode function from JS and actually see a response.
You need to code two JS functions, one for calling LC and another for
receiving the LC response in an analog (even worse) to the old callback hell
of JS from early 2000. I find this quite unacceptable, it makes impossible
to make multiple calls to LC to retrieve values without devolving into a
spiral of callbacks.

Besides the only way to execute JS code from LC is to use the do statement,
which works with strings making it hard to assemble values compatible with
JS. You need to go like building SQL statements in 1990s by concatenating a
JS to be executed which is not only error prone, it is error certain. It
will fail if you are building something really complext because

Because LC jsonExport routines are broken, for they will export an array as
an object, which makes no sense at all. For example, if you have an array
like:

t[1]["name"] = "andre"
t[2]["name"] = "cleo"

jsonExport will output:

{"1": {"name": "andre"},"2": {"name": "cleo"}} instead of the correct:

[{"name": "andre"}, {"name": "cleo"}]

If you pick an array, pass through that jsonExport routine, assemble a
correct JS string, send it to the web widget and the JS on the other side is
expecting an array, it will fail because that is an object.

So, in summary:

* We have subpar integration that relies on callback hell
* The json routines don't work
* The integration to execute JS from LC relies on error-prone hand assembled
strings

The worst thing for me is the JSON library exporting objects. How did this
didn't affected people on this list on the past is a bit beyond me.

I am doing a simple round-trip execution of LC + JS here and it is taking me
hours because I need to fight the current buggy feature implementations
instead of focusing on my own business logic.

--
http://www.andregarzia.com -- All We Do Is Code.
http://fon.nu -- minimalist url shortening service.
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


LC Web integration is not good enough

2018-04-30 Thread Andre Garzia via use-livecode
Hi Friends,

This is a bit of a rant because I can't believe no one stopped by these
kind of problems before.

First of all, the JS Handlers for a browser widget are one way only. There
is no way to call a LiveCode function from JS and actually see a response.
You need to code two JS functions, one for calling LC and another for
receiving the LC response in an analog (even worse) to the old callback
hell of JS from early 2000. I find this quite unacceptable, it makes
impossible to make multiple calls to LC to retrieve values without
devolving into a spiral of callbacks.

Besides the only way to execute JS code from LC is to use the do statement,
which works with strings making it hard to assemble values compatible with
JS. You need to go like building SQL statements in 1990s by concatenating a
JS to be executed which is not only error prone, it is error certain. It
will fail if you are building something really complext because

Because LC jsonExport routines are broken, for they will export an array as
an object, which makes no sense at all. For example, if you have an array
like:

t[1]["name"] = "andre"
t[2]["name"] = "cleo"

jsonExport will output:

{"1": {"name": "andre"},"2": {"name": "cleo"}}
instead of the correct:

[{"name": "andre"}, {"name": "cleo"}]

If you pick an array, pass through that jsonExport routine, assemble a
correct JS string, send it to the web widget and the JS on the other side
is expecting an array, it will fail because that is an object.

So, in summary:

* We have subpar integration that relies on callback hell
* The json routines don't work
* The integration to execute JS from LC relies on error-prone hand
assembled strings

The worst thing for me is the JSON library exporting objects. How did this
didn't affected people on this list on the past is a bit beyond me.

I am doing a simple round-trip execution of LC + JS here and it is taking
me hours because I need to fight the current buggy feature implementations
instead of focusing on my own business logic.

-- 
http://www.andregarzia.com -- All We Do Is Code.
http://fon.nu -- minimalist url shortening service.
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode