livecode JSON extension

2016-08-11 Thread Matt Maier
I'm using a stack written by someone else that's trying to call what
appears to be a built-in JSON library.

For example, it will call jsonImport() on some JSON, but won't find that
handler. The error says to check to see if the "com.livecode.library.json"
extension is checked in the standalone application settings.

I've checked and unchecked that extension several times. It's always
checked when I open the stack. How do I get Livecode to actually use that
extension?
___
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: Can use assign multiple behaviors to a single object?

2016-08-11 Thread Sannyasin Brahmanathaswami
@Dick

Sure, I think we would be interested. 

@ monte

Not sure if the above qualifies as use case… but may help ?

Our new app is very modular. Layout on disk looks like this

config.json
loader stack 
# stack script initializes all back/front and lib required to app wide use
# as declared in the json file.
   /modules
   /home
  config.json
  home.livecode
   /module 2
  config.json
  module 2.livecode
   /module 3
  config.json
  module 3.livecode
   /module 4
  config.json
  module 3.livecode
   /module 3
  config.json
  module 2.livecode
  /shared
  /backscripts # all instantiated at start up
 /api.livecode # app wide but not too long, no meant to overload.
  /frontscripts # all instantiated at start up
  /libs # meant to be instantiated with "start/stop using"

The loader stack initializes all back and front scripts, reads the top 
config.json and sees that the launchModule should be "home.livecode"  and 
that's what appear on screen on mobile at boot.  this is working great.  but 
obviously could get crazy very fast with library bloat.

user could later make module3 their opening modules, and the app will write 
that "favorite" request to the top config.json… next time they reboot the app 
on the phone, it would open to module3.livecode. 

So that's the architecture. 

OK so now the subjective views of life arrive.

For creating scrollers, which would be  "universal" requirement across the 
entire app, one approach is to create simply add another lib or backscript, 
include this in the json (which lists all libs to be initialized on start up) 
and it is loaded into the msg path on start up. 

The other approach would be to create a behavior and attach that to every stack 
that needs scrollers. 

Frankly, despite the "geeky, cool" appearance of nested behaviors, in this 
scenario I'm not seen that many advantages. I just like to explore it to see if 
new visions may actually be more maintainable, less buggy in the long run.

 But another view of life says that behaviors really REALLY, should only be 
used when there is  a very unique set of vars/methods that apply to (in this 
case) one card on one module.livecode stack.

Despite the attractiveness of Richard Parent/Child = a "kinda class like object 
hierarchy" I'm not seeing that it gets us anything more than backscripts if 
there is at all any commonality of methods that might be re-used on modules 
across the entire app. If you have 4 developers working on 

module1.livecode
module2.livecode
module3.livecode
module4.livecode

you just have to tell everyone to stay away form the loader and the api 
backscript, and be sure to pull every day and push every day (we are using Git) 
there is a bit of "pass the baton" that needs to be played by telling everyone 
to be careful, but since the config.json files and backscripts are all 
text…merging is not a problem. 

Meanwhile if dev 1 is building
modules1
  /image-puzzles.livecode
and
dev 2 is building
modules2
/interactive-books.livecode

we know that binary and the files in that modules folder are "none of our 
business" and there are no merge issues.

BUT were we start mixing a complex chain of parent-child behaviors into this 
overall CMS… I think it would become a team nightmare.   Also the requirement 
to attach behaviors when other wise you could just call a command you know is 
in the message path?

That said if dev2 wants to do that in his sand box

modules2
/interactive-books.livecode 
/books-shared
  /[100 small behaviors]

 fine… go ahead… no problem. 

There is also the issue of dealing with different opinions on the team as to 
the best architecture.  It's a different working environment than one dev 
building product working in a silo all by himself.

As an admin "sweet boss" I have a simple way to handle that: most senior on the 
team + most work out the door in the past two years in terms of  product(s) 
produced his or her opinion trumps "cool innovation" that actually has never 
used in production for anything that is actually in the app store. 

BR





  




On 8/11/16, 2:17 PM, "use-livecode on behalf of Dick Kriesel" 
 
wrote:

Because multiple behaviors appear in a list whose sequence the developer 
controls, the message path stays deterministic.

___
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: Can use assign multiple behaviors to a single object?

2016-08-11 Thread Sannyasin Brahmanathaswami
I meant "can't run parallel"

Svasti Astu, Be Well 
Brahmanathaswami

www.himalayanacademy.com

 

On 8/11/16, 3:08 PM, "use-livecode on behalf of Sannyasin Brahmanathaswami" 
 wrote:

So, since we know the behaviors can run parallel,

___
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: Can use assign multiple behaviors to a single object?

2016-08-11 Thread Sannyasin Brahmanathaswami
"I had tried indenting each level, but found it didn't provide that much
more clarity and preferred to keep linked behaviors at the same  level"


So, since we know the behaviors can run parallel, your view means behavior 3 is 
parent of 2? And behavior 2 is a patent of 1?
Swasti Astu! Be Well

( from my mobile )




On Thu, Aug 11, 2016 at 12:35 PM -1000, "Sannyasin Brahmanathaswami" 
mailto:bra...@hindu.org>> wrote:

Richard… tks for devolution I had it before but downloaded a fresh copy.

fyi that image " devo-mpath-nested.png"

button "Main Button"

shows three assigned behaviors in parallel, not nested?

??

On 8/11/16, 12:26 PM, "use-livecode on behalf of Richard Gaskin" 
 
wrote:

Here's a view with nested behaviors:




___
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


Re: Can use assign multiple behaviors to a single object?

2016-08-11 Thread Monte Goulding

> On 12 Aug 2016, at 10:17 AM, Dick Kriesel  wrote:
> 
> A use case involves the script editor’s "Apply" button, whose events may 
> matter to multiple development tools.  When that button already has a 
> behavior, the process for adding another also adds complexity and adverse 
> side effects.  The library encapsulates the complexity and prevents the 
> adverse side effects (that I’ve seen).

I’m interested in your use cases here on multiple levels. Firstly we are 
working towards an IDE with a rich set of events that plugins can subscribe to. 
We also need to flesh out a spec for filters which will probably just be events 
with pass by reference parameters so that things like IDE menus can be modified 
by plugins easily. One use case that I have wanted for a while is to be able to 
fiddle with the standalone settings in a plugin during savingStandalone. The 
end goal is all the IDE components are themselves plugins and people can use 
whichever parts suit their workflow. The other reason this tweaked my interest 
is I recently had a play with implementing a scriptChanged message which might 
be a good hook for your use cases. The idea needs a bit more thought so won’t 
make 8.1 although the scriptStatus property will (that returns an enum letting 
you know if the script is uncompiled, compiled or has an error… there’s a 
placeholder for a future warning state also).

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: Can use assign multiple behaviors to a single object?

2016-08-11 Thread Dick Kriesel

> On Aug 11, 2016, at 2:34 PM, Sannyasin Brahmanathaswami  
> wrote:
> 
> but looking for
> 
> OBJECT A (with behaviors)
>   behavior 1
>   behavior 2
>   bevaiour 3
> 
> all with an "equal standing"

I have a library called "libBehaviorList" you could use to give any object a 
list of behaviors, as if the "behavior" property evolved to allow a list. (I 
think it should, but I’m still exploring.)

A use case involves the script editor’s "Apply" button, whose events may matter 
to multiple development tools.  When that button already has a behavior, the 
process for adding another also adds complexity and adverse side effects.  The 
library encapsulates the complexity and prevents the adverse side effects (that 
I’ve seen).

Because multiple behaviors appear in a list whose sequence the developer 
controls, the message path stays deterministic.

If you’re interested, what would you like to know?

— Dick
___
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: Can use assign multiple behaviors to a single object?

2016-08-11 Thread Dr. Hawkins
On Thu, Aug 11, 2016 at 3:26 PM, Richard Gaskin 
wrote:

> With the current nesting setup we have the same ability to use multiple
> scripts to define a single class of objects, but much greater clarity with
> being able to know which will override/overload others.


Multiple inheritance can have its advantages--but I've yet to have ore than
a passing need for it.


-- 
Dr. Richard E. Hawkins, Esq.
(702) 508-8462
___
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: Can use assign multiple behaviors to a single object?

2016-08-11 Thread Richard Gaskin

Sannyasin Brahmanathaswami wrote:

> Richard… tks for devolution I had it before but downloaded a fresh
> copy

If yours is v4 or later it should have an option to notify you of 
updates automatically.



> fyi that image " devo-mpath-nested.png"
>
> button "Main Button"
>
> shows three assigned behaviors in parallel, not nested?

That's just a stylistic choice, not a custom engine build. :)

I had tried indenting each level, but found it didn't provide that much 
more clarity and preferred to keep linked behaviors at the same 
indentation level.


--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.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: Can use assign multiple behaviors to a single object?

2016-08-11 Thread Sannyasin Brahmanathaswami
Richard… tks for devolution I had it before but downloaded a fresh copy.

fyi that image " devo-mpath-nested.png"

button "Main Button" 

shows three assigned behaviors in parallel, not nested?

??

On 8/11/16, 12:26 PM, "use-livecode on behalf of Richard Gaskin" 
 
wrote:

Here's a view with nested behaviors:




___
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: Can use assign multiple behaviors to a single object?

2016-08-11 Thread Richard Gaskin

Sannyasin Brahmanathaswami wrote:

> The hierarchical behavior method obfuscates the architecture in the
> sense that it is very hard to see the common parent behaviors that
> are "hiding" behind the other child behaviors.

That's a function of the tool, not a weakness in the language.

The Project Browser shows objects according to their physical location, 
but I needed something different, a view that showed the full current 
active message path.  So I wrote one I call MPath, and included it in 
devolution:



Here's a view with nested behaviors:


devolution is free to use, and available here:



As for the language, I believe the implementation of behaviors is a good 
one.


If you need many handlers to define a specific class of objects, what is 
the spreading them out across multiple scripts?


And if it were possible, what would happen if two (or more) of those 
scripts contains handlers of the same name?


With the current nesting setup we have the same ability to use multiple 
scripts to define a single class of objects, but much greater clarity 
with being able to know which will override/overload others.


Even better, nested behavior scripts can act as sub- and super-classes, 
with a script defining things for several classes of objects, and each 
of those providing more specific routines unique to each class.



> p.s. I realize "parent-child" has been deprecated… that still doesn't
> mean, IMHO, it is not the optimal language choice for talking about
> behaviors.

Agreed.  Behavior is too generic.  The original name of parentScript was 
more descriptive.


--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.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: Can use assign multiple behaviors to a single object?

2016-08-11 Thread Sannyasin Brahmanathaswami
agreed and done

http://quality.livecode.com/show_bug.cgi?id=18176

please add more if my description is insufficient.

Aloha!

BR


On 8/11/16, 11:40 AM, "use-livecode on behalf of Monte Goulding" 
 wrote:

Given the width it would probably be nice to support showing the full 
behavior hierarchy on the project browser. If you would like to open an 
enhancement request on that I think it would be a nice feature.

___
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: Can use assign multiple behaviors to a single object?

2016-08-11 Thread Monte Goulding

> On 12 Aug 2016, at 7:34 AM, Sannyasin Brahmanathaswami  
> wrote:
> 
> The hierarchical behavior method obfuscates the architecture in the sense 
> that it is very hard to see the common parent behaviors that are "hiding" 
> behind the other child behaviors.

Given the width it would probably be nice to support showing the full behavior 
hierarchy on the project browser. If you would like to open an enhancement 
request on that I think it would be a nice feature.

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: Can use assign multiple behaviors to a single object?

2016-08-11 Thread Sannyasin Brahmanathaswami
Monte: yes I was aware of that option… but looking for

OBJECT A (with behaviors)
   behavior 1
   behavior 2
   bevaiour 3

all with an "equal standing". I can see how from the engine's point of view 
this might be challenging vs a hierarchical/cascading layout. 

ergo, answer is "no, you can't do it that way." (have multiple behaviors 
parallel to each other)

The hierarchical behavior method obfuscates the architecture in the sense that 
it is very hard to see the common parent behaviors that are "hiding" behind the 
other child behaviors. (perhaps I am wrong there)  i.e. making that method even 
more challenging from a transparency-maintenance architecture choice… may as 
well just "start/stop" using libs as needed.

p.s. I realize "parent-child" has been deprecated… that still doesn't mean, 
IMHO, it is not the optimal language choice for talking about behaviors

BR

On 8/11/16, 11:15 AM, "use-livecode on behalf of Monte Goulding" 
 wrote:

You can assign a behavior to a behavior object for common code you want to 
use in multiple behaviors. The IDE does support 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

No data in application browser in 8.0.2

2016-08-11 Thread Dr. Hawkins
I took one of my brief forays into version 8 today--shorter even than usual.

The application browser window comes up, but it's completely empty--with a
dozen stacks loaded!

-- 
Dr. Richard E. Hawkins, Esq.
(702) 508-8462
___
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: Can use assign multiple behaviors to a single object?

2016-08-11 Thread Monte Goulding
You can assign a behavior to a behavior object for common code you want to use 
in multiple behaviors. The IDE does support it.

Cheers

Monte

Sent from my iPhone

> On 12 Aug 2016, at 7:10 AM, Sannyasin Brahmanathaswami  
> wrote:
> 
> Pursuant to the new text only script architecture possibilities:
> 
> e.g. Group "portal-links"
> 
> Can we assign more than 1 behavior to this(any) group(object)?
> 
> Rumors are that it is possible. But, the IDE does not support it. Or at least 
> the current property inspector UI as it looks today, does not support it.
> 
> Manual assignment via script or msg box implementation would imply that doing
> 
> "set the behavior of [some object] to the long id of 
> [someObject/textOnlyScript]"
> 
> effectively replaces the one and only assigned behavior.
> 
> OTOH it does seem useful if you want more robust encapsulation of vars and 
> methods
> 
> vs overloading the global space with vars and methods from multiple 
> backscripts and libs added to the msg path by 'start using'
> 
> Comments?
> 
> But first, is it doable at all (2+ behaviors assigned to one object)?
> 
> A snake pit of behaviors that are all encapsulated seems less venomous than a 
> snake pit of stack/libs/scripts that are a live and globally "hot" in the 
> message hierarchy.
> 
> Of course one does have the added burden of making the behavior assignment, 
> but this seems a trivial burden when behaviors are encapsulated vs debugging 
> a global message path comprised 50 plus backscripts/stack scripts\
> 
> BR
> 
> ___
> 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


Can use assign multiple behaviors to a single object?

2016-08-11 Thread Sannyasin Brahmanathaswami
Pursuant to the new text only script architecture possibilities:

e.g. Group "portal-links"

Can we assign more than 1 behavior to this(any) group(object)?

Rumors are that it is possible. But, the IDE does not support it. Or at least 
the current property inspector UI as it looks today, does not support it.

Manual assignment via script or msg box implementation would imply that doing

"set the behavior of [some object] to the long id of 
[someObject/textOnlyScript]"

effectively replaces the one and only assigned behavior.

OTOH it does seem useful if you want more robust encapsulation of vars and 
methods

vs overloading the global space with vars and methods from multiple backscripts 
and libs added to the msg path by 'start using'

Comments?

But first, is it doable at all (2+ behaviors assigned to one object)?

A snake pit of behaviors that are all encapsulated seems less venomous than a 
snake pit of stack/libs/scripts that are a live and globally "hot" in the 
message hierarchy.

Of course one does have the added burden of making the behavior assignment, but 
this seems a trivial burden when behaviors are encapsulated vs debugging a 
global message path comprised 50 plus backscripts/stack scripts\

BR

___
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: Trouble setting the font of the text of a field

2016-08-11 Thread Dr. Hawkins
On Thu, Aug 11, 2016 at 12:53 PM, Jeanne A. E. DeVoto <
revolut...@jaedworks.com> wrote:

>   set the textFont of char 1 to -1 of tgTg to empty
>
> That should work.
>

It did, it did!

I had been trying "char 1 to -1 of the text of tgTg", which I suppose gets
past the same way as "the text of" . . .

The irony here is that the ability to refer to fields with other variables
is the single biggest reason for me to be using a HyperCard  solution . . .
(it was the *only* way to do what I was doing [am doing] back in the 80s
short of a LISP variant and low-level programming of the fields on my
screen . . .)




-- 
Dr. Richard E. Hawkins, Esq.
(702) 508-8462
___
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: Trouble setting the font of the text of a field

2016-08-11 Thread Jeanne A. E. DeVoto

At 11:28 AM -0700 8/11/2016, Dr. Hawkins wrote:

This code has been around a while; it's part of the maintenance routines.
But now it's glitching.

[...]

 set the textFont of the text of tgTg to empty



"the text of tgTg" would be parsed as the text content of the field.

Try using this instead:

  set the textFont of char 1 to -1 of tgTg to empty

That should work.

___
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: Trouble setting the font of the text of a field

2016-08-11 Thread Peter Bogdanoff
I've had better results with:
set char 1 to -1 of the text of ...

> On Aug 11, 2016, at 11:28 AM, Dr. Hawkins  wrote:
> 
> This code has been around a while; it's part of the maintenance routines.
> But now it's glitching.
> 
> tgTg holds the long id of a field
> 
> Inside a conditional, the last line of the code
> 
> set the txtFnt of tgTg  to "ArialMt"
> ck tgTg & cr &  the long name of tgTg
> set the textFont of the text of tgTg to empty
> 
> 
> is giving the error
> 
> button "mkArialMt": execution error at line 8 (Chunk: error in object
> expression) near "sofa_dpadr_", char 30
> 
> 
> Maybe it just hasn't hit a field with the condition in a while, but isn't
> this the correct way to clear the text of a field?
> 
> sofa_dpadr_ is indeed the name of the field in question, and it has text in
> it.
> -- 
> Dr. Richard E. Hawkins, Esq.
> (702) 508-8462
> ___
> 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


Trouble setting the font of the text of a field

2016-08-11 Thread Dr. Hawkins
This code has been around a while; it's part of the maintenance routines.
But now it's glitching.

tgTg holds the long id of a field

Inside a conditional, the last line of the code

 set the txtFnt of tgTg  to "ArialMt"
 ck tgTg & cr &  the long name of tgTg
 set the textFont of the text of tgTg to empty


is giving the error

button "mkArialMt": execution error at line 8 (Chunk: error in object
expression) near "sofa_dpadr_", char 30


Maybe it just hasn't hit a field with the condition in a while, but isn't
this the correct way to clear the text of a field?

sofa_dpadr_ is indeed the name of the field in question, and it has text in
it.
-- 
Dr. Richard E. Hawkins, Esq.
(702) 508-8462
___
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: [OT] Another reason we love LiveCode

2016-08-11 Thread Mark Waddingham

On 2016-08-11 17:32, Mike Kerner wrote:

or the difference between ++a and a++

and I didn't know, until yesterday, that "to" and "into" are synonyms.  
I

freaked out when the syntax checker didn't yell at me for "put 1 to a",
until I tested it.


There's lots of synonyms lurking around like that - in this case I'd 
class it as a bug. Overloading of synonyms for the 'connecting' words 
(like of, the, in, into, after, before, with etc.) is generally a bad 
idea as it reduces the potentially expressibility of the language in the 
future.


Monte recently did some work to indicate the status of script 
compilation of objects in the project browser (this should be in 8.1) 
which means fixing these small parsing errors (where the parser is 
wy to lax in terms of what it accepts) will cause less user friction 
- you'll be able to see clearly if you have scripts which no longer 
compile when loaded into a new version.


(Note, we'd only do this for minor laxness in syntax which is not very 
common and generally present as an accident which can mislead in terms 
of functionality of the script - we recently made 'repeat' parsing 
stricter and at least two people fixed actual bugs in their code as a 
result).


Warmest Regards,

Mark.

--
Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps

___
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: put one array after another

2016-08-11 Thread Peter M. Brigham
On Aug 11, 2016, at 11:37 AM, Matt Maier wrote:

> The way I've been tracking arrays in text for documentation purposes is
> basically just a table at heart:
> 
> array[first-key][this-key] = whatever
> array[first-key][that-key] = foobar
> array[2nd-key][some-key] = data
> array[2nd-key][another-one] = more data
> array[3rd-key][sub-key][new-level] = fake data
> array[3rd-key][sub-key][next-level] = probably also fake data
> array[3rd-key][sub-key][here-we-go-again] = totally the real data

This looks like the output of a function I use that was based on something Bob 
Sneider posted to this list.

function arrayToKeyList @pArray, _theKeyList
   -- from Bob Sneider, use-LC list, originally named altPrintKeys()
   --adjusted by Peter M. Brigham, pmb...@gmail.com
   -- returns a list of all the elements of pArray,
   --with their keys, in the form of   , eg,
   -- [1] ["runs"] [1] ["style"] ["textColor"]  0,0,0
   -- [1] ["runs"] [1] ["style"] ["textStyle"]  bold
   -- [1] ["runs"] [1] ["text"] function
   -- [1] ["runs"] [2] ["style"] ["textColor"]  0,0,0
   -- [1] ["runs"] [2] ["text"]  sr pStr
   -- [2] ["runs"] [1] ["style"] ["textColor"]  0,0,0
   -- [2] ["runs"] [1] ["text"]
   -- [2] ["runs"] [2] ["style"] ["textColor"]  0,127,0  ...
   -- pArray is referenced to avoid duplication of large arrays in memory,
   --but is not changed by this function
   -- _theKeyList is an internal parameter, used for the recursion
   --do NOT pass a second parameter when calling this function
   --  keyListToArray() is the inverse function, allowing you to re-create the 
array
   --from the key list
   -- requires deleteItem, getDelimiters(), keyListToArray()
   
   put numtochar(11) into vertTab
   put numtochar(30) into altCr
   put the keys of pArray into theKeys
   if line 1 of theKeys is a number then
  sort theKeys numeric
   else
  sort theKeys
   end if
   repeat for each line theKey in theKeys
  if theKey is a number then
 put "[" & theKey & "] " after _theKeyList
  else
 put "[" & quote & theKey & quote & "] " after _theKeyList
  end if
  if pArray[theKey] is an array then
 put pArray[theKey] into theTempArray
 put arrayToKeyList(theTempArray, _theKeyList) after theText
 deleteItem _theKeyList,-1,"] "
 put cr into char -1 of theText
  else
 if theKey is a number then
put "pArray" && "[" & theKey & "]" into theKeyName
 else
put "pArray" && "[" & quote & theKey & quote & "]" into theKeyName
 end if
 put value(theKeyName) into theValue
 replace tab with vertTab in theValue
 replace cr with altCr in theValue
 put _theKeyList & tab & theValue & cr after theText
 deleteItem _theKeyList,-1,"] "
  end if
   end repeat
   return theText
end arrayToKeyList

on deleteItem @pList, pItemNbr, pDelim
   -- deletes item pItemNbr of pList, given itemdel = pDelim
   -- based on replaceItem
   -- if pDelim = empty, defaults to tab as the delimiter
   -- pList is referenced, so the original list will be changed
   -- most useful when the itemdel is non-standard,
   --don't have to set it then reset it in calling script
   -- also, pDelim can be a string of characters, so you could do
   --pList = "first or ninth or second or third"
   --deleteItem pList,2," or "
   --and get "first or second or third"
   -- by Peter M. Brigham, pmb...@gmail.com — freeware,
   --based on a handler on the use-LC list
   -- requires getDelimiters()
   
   if pItemNbr = empty then exit deleteItem
   if pDelim = empty then put tab into pDelim
   if len(pDelim) > 1 then
  put getDelimiters(pList) into tempDel
  if tempDelim begins with "Error" then
 answer "Error in getDelimiters()" & cr & tempDelim
 exit to top
  end if
  replace pDelim with tempDel in pList
   else
  put pDelim into tempDel
   end if
   set the itemdelimiter to tempDel
   delete item pItemNbr of pList
   replace tempDel with pDelim in pList
end deleteItem

function getDelimiters pText, nbrNeeded
   -- returns a cr-delimited list of  characters
   --none of which are found in the variable pText
   -- use for delimiters for, eg, parsing text files, manipulating arrays, etc.
   -- usage: put getDelimiters(pText,2) into tDelims
   --if tDelims begins with "Error" then exit to top -- or whatever
   --put line 1 of tDelims into lineDivider
   --put line 2 of tDelims into itemDivider
   -- etc.
   -- by Peter M. Brigham, pmb...@gmail.com — freeware
   
   if pText = empty then return "Error: no text specified."
   if nbrNeeded = empty then put 1 into nbrNeeded -- default 1 delimiter
   put "2,3,4,5,6,7,8,16,17,18,19,20,21,22,23,24,25,26" into baseList
   -- low ASCII values, excluding CR, LF, tab, etc.
   put the number of items of baseList into maxNbr
   if nbrNeeded > maxNbr then 

Re: put one array after another

2016-08-11 Thread Matt Maier
I second the vote for a YAML library. It makes text and arrays work
together a lot better than JSON.

The way I've been tracking arrays in text for documentation purposes is
basically just a table at heart:

array[first-key][this-key] = whatever
array[first-key][that-key] = foobar
array[2nd-key][some-key] = data
array[2nd-key][another-one] = more data
array[3rd-key][sub-key][new-level] = fake data
array[3rd-key][sub-key][next-level] = probably also fake data
array[3rd-key][sub-key][here-we-go-again] = totally the real data

Usually I'll omit the redundant text, which helps me think of it as a tree

array[first-key][this-key] = whatever
[that-key] = foobar
array[2nd-key][some-key] = data
  [another-one] = more data
array[3rd-key][sub-key][new-level] = fake data
   [next-level] = probably also fake data
   [here-we-go-again] = totally the real data

On Thu, Aug 11, 2016 at 6:14 PM, Richard Gaskin 
wrote:

> Quentin Long wrote:
>
> > I don't know if there's a command that will do the job. However,
> > there's a construction I use when I merge two list variables into one:
> >
> > put ItemList2 into item (1 + the number of items in ItemList1) of
> > ItemList1
> >
> > That construction may seem a little weird, but it does the job. So
> > *if* the same sort of logic applies to arrays, something like this
> > might do the job:
> >
> > function ConcatArray Array1, Array2
> >   -- if this was a real function, it would confirm that Array1 and
> Array2 are both, you know, *arrays*
> >   put the number of lines in the keys of Array1 into A1
> >   put the keys of Array2 into key (A1 + 1) of Array1
> >   return Array1
> > end ConcatArray
>
> The "*if*" there is critical, as strings (LC lists) do not work like
> arrays.
>
> I'm not sure of the specifics of LC's implementation, but this general
> discussion may be useful:
> https://en.wikipedia.org/wiki/Associative_array#Implementation
>
> In brief (and woefully oversimplified), we could conceive of an array as a
> collection of memory addresses, in which each address is derived from a
> hashing function applied to the key.
>
> This is why when we try to display an array in a field it shows empty -
> there is no single string for the array data, its contents instead spread
> across multiple locations linked together through pointers. Indeed, given
> that arrays can be nested, it's non-trivial to come up with a string
> representation to meaningfully represent them.*
>
> In contrast to the actual structure of an array, using the keys function
> does return a string, a return-delimited list of the key names.  But the
> creation of that string is copying the keys from the actual array
> structure, and not the structure itself.
>
> So given an array which we could notate as:
>
>   Array2/
> key "a" = value "SomeValue"
> key "b" = value "SomeOtherValue"
>
> ...the line above that reads:
>
>   put the keys of Array2 into key (A1 + 1) of Array1
>
> ...would first get a string comprised of copies of the key names, like
> this:
>
>a
>b
>
> ...then add 1 to the number of lines there to get 3, and then use that as
> the string list of key names as the value of element Array1[3]
>
> That is, if the syntax "...into key  of " was
> something LC did - using LC we'd need to write that as:
>
>put the keys of Array2 into Array1[A1+1)
>
> But while that modified line would execute, it still won't do what we want
> here.  It applies a return delimited string of key names as a value to a
> single element, and what we're looking for is a method of bulk copying the
> actual array elements.
>
>
> This post may seem tediously long and pedantic, but bear with me, as I
> think we're discovering an opportunity for an enhanced array tutorial.
>
> The conceptualization of the role of array keys here closely matches one
> we saw a couple weeks ago on this list, in which a very experienced
> developer was attempting to use the keys of an array as a sort of bulk
> copying method for the array elements.
>
> Whether we have a good means of doing that bulk copying already (union
> seems useful here) is less interesting to me than the conceptualization
> itself.  There may be value exploring ways we might make the
> conceptualization of arrays more closely match their actual structure,
> hopefully making it easier for us to anticipate how the various syntax for
> arrays can and can't be used for a given task.
>
> Many years ago Dar Scott put together a wonderfully animated tutorial on
> LiveCode (then "Revolution") Message Mechanics, available here:
> http://pages.swcp.com/dsc/revstacks.html
>
> I wonder if we might have a similarly inventive soul among us who may be
> able to deliver something as nice for explaining array structure.
>
> As with Dar's stack, this may well be a case where illustrations, esp.
> animated ones, might help far more than any explanatory text alone.
>
> Arrays are among the more abstract things i

Re: [OT] Another reason we love LiveCode

2016-08-11 Thread Mike Kerner
or the difference between ++a and a++

and I didn't know, until yesterday, that "to" and "into" are synonyms.  I
freaked out when the syntax checker didn't yell at me for "put 1 to a",
until I tested it.
___
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


[OT] Another reason we love LiveCode

2016-08-11 Thread Richard Gaskin
The difference between "=" and "==" is something we LiveCoders never 
need to worry about:


https://i.redd.it/nf19afmd7kex.jpg

:)

--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.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: put one array after another

2016-08-11 Thread Richard Gaskin

Quentin Long wrote:

> I don't know if there's a command that will do the job. However,
> there's a construction I use when I merge two list variables into one:
>
> put ItemList2 into item (1 + the number of items in ItemList1) of
> ItemList1
>
> That construction may seem a little weird, but it does the job. So
> *if* the same sort of logic applies to arrays, something like this
> might do the job:
>
> function ConcatArray Array1, Array2
>   -- if this was a real function, it would confirm that Array1 and 
Array2 are both, you know, *arrays*

>   put the number of lines in the keys of Array1 into A1
>   put the keys of Array2 into key (A1 + 1) of Array1
>   return Array1
> end ConcatArray

The "*if*" there is critical, as strings (LC lists) do not work like arrays.

I'm not sure of the specifics of LC's implementation, but this general 
discussion may be useful:

https://en.wikipedia.org/wiki/Associative_array#Implementation

In brief (and woefully oversimplified), we could conceive of an array as 
a collection of memory addresses, in which each address is derived from 
a hashing function applied to the key.


This is why when we try to display an array in a field it shows empty - 
there is no single string for the array data, its contents instead 
spread across multiple locations linked together through pointers. 
Indeed, given that arrays can be nested, it's non-trivial to come up 
with a string representation to meaningfully represent them.*


In contrast to the actual structure of an array, using the keys function 
does return a string, a return-delimited list of the key names.  But the 
creation of that string is copying the keys from the actual array 
structure, and not the structure itself.


So given an array which we could notate as:

  Array2/
key "a" = value "SomeValue"
key "b" = value "SomeOtherValue"

...the line above that reads:

  put the keys of Array2 into key (A1 + 1) of Array1

...would first get a string comprised of copies of the key names, like this:

   a
   b

...then add 1 to the number of lines there to get 3, and then use that 
as the string list of key names as the value of element Array1[3]


That is, if the syntax "...into key  of " was 
something LC did - using LC we'd need to write that as:


   put the keys of Array2 into Array1[A1+1)

But while that modified line would execute, it still won't do what we 
want here.  It applies a return delimited string of key names as a value 
to a single element, and what we're looking for is a method of bulk 
copying the actual array elements.



This post may seem tediously long and pedantic, but bear with me, as I 
think we're discovering an opportunity for an enhanced array tutorial.


The conceptualization of the role of array keys here closely matches one 
we saw a couple weeks ago on this list, in which a very experienced 
developer was attempting to use the keys of an array as a sort of bulk 
copying method for the array elements.


Whether we have a good means of doing that bulk copying already (union 
seems useful here) is less interesting to me than the conceptualization 
itself.  There may be value exploring ways we might make the 
conceptualization of arrays more closely match their actual structure, 
hopefully making it easier for us to anticipate how the various syntax 
for arrays can and can't be used for a given task.


Many years ago Dar Scott put together a wonderfully animated tutorial on 
LiveCode (then "Revolution") Message Mechanics, available here:

http://pages.swcp.com/dsc/revstacks.html

I wonder if we might have a similarly inventive soul among us who may be 
able to deliver something as nice for explaining array structure.


As with Dar's stack, this may well be a case where illustrations, esp. 
animated ones, might help far more than any explanatory text alone.


Arrays are among the more abstract things in LiveCode, a language 
otherwise characterized by an ease of learning afforded through more 
concrete structures (objects, chunks - things we can see).  But arrays 
are so useful in so many contexts that it seems an excellent tutorial 
would be a welcome addition to our community learning resources.



* The challenge of representing associate arrays in a textual form is 
infamous; doable, but cumbersome.  JSON is the most popular way to do 
this, but being designed specifically for the JavaScript engine it's 
notoriously tedious to parse in anything other language.  YAML offers a 
much more human-readable/writable alternative, though less commonly used.


Now that JSON is included in LC 8 we do at last have a common means of 
translating LC's associative arrays to and from textual form.  But for 
the sake of readability, it might be nice if there was a common YAML 
library available as well.


--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.

Re: put one array after another

2016-08-11 Thread Quentin Long

sez Matt Maier :
> Is there a command to merge two array variables into one?
> 
> Example:
> 
> tFirstArray[tom] = mot
> tFirstArray[jane] = enaj
> 
> tSecondArray[bill] = llib
> tSecondArray[name] = eman
> 
> put tSecondArray after tFirstArray
> 
> tFirstArray[tom] = mot
> tFirstArray[jane] = enaj
> tFirstArray[bill] = llib
> tFirstArray[name] = eman

I don't know if there's a command that will do the job. However, there's a 
construction I use when I merge two list variables into one:

put ItemList2 into item (1 + the number of items in ItemList1) of ItemList1

That construction may seem a little weird, but it does the job. So *if* the 
same sort of logic applies to arrays, something like this might do the job:

function ConcatArray Array1, Array2
  -- if this was a real function, it would confirm that Array1 and Array2 are 
both, you know, *arrays*
  put the number of lines in the keys of Array1 into A1
  put the keys of Array2 into key (A1 + 1) of Array1
  return Array1
end ConcatArray

   
"Bewitched" + "Charlie's Angels" - Charlie = "At Arm's Length"

Read the webcomic at [ http://www.atarmslength.net ]!

If you like "At Arm's Length", support it at [ 
http://www.patreon.com/DarkwingDude ].

___
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