Re: WebDeployHelper tool - the LC10 web app toolbox

2024-04-05 Thread Alex Tweedly via use-livecode

That's cool !   I really like those 'slide-out' left buttons.

Thank you very much for this.

Alex.


On 05/04/2024 16:38, Andreas Bergendal via use-livecode wrote:

And as a follow-up on this, here is also a demo web app created with the help 
of WebDeployHelper 1.0.1:

https://wheninspace.com/WebDeployHelperTest/

To back my words! :D

/Andreas



5 apr. 2024 kl. 03:06 skrev Tom Glod via use-livecode 
:

thank you for making this available to the community.

On Thu, Apr 4, 2024 at 5:02 PM Ralph DiMola via use-livecode <
use-livecode@lists.runrev.com> wrote:


+1

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 William Prothero via use-livecode
Sent: Thursday, April 04, 2024 4:48 PM
To: How to use LiveCode
Cc: William Prothero
Subject: Re: WebDeployHelper tool - the LC10 web app toolbox

Andreas,
This sounds really great! It encourages me to start working with web
apps.Thanks for your contribution.
Best,
Bill

___
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: Revisiting Lock Screen

2024-03-28 Thread Alex Tweedly via use-livecode

Hi Bob,

I'm not sure from your description how / when you are seeing the 
(unexpected) changes happening.


Remember that lockscreen is automatically set to false when there is no 
handler running, so unlerss you have an intensive handler running, you 
will see these changes.


If it's not that - could you describe how you are verifying the effect 
of lockscreen in more detail. Thanks.


Alex.

On 27/03/2024 22:55, Bob Sneidar via use-livecode wrote:

Hi all.

I read in the dictionary that Lock Screen does not work in Script Debug mode. 
Okay so I turn it off, put the command “Lock Screen” at the entry point to a 
selectionChanged handler which goes on to do a number of things that change the 
appearance of the screen. The screen is decidedly NOT LOCKED! The things I go 
on to do are things like changing the hilitedItems of a tab widget which in 
turn shows and hides a number of objects, and also changes the selection in a 
number of datagrids. Every action that alters the screen is visible after I 
issue the Lock Screen command.

Is Lock Screen completely hosed? Am I missing something??

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


___
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: Tutorial for Livecode Server log in system

2024-03-26 Thread Alex Tweedly via use-livecode

Hi Tim,

I guess my first response would be - don't.

Specifically, don't store or use passwords. Users have a bad habit of 
re-using the same passwords, so even if your site has no personal or 
valuable info about your users, the fact that passwords get re-used 
means you are storing valuable info, and so you're taking on a moral 
responsibility to keep it very safe.


If you do have passwords, then you need to have a recovery mechanism for 
when users forget their pssword. 99% of the time, that involves emailing 
them a recovery link, or temp password, or ... So in effect the password 
has the same (or less) security than their email account - so you might 
as well just use the email account.


Nowadays I always use this style of password-free accounts. I would have 
sent a copy of the known, tested, etc. code - but it's all embedded in 
lots of my libraries, etc. and was tricky to unravel. So I've sent a 
very bare-bones version; tested but not all corner cases (e.g. I didn't 
wait a week to ensure time-outs happened properly :-).


Overview: The user asks for a code to login with, that gets emailed to 
them, and then they type that code in to the next screen. Once that's 
successfully done, you set up a cookie in their browser, valid for some 
reasonable length of time such as 7 days, and you're done. Any script 
that wants to can take the getCurrentUser() code to check that they are 
logged in properly.


Internally, it's done by creating a temporary code (6 digits, which is 
recorded along with their email and expires within 15 minutes), and once 
they have verified that code, you give them a new code which is a UUID 
(so essentially un-guessable) which lasts for the 7 days.


Other than that, I hope it's reasonably straightforward .


Alex.

simplelogin.lc


 tExpires then
  return empty
   else
  return item 2 of line -1 of tCodes
   end if
end getCurrentUser

function shellEscape pText
-- keep this at the end because it messes up Coda colouring
   repeat for each char tChar in "\`!$" & quote
  replace tChar with "\" & tChar in pText
   end repeat
   return pText
end shellEscape

function wrapQ pText
   return quote & pText & quote
end wrapQ

on askforemail
 put ""
 put "    My email is "
 put "    "
 put "    Submit my email 
"

 put ""
end askforemail

on askforcode
 put ""
 put "    My code is "
 put "    "
 put "    Submit my code "
 put ""
end askforcode

on askforlogout
 put ""
 put "    "
 put "    Log me out now"
 put ""
end askforlogout

-- real code start here

put getCurrentUser() into tUser

if $_POST["logout"] AND tUser is not empty then
   put $_COOKIE["myusercookie"] into tCode
   put tCode & comma & tUser & comma & (the seconds-1)  after \
   URL ("file:codes.txt")
  put "Successfully logged out."
  exit to top
end if

if tUser is not empty then -- ask them if they want to log out
  put "Already logged in as " & tUser
  askforlogout
  exit to top
end if

put $_POST["code"] into tCode
if tCode is not empty then
  -- we need to compare this code with what is pending
  put URL ("file:codes.txt") into tPending
  put ( tCode & comma & "*") into tFilter
  filter tPending with tFilter
  put line -1 of tPending into tPending
  if the seconds <= item 3 of tPending then  -- found a match pending
 put item 2 of tPending into tEmail
 put uuid("random") into tCode
 put tCode & comma & tEmail & comma & (the seconds+60*60*24*7)  
after \

   URL ("file:codes.txt")
 put cookie "myusercookie" with tCode until (the seconds + 60 * 60 
* 24 * 7)

 put "Successfully logged in"
 exit to top
  end if
  -- no match for the code
  put "Code not matched. Please try again or give different email 
address."

  askforcode
else
  put $_POST["email"] into tEmail
end if

if tEmail is not empty then
  -- have email address - generate a code and ask user for it
  put random(99) into tSix
  put format("%06d", tSix) into tSix

  -- put this following line in for quick and easy testing !!
  -- be sure to take it out later !!!
  put "should email" && tSix && "to you."

  -- build the message header, adding the from, to and subject details
  -- we also put any cc addresses in here, but not bcc (bcc addresses 
hidden)


  put "i...@kilmelford.com" into pFrom   -- CHANGE KILMELFORD.COM
  put tEmail into pTo
  put "From:" && pFrom  & return & \
   "To:" && tEmail & return & \
   "Subject: Login code for kilmelford.com" & \
    return into tMsg

   put "Content-Type: text/plain;" & return & return after tMsg
   put "Your code is" && tSix && "and it will expire in 15 minutes" 
after tMsg


   -- send the mail by piping the message we have just built to the 
sendmail command
   get shell("echo" && wrapQ(shellEscape(tMsg)) && "| 
/usr/sbin/sendmail" && \

 wrapQ(shellEscape(pTo)) && "-f" && wrapQ(shellEscape(pFrom)))

  put the seconds into tEndTime
  add 15 * 60 to tEndTime
  put tSix & comma & tEmail & comma & tEndTime  after \
   URL 

Re: FindIndex question

2024-03-25 Thread Alex Tweedly via use-livecode
Bob - I think you've mentioned these functions (and posted code, or a 
pointer to code, for them) before (but I couldn't find it). Any chance 
you could re-post (or just send to me, or ...)


Mike - I couldn't see in the thread *why* you want to use a dg ather 
than a pg ? Is there a missing capability you need ? Or some non-obvious 
(to me) reason to avoid pg?


Thanks,

Alex.

On 25/03/2024 18:50, Mike Kerner via use-livecode wrote:

i guess what i'm wondering is how quickly or slowly the dg will render, if
the dgArray is large. it seems to be slower, when the array is larger.

On Mon, Mar 25, 2024 at 2:48 PM Mike Kerner 
wrote:


i never heard of it called an "elevator". I anyways heard "thumb"

On Mon, Mar 25, 2024 at 2:08 PM Bob Sneidar via use-livecode <
use-livecode@lists.runrev.com> wrote:


I’ve thought about that. A temporary memory database would not appear to
the user to be faster, as the initial query for a large dataset will happen
all at once during which Livecode would be unresponsive. And if you page
the queries from the live database, re-storing the data in a memory
database would just be added time.

You could use send in time to cache forward and backwards a few pages,
and in that case a memory database could help, but if the user drags the
elevator box (how many people know what THAT is) then you go back to square
1 concerning efficiency.

Bob S



On Mar 25, 2024, at 10:34 AM, Mike Kerner via use-livecode <

use-livecode@lists.runrev.com> wrote:

i would be curious to know if an in-memory sqlite db increases scroll

speed

with dg's.
basically, you would live load the dg with pages from the db.
i can't imagine that the dg is faster than the pg. everything i've tried
with the pg is faster than the dg.
just one more reason to resurrect the script compiler and release it.

On Mon, Mar 25, 2024 at 11:16 AM Bob Sneidar via use-livecode <
use-livecode@lists.runrev.com> wrote:


I wrote a findInArray() function that will convert an array to a memory
based SQL database, and one of the arguments is the SQL query

statement to

use on the database. I have another called FilterArray() which simply
iterates through the keys to output those matching a criteria.

Bob S


On Mar 24, 2024, at 2:22 PM, Neville Smythe via use-livecode <

use-livecode@lists.runrev.com> wrote:



On 25 Mar 2024, at 3:00 am,Mike Kerner wrote:

i don't know if you dove into the code, but it's too early to think

about

unpacking this, so  here's the code: ...

Thanks Mike

While I was aware of the optional parameters feature of LC commands I

have never used it I so was unfamiliar with the syntax. The penny had

never

dropped that the parameter list for a command is just an array, so
evidently you can actually send an array instead of a comma delimited

list

Which means that you can send FindIndex a single parameter pKeyPairsA

which is an array with alternating colName,searchStr values

Setting up such an array is not particularly convenient for coding

however. My workaround had been to use a custom function hack

function myFindIndex pDataGrid, pKeyPairs
  — pKeyPairs is a comma delimited list such as

“colname1,str1,colname2,str2,..”

   replace comma with quote & comma & quote in pKeyPairs
   put “dispatch FindIndex to” && pDataGrid && “with” && quote &

pKeyPairs & quote into tCommandStr

   do tCommandstr
  put the result into tFoundIndex
  ...

A much more elegant (if probably no faster) solution is

function myFindIndex pDataGrid, pKeyPairs
  — pKeyPairs is a comma delimited list such as

“colname1,str1,colname2,str2,..”

   set the columnDelimiter to comma
   split pKeyPairs by column
   dispatch “FindIndex" to pDataGrid with pKeyPairs
  put the result into tFoundIndex
  ...


BTW, where did you find the source code for DataGrid handlers? I now

see

how one could write a FindIndices function to return all indices rather
than just the first found … or even a general WHERE  search :-)

Neville Smythe




___
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



--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
___
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: web

2024-02-03 Thread Alex Tweedly via use-livecode

I've not been able to get anything worthwhile to work on web.

All the working examples that I've seen (e.g. Andreas's example last 
week of interaction between browser and LC) , have involved a 
significant amount of html + JS being written. The default shipping web 
wrapper is completely under-functional (no simple customization, can't 
even handle a window resize, no documentation on what will/won't be 
possible, no cloud storage interface, ) that I'd have to describe it 
as pre-beta.


I'll look at the next DP to see if there's been any progress, but I've 
completely shelved all the ideas I had about using it any time soon.


Alex.

On 03/02/2024 15:40, Mike Kerner via use-livecode wrote:

my subscription is up, soon. i have web, but the last time i tried it, no
bueno. is anyone using web deploy?



___
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: We lost an Angle

2024-01-11 Thread Alex Tweedly via use-livecode

I  am so sorry for your loss.  You are in my prayers tonight.

Alex.

On 11/01/2024 01:54, Ralph DiMola via use-livecode wrote:

Many of you knew Margaret from the conferences. We lost her today. She spent
her life as a nurse in the oncology department. She gave her love and
empathy to all her patients. She was so full of life and gave it a gallant
try, but was not to be. We just celebrated our 40th anniversary in December.

You all were so kind and welcoming to her. I thank you for that.

  


Ralph DiMola

IT Director

Evergreen Information Services

rdim...@evergreeninfo.net

___
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: tsneterr: (3) URL using bad/illegal format or missing URL

2023-12-17 Thread Alex Tweedly via use-livecode



On 16/12/2023 14:51, Klaus major-k via use-livecode wrote:

Hi friends,

I am trying to upload a (not so long) urlencoded text list
to my server, but get the tsNet error as in the subject.

In the form of:
...
## Remove spaces etc.
put clean_name(tSetlist) into tDateiname
put "whatever" & CR & urlencode(fld "setlist") into tInhalt
put "https://www.MYSERVER.de/setlists.lc?name=; & tDateiname & "=" & 
tInhalt into tUrl
...
...

The error comes from LC and NOT from the server, tAnwort = EMPTY!

The URL is definitively correct!
Is the urlencoded string in tInhalt too long for a parameter?
Or is a CR in that parameter not a good idea?


The CR in the parameter is a bad idea.

Instead of

put "whatever" & CR & urlencode(fld "setlist") into tInhalt

would you not be better doing

put urlencode("whatever"  & fld "setlist") into tInhalt


(I can't reproduce the error here, so I can't be sure if this fixes it 
or not - but the CR in the url is definitely a bad idea).



Alex.



___
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: resizeControl wishes...

2023-11-30 Thread Alex Tweedly via use-livecode


On 30/11/2023 16:05, Paul Dupuis via use-livecode wrote:
resizeControl is sent "only sent when the user resizes a control by 
dragging its handles. It is not sent if a handler changes the size of 
a control by changing its properties (width, height, and so on)."



Basically, that dictionary entry is wrong.

If you *change* the size of a group by script, then that group *does* 
receive a resizeControl message.


Note that it does *not* receive a mesage just because the rect changes - 
only if the size changes.


So if you do something like

   repeat 10 times
       add 1 to X
       set the rect of grp "A" to X,Y, X+100, Y+100
   end repeat

then grp "A" will get either 0 or 1 message (from the first time through 
the loop).


If you do

   repeat 10 times
       add 1 to X
       set the rect of grp "A" to 100,Y, X+100, Y+100
   end repeat

it will receive either 9 or 10 messages.

So, essentially I think, your wish is already true :-)

Alex.

(Yes, tested pretty thoroughly in 10.0DP6 but I believe also true in 
earlier versions; I had to re-test this two days ago while playing with 
the recent benchmarking of groups vs cards).




___
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: Comparative speed in switching among groups

2023-11-27 Thread Alex Tweedly via use-livecode


On 27/11/2023 00:02, ambassador--- via use-livecode wrote:

An excuse to benchmark?  Sure, I'll bite. :)


:=).  Beat me to it.

But boy oh boy was I surprised by the difference.
Bottom line, in millisecs for just 5 iterations on an M1 Mac:

Groups: 141
Cards: 13619


Wow!



I suspect most layouts won't encounter this much of a difference. After all, I 
did choose the elements I could put together quickly with rendering impairment 
in mind.


But there is another consideration. When (if) you resize the stack, the 
'group' version will need to resize each of the groups (even when they 
are hidden), and if the number of different groups is non-trivial, that 
might make resizing slow.


I took Richard's test stack and resized each of the the text fields  to 
approx 1/3 of the stack width - and that was already painfully slow with 
two groups. So if you aim to have a large number of groups, you may be 
forced to overcome this yourself.


You can do something like

on resizecontrol
   if the visible of me then
  .
   end if
end resizecontrol

and be sure to add a

   send "resizecontrol" grp tGroup

immediately after you make group 'tGroup' visible again.


But I suspect the difference would still show itself in lighter layouts.

And now I'm curious: what are you working on where layout transition speed is 
critical?

Hmmm. Doesn't your test case already take 2-1/2 seconds to change card ? 
(13 seconds for 5 iterations).


That's plenty long enough to annoy me. I get frustrated (for example) 
with the forums, because of the 1-3 seconds it takes to transition from 
one interesting topic to the next.


I have no idea what current UI thinking is - and I admit that the 
increasing use of the web and online access has probably increased 
people's acceptance of small delays - but back in the day I was used to 
aiming for sub-second response to complete *most* user actions.


Alex.
___
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] The Fall of the British Empire???

2023-11-17 Thread Alex Tweedly via use-livecode


> 
>> On Nov 17, 2023, at 1:39 PM, 
>> 
>> England was #1 until 1916, when guess who took over.
>> 
>> Craig

Hmmm I thought it was the UK on the top spot.

Alex

___
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: Me and target of script widgets

2023-10-22 Thread Alex Tweedly via use-livecode

Brutal answer :-)

Script widgets aren't ready for release yet. They have (effectivtely) no 
documentation, no examples, no lessons.


Unless you have a desparate need to do it now, I'd suggest waiting until 
they are somewhere near ready.


Alex.

On 22/10/2023 10:41, David Bovill via use-livecode wrote:

Having my first go at script widgets. It appears that there is either an
issue (or it is a feature) with script widgets and "me"?

A handler like this:

*on* mouseUp

*## All references are to "inner" controls (ie the target) and not the
group*

*put* the short id of me into shortID

*put* the long id of the target into sName

*put* the long id of me into myID

*## Have to be explicit with messages*

*-- dispatch "menu_AskEdit" to me -- or the target does not work*

*dispatch* "menu_AskEdit" to this card with myID,shortID

*end* mouseUp

When inside a script only widget shows that would normally pass the long id
of the control clicked on within the group (script widget) with myID and
the short ID of the group (script widget) itself in shortID. However both
the target and me refer to the control and not the group / script widget.
It seems there is no easy way to find out a reference to "me" in a
script widget?

I've a lot of scripts that use "me" in behaviors for potential script
widgets - so looking for a short term and long term solution for this?
___
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: I give up! Mac App Installer Hell

2023-10-06 Thread Alex Tweedly via use-livecode

I'm afraid I can't help - wish I could.

But I have to say that "... tried the (out of date) LC Lesions," must be 
the best auto-correct failure this week.


Alex.

On 06/10/2023 23:44, Dan Friedman via use-livecode wrote:

If you have a very, very, VERY good understanding of creating Mac installer 
files to be posted to a website for user install, and to submit to the Mac App 
Store, I would like to pay you to walk me through all this - step by step.  I 
can’t take any of more this crap!  Certificates, Identifiers, Profiles, p12 
Files, Keys (public and private), Provisioning, Installer keys… G!!!  I 
have an app that is tested, built and ready to go.  Just need to get it signed 
and uploaded to Apple.   If you understand all this, I would think a 20 minute 
Skype call should get it done.

FYI… This is an update to an existing app that is already in the app store.  
(Don’t ask me how I got it done last time?!).  I don’t know why my brain can’t 
grasp this…. I have read Apple’s documentation, tried the (out of date) LC 
Lesions, watched videos, and gone through article after article.   At this 
point, I am not really interested in learning how to do this… I just want to 
get it done.

Save me!
-Dan
___
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: Sort bug

2023-08-31 Thread Alex Tweedly via use-livecode


On 01/09/2023 00:37, Bob Sneidar via use-livecode wrote:

The function is adding the value of two chunks together and returning the 
result. How does that even compute? Unless the + operator is doing something 
totally different here…


The code said:


sort lines tVariable by myVal(each)

where the function is for example

function myVal pStr
return item 1 of pStr + item 2 of pStr
end myval
since it's sorting the lines of the container, it calls the custom 
function with each line in turn. The function simply adds together the 
first two items from the passed-in line, and returns that. The returned 
value is associated with the corresponding line - and then the container 
is sorted by those associated values.


This works fine if the input variable is well formatted (i.e. first and 
second items of each line are numeric), but fails to give an error when 
something goes wrong - such as a non-numeric item.


(and, yes - the dictionary description is misleading, if not simply 
incorrect. However, the "Tip" at the end describes the use of ustom 
functions).


Alex.


___
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: Adding and delete a row of data to the Polygrid

2023-08-28 Thread Alex Tweedly via use-livecode
Sorry, I meant 10.x

In 9.x you could do

  put sColSubtotalArray  into tA[1]
  set the addDataAfter  of widget "rwTableview" to tA

Alex 

Sent from my iPhone

> On 28 Aug 2023, at 13:33, Paul Dupuis via use-livecode 
>  wrote:
> On 8/28/2023 7:28 AM, Alex Tweedly via use-livecode wrote:
>> The latest LC has the additional feauture of "automatic" sequences; i.e.
> 
> Is that LC 10.0.0dp5 or LC 9.6.9 or 9.6.10rc1, which 'latest' version?
> 
> ___
> 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: Adding and delete a row of data to the Polygrid

2023-08-28 Thread Alex Tweedly via use-livecode


On 27/08/2023 20:43, Paul Dupuis via use-livecode wrote:

I ran into an inconsistency with the Polygrid
...
I am not sure this is a BUG. It is certainly an inconsistency and 
changing it would break some current code. On the other hand, the 
Polygrid is part of the widget set for Xavvi/Livecode Create and the 
goal for that tool is to have things be super easy and super intuitive 
for beginners (non-code or low-code app building) so I think beginners 
would find thsi jarring.


So, is it a bug? What does the community think?


I'd say it's definitely not a bug.

It may be a "missing feature". There is an asymmetry, in that there are 
ways to


- extract one row

- delete one row

but only

- add multiple rows.

You could make a case for adding a feature to "add a single row". But I 
wouldn't bother,  because it's already so easy - see below.


You suggested converting by


  repeat for each key tKey in sColSubtotalArray
    put sColSubtotalArray[tKey] into tA[1][tKey]
  end repeat
 -- tA is now in the format that the addDataAfter property of the 
Polygrid requires. 


The latest LC has the additional feauture of "automatic" sequences; i.e.

  put [ sColSubtotalArray ] into tA

So, in fact you would simply do


  put the numberOfRows    of widget "rwTableview" into N
  set the pgInternalPointer of widget "rwTableview" to N
  set the addDataAfter       of widget "rwTableview" to [ 
sColSubtotalArray]


Alex.



___
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: Behaviors

2023-08-22 Thread Alex Tweedly via use-livecode
Not sure how it works in the IDE - seems a problem because it only 
presents button in the current stack.


So I do it all in preOpen... scripts, doing something like

set the behavior of fld "F" of grp tmpName to the long id of button 
"RichTextFieldBehaviour" of \
 card "Behaviours" of stack "/Users/alextweedly/Dropbox/My 
Livecode/Libraries/richText.livecode"


Alex.

On 22/08/2023 17:57, Dar Scott via use-livecode wrote:

I am misremembering things about Behaviors.

I have a card with my behavior buttons, but I can’t seem to point to buttons on 
that card. Maybe, I’m remembering what I did long ago with front scripts.

I suppose I can use substacks, but I’m worried that the stacks would be in the 
message path. Is there a way to keep the stack out of the message path?
___
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: Group corners

2023-08-21 Thread Alex Tweedly via use-livecode
I see those kind of changes (10.0.0DP5, MacOS), but the border changes 
from solid black to black/white lines - with those 'splits' you described.


Alex.

On 21/08/2023 01:50, Dar Scott via use-livecode wrote:

On Mac and LiveCode 9.6.9…

Make a new stack. Put a few controls on it. Group them.

Give the group a name

Set the border width to something like 10-15 so the effect is visible.

Turn off 3D.
  
Turn on border.


Now, turn show name on and off. When show name is off, the border looks good. 
When on, the border is goofy.

On my machine, when show name is on, the border gets thinner, most times. The 
ends of the border near the name is split into two lengths. The corners are 
split and some of the splits are too short. There are gaps compared to the 
pretty border when show name is off.

Dar



On Aug 19, 2023, at 11:07 AM, J. Landman Gay via use-livecode 
 wrote:

Weird how? The corners should be right angles. Do you see something different?

--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
On August 18, 2023 3:47:34 PM Dar Scott via use-livecode 
 wrote:


If I turn off 3D for a group, the corners of the rectangle are weird. Advice? — 
Dar
___
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



___
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: Sorting Arrays

2023-08-11 Thread Alex Tweedly via use-livecode


On 11/08/2023 23:00, J. Landman Gay via use-livecode wrote:

On 8/10/23 2:29 PM, Alex Tweedly via use-livecode wrote:
[ ... code from earlier posting ...]


I couldn't get this to work until I altered it, but I was using a very 
simple array. What type of array data did you use? I think I'm missing 
something.


I just did this:

  put the weekdayNames into tDataA
  split tDataA by cr
  simpleSortNumberedArray tDataA, "descending,text"

What you're missing is that this (simpleSortNumberedArray) is only 
intended for "numbered array"s (which LC is calling "sequences" in some 
places); i.e. an array where the (top-level) keys are all consecutive 
integers, from 1  n


Also, the pSortkeys should be a number of comma-separated items, each of 
which consists of a key by which you want to sort the array followed 
optionally by an order and type.


So you might do something like :


on mouseup
   local tCounter, tDataA

   repeat for each line L in the weekdayNames
  add 1 to tCounter
  put L into tDataA[tCounter]["dayname"]
  put the number of chars in L into tDataA[tCounter]["charcount"]
   end repeat

   -- sorts ascending by name (i.e. F, M, Sa, Su, Th, Tu, W)
   simpleSortNumberedArray tDataA, "dayname"
   repeat with I = 1 to 7
  put tDataA[I]["charcount"] && tDataA[I]["dayname"] & CR after msg
   end repeat

   put "-"  after msg

   -- sorts descending numeric by number of characters in name
   --  NB within each char count value, they remain in alphabetical 
order of name

   simpleSortNumberedArray tDataA, "charcount numeric descending"
   repeat with I = 1 to 7
  put tDataA[I]["charcount"] && tDataA[I]["dayname"] & CR after msg
   end repeat
end mouseup

and get as output


6 Friday
6 Monday
8 Saturday
6 Sunday
8 Thursday
7 Tuesday
9 Wednesday
-
9 Wednesday
8 Saturday
8 Thursday
7 Tuesday
6 Friday
6 Monday
6 Sunday


So - it would be worth adding a check that the array passed in is indeed 
a sequence, at the start of simpleSortNumberedArray:


if NOT (pArrayDataA is an array AND \
   item 2 of extents(pArrayDataA) is the number of elements in 
pArrayDataA) then \

 return pArrayData

I'm now going to add this to my personal library, but I'll rename it to

    seqSortMultipleKeys

Alex.



___
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: xavvi - temper your expectations

2023-08-10 Thread Alex Tweedly via use-livecode
I have high expectations of xavvi - mostly because I want the cloud IDE, 
cloud db, new widgets, ...


Oh - and I might just play with the AI, but I have no short-term 
expectations for that part of it.


:-)

Alex.

On 10/08/2023 20:22, Mike Kerner via use-livecode wrote:

i'm using chatgpt and bard, every day, because i can, and because
sometimes they give me more comprehensive things to think about.
but, they are wrong. a lot.
zdnet just published a piece, today, documenting the same thing: wrong

50% of the time.

so, temper your expectations for xavvi in the medium term:
https://www.zdnet.com/article/chatgpt-answers-more-than-half-of-software-engineering-questions-incorrectly/



___
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: Sorting Arrays

2023-08-10 Thread Alex Tweedly via use-livecode


On 09/08/2023 00:15, Bob Sneidar via use-livecode wrote:

Has anyone come across a need to sort a numbered array by the values of the 
different keys? Here you go.


Absolutely I have needed that quite often now. I tend to use sequences 
(numbered arrays) often - maybe too often.


Up until now I've just done the sorting in the "traditional" way (i.e. 
using multiple "sort" commands), like



   put seqAsLines(sQ2) into tKeys
   sort lines of tKeys numeric by sQ2[each]["anumber"]
   sort lines of tKeys by sQ2[each]["thecategory"]
   rebuildSeq sQ2, tKeys
(the functions seqAsLines and rebuildSeq are included in the code 
snippet below).


But I really like your idea of having a handler that can be given 
multiple sort keys, and just does it all, so I took a detailed look.


First - a couple of little bugs for you.


Keep in mind that there is no error checking so I have no idea what would 
happen if you provided a sort key that didn’t exist in the array.

on sortNumberedArray @pArrayDataA, pSortKeys
  switch
 case tKeyWord is among the items of "asc,ascending,desc,descending"
put tKeyWord into tSortKeysA [i] ["sortorder"]
break
 case tKeyWord is "International,Numeric,datetime,text,binary"

'is' should be 'is among the items of'

put tKeyWord into tSortKeysA [i] ["sorttype"]
break
 default
put word 1 to x of tSortIndex into tSortKeysA [i] ["sortvalue"]
  end switch
   end repeat
end repeat



Secondly, not sure if it's a bug or simply a limitation - the code fails 
if one of the array keys to use for sorting is one of 
"asc,desc,numeric,...".



And - overall, an alternate suggestion. I think your way is a bot complex.
Combining my "traditional" way as above, and your example, I came up 
with a  simpler way to do the same thing:



on simpleSortNumberedArray @pArrayDataA, pSortKeys
   local tKeys, tSeq, tOneSortKey, tSortCommand
   put seqAsLines(pArrayDataA) into tKeys
   repeat with I = the number of items in pSortKeys down to 1
  put item I of pSortKeys into tOneSortKey
  put "sort lines of tKeys" && word 2 to -1 of tOneSortKey && \
    "by pArrayData[each][" && word 1 of tOneSortKey && "]" 
into tSortCommand

  do tSortCommand
   end repeat
   rebuildSeq pArrayDataA, tKeys
end simpleSortNumberedArray

function seqAsLines pSeq
   local tRes
   repeat with i = 1 to the number of elements in pSeq
  put i & CR after tRes
   end repeat
   return tRes
end seqAsLines

command rebuildSeq @pSeq, pList
   local tResQ, tCount
   repeat for each line L in pList
  add 1 to tCount
  put pSeq[L] into tResQ[tCount]
   end repeat
   put tResQ into pSeq
end rebuildSeq
This is simpler and, I think, easier to understand. And it's certainly 
much faster: takes 89 msec for my test case rather than 3416 msecs.


Alex.



___
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: Question re download timeout setting

2023-07-22 Thread Alex Tweedly via use-livecode


On 22/07/2023 04:29, Bob Sneidar via use-livecode wrote:

Use sockets to test the connection.

Open socket to 
If the result is not empty then…
Close socket 


Hmmm - I have tried it but not got reliable results.

According to the dictionary that won't work reliably. Dictionary says:


(4.5) The open socket command no longer blocks on DNS resolution.

Instead, if resolution is required the command will return immediately

and the DNS lookup will happen in the background. If resolution fails,

then a socketError message is sent in the same was as if connection

fails.

So if you need a DNS resolution, you'll get an empty result - and a 
later socketError message. Your suggested code takes the empty result as 
a sign things are working - when they may not be.


(When I try to connect to a non existent host:port, I do get the empty 
result, but I don't seem to be getting the socketError messages. So 
there may be a bug in there - I'll try to track it down more closely, 
and if I can get anything reliable, submit a bug report).


btw - livekode.com was my first attempt at a  "non-existent host" - and 
it does exist !!


Alex.


On Jul 21, 2023, at 17:49, Alex Tweedly via use-livecode 
 wrote:



On 22/07/2023 01:02, prothero--- via use-livecode wrote:
Folks:
Sorry for the trivial question, but..
I have an app on my iphone that I am updating from a several years old app the 
previously worked on an older version of livecode. It needs to access a mysql 
database on the internet. It works fine when there is internet service.

I test access by downloading a file with a simple text code. If there code is 
returned in the message, I continue accessing the database. However, when there is 
no internet, the "put URL” command seems to hang forever. I’ve looked for a way 
to set the timeout for an internet command, but…. can’t,.

Could you direct me to a simple explanation about how to set a reasonable 
internet not connected message?


 not thoroughly tested 

You should, I think, be able to do this using tsNetSetTimeouts. But I wouldn't 
:-)

I'd do something like the following - I've tested some, but not all, failure 
cases, but haven't tested a successful url.



local sEventID

-- neverhappens.com is a website - returns "Forbidden"
-- nevehapens.com isn't, so almost immediately returns "can't be reached"
-- I didn't test a properly working case :-)

constant KURL = "http://neverhappens.com;

on mouseup
load url kURL with message "gotareply"
send "timetocheck failed" to me in 10 seconds -- or whatever timeout 
you want
put the result into sEventID
end mouseup

on gotareply pURL, pURLStatus
cancel sEventID
timetocheck pURLStatus
end gotareply

on timetocheck pWhat
local tAnswer
put "time to check" && pWhat  after msg
if pWhat = "loaded" then
   put URL kURL into tAnswer
   if tAnswer contains "mycode" then
  -- Internet is good
  put "Internet is good"  after msg
   end if
end if
-- Internet problematic
put "problem"  after msg
if pWhat = "error" then put libUrlErrorData(kURL)  after msg

unload URL KURL
end timetocheck


Alex.


___
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


___
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: Question re download timeout setting

2023-07-21 Thread Alex Tweedly via use-livecode


On 22/07/2023 01:02, prothero--- via use-livecode wrote:

Folks:
Sorry for the trivial question, but..
I have an app on my iphone that I am updating from a several years old app the 
previously worked on an older version of livecode. It needs to access a mysql 
database on the internet. It works fine when there is internet service.

I test access by downloading a file with a simple text code. If there code is 
returned in the message, I continue accessing the database. However, when there is 
no internet, the "put URL” command seems to hang forever. I’ve looked for a way 
to set the timeout for an internet command, but…. can’t,.

Could you direct me to a simple explanation about how to set a reasonable 
internet not connected message?


 not thoroughly tested 

You should, I think, be able to do this using tsNetSetTimeouts. But I 
wouldn't :-)


I'd do something like the following - I've tested some, but not all, 
failure cases, but haven't tested a successful url.




local sEventID

-- neverhappens.com is a website - returns "Forbidden"
-- nevehapens.com isn't, so almost immediately returns "can't be reached"
-- I didn't test a properly working case :-)

constant KURL = "http://neverhappens.com;

on mouseup
   load url kURL with message "gotareply"
   send "timetocheck failed" to me in 10 seconds -- or whatever 
timeout you want

   put the result into sEventID
end mouseup

on gotareply pURL, pURLStatus
   cancel sEventID
   timetocheck pURLStatus
end gotareply

on timetocheck pWhat
   local tAnswer
   put "time to check" && pWhat  after msg
   if pWhat = "loaded" then
  put URL kURL into tAnswer
  if tAnswer contains "mycode" then
 -- Internet is good
 put "Internet is good"  after msg
  end if
   end if
   -- Internet problematic
   put "problem"  after msg
   if pWhat = "error" then put libUrlErrorData(kURL)  after msg

   unload URL KURL
end timetocheck



Alex.


___
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: What is your best practice for setting a script in a script?

2023-07-15 Thread Alex Tweedly via use-livecode


On 15/07/2023 21:29, Paul Dupuis via use-livecode wrote:
All good suggestions so far, but not what I was after, which was 
whether there is any better way to have the script you are setting the 
newly created object to, readable, in the script that setup of the new 
object. If a behavior script is used or properties or objects then I 
can not read (and potentially revise) the script right in the script 
that is making the object. I have to open something else if I want to 
revise the script. Of course I can have a comment that says "look here 
for the script" and it is generally obvious from "set the script of 
button "Sample" to .



OK, how about this ?


on mouseUp
   -- using special comments to set script of another object
   local tmp
   put the script of me into tmp
   filter tmp with "*--1 *"
   replace "--1 " with empty in tmp
   set the script of btn "B" to tmp
   --1 on mouseup
   --1   put "hello world"
   --1 end mouseup
end mouseUp


of course, you could have multiple of them --1, --2, etc.

and you could have metadata, say the first line of each "special 
comment" has the object name


--1 -- script for button "abc"
--1 on mouseup
...
--1 end mouseup


Alex.


___
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: Convert date

2023-07-15 Thread Alex Tweedly via use-livecode


On 14/07/2023 19:45, Bob Sneidar via use-livecode wrote:

Because I’m not that good with regular expressions and the format function. :-) 
But you example has one too many close parens.


Oops - I got caught out copying / pasting again :-(

Yes, of course it should have been


put format("%s-%02d-%02d", item 1 of theDate, item 2 of theDate, \
 item 3 of theDate) into theDate



Also, for SQL Date I do not thing UK or US matters. It’s -MM-DD everywhere, 
isn’t it?

Yes, sql (or ISO) is same everywhere.


Also, I assumed that the localization of the LC engine would take into account 
the local date format for the built in date functions. Is that incorrect?


That is correct, but there is kind of a problem (or at least limitation) 
with the function.


If I have a user here (UK) type a date into a field, and then I try to 
format it to SQLdate (or anything else) using this function, it will 
fail. My user will type something  (15/07/2023), and that gets an 
"invalid date" error.


I'm not sure there is anything you can do that is completely safe - you 
can't tell whether a /-separated date string is US or UK. But I'd argue 
that dates ready to pass in to the function are either 
internally-generated (so they'll be sql, or dateitems, or otherwise 
unambiguous), or they are user-generated (and hence local format).  And 
therefore I would suggest changing the code to



   put item 2 of theDate & "/" & \
  item 3 of theDate & "/" & \
  item 1 of theDate into theDate
   convert theDate to dateitems
ELSE
   convert theDate from system date to dateitems
END IF

-- replace "." with "/" in theDate

-- convert theDate to dateitems


Alex.


___
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: Convert date

2023-07-15 Thread Alex Tweedly via use-livecode



On 14/07/2023 16:13, Bob Sneidar via use-livecode wrote:

I beg to differ. Again, Livecode is a way to build both the tools and the 
product made by those tools. Livecode is NOT a collection of every conceivable 
tool for everything everyone wants to do. No language is.

I think the LC dev team is far more useful to everyone if they focus on 
completing the projects they already have, and squashing the long standing and 
pervasive bugs that exist.

I think if there is a fairly easy way to create the tool you need with the 
codeset you now have, then you would need a compelling reason, like dramatic 
performance increases to justify building it into the engine.


I guess the primary argument is having it available "out of the box" for 
new users, or for those who are still unfamiliar / uncertain about LC 
scripting.



What I'd *really* like to see the LC dev team work on is bringing LCS 
libraries up to the same level of support as LCB libraries. It's taken a 
few years to finally get LCS widgets - and that was clearly HARD work. I 
would have thought t would be much easier - and just about as useful - 
to get CS libraries.


(and even to add some better support, such as "require library" that 
will properly deal with missing / duplicate attempts to load a library).


Alex.


___
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: Convert date

2023-07-14 Thread Alex Tweedly via use-livecode



On 14/07/2023 16:34, Bob Sneidar via use-livecode wrote:

   CASE "sql date"
  put item 1 of theDate & "-" & \
 format("%02d",item 2 of theDate) & "-" & \
 format("%02d",item 3 of theDate) into theDate
  break


Why not just

put format("%s-%02d-%02d", item 1 of theDate, item 2 of theDate), \
   item 3 of theDate) into theDate

Alex.

btw - you forgot the if/switch check for
"if in the USA" vs "if in the UK" :-) :-)


___
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: How to loop through stacks with same name?

2023-04-06 Thread Alex Tweedly via use-livecode

Jacque,

those two code snippets do slightly different things - and I don't think 
either of them is doing exactly what's intended; I think the intent is 
to delete stack(s) called (exactly) "test".


The first one will (wrongly) catch a stack called "testabc" or "abctest" 
- and then will fail on deleting 'test'.


The second one also catches "testabc" - but in this case deletes it 
unintentionally.


Alternatively, we could go straight to the point


put the milliseconds into tStart
repeat forever
  try
     delete stack "test"
  catch tmp
    exit repeat
  end
end repeat
answer the milliseconds - tStart

again, the timings are overlapping - the variation between different 
runs far outweighs the difference between the methods. I think that 
could be different if there many other mainstacks in play, but I don't 
see that it would be significant in any realistic case.


So pick the one that seems  most easily read and understood :-)

Alex.

On 05/04/2023 20:27, J. Landman Gay via use-livecode wrote:
I just created four same-named stacks and ran my suggested handler 
wrapped with timer commands. All four were deleted in 67 milliseconds. 
LC 10.0.0 DP 4.


put the milliseconds into tStart
repeat while "test" is in the mainstacks
   delete stack "test"
end repeat
answer the milliseconds - tStart

Ralph's idea to use filter is good too but slightly slower, at (a 
fairly insignificant) 79 milliseconds:


put the milliseconds into tStart
filter the mainstacks with "test*" into tStacks
repeat for each line l in tStacks
   delete stack l
end repeat
answer the milliseconds - tStart

On 4/5/23 10:15 AM, Bob Sneidar via use-livecode wrote:

Whoa! No I'm not! There's over 300 mainstacks just from Livecode!

Bob S


On Apr 5, 2023, at 08:07, Bob Sneidar via use-livecode 
 wrote:


Oooh Pro Tip #276 from Jacque. I'm gonna use that one.

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




___
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: Is it possible to use a reverse direction for offset

2023-03-23 Thread Alex Tweedly via use-livecode

Oh dear - replying to myself again :-)

The 'itemDel' method still does the long search through the text - even 
though it does it at engine speed, and in neat tidy looking script.


But, re-reading your earlier description, it occurred to me that (maybe) 
you are doing lots of different processing on the same bit of text. If 
that is the case, then it may be worth doing a single "reverse" 
operation at the start, and then doing everything as a 'forward' search.


i.e.

put the number of chars in tText into K
put reverse(tText) into tRevText

to find the enclosing strings from position 'm', we would do

put offset(tClosingSting, tText, m) into t2
put K - offset( reverse(tOpeningString), tRevText, K-m) into t1

 text you need is in char t1 to t2 of tText

Should give you quick searches  -  IF you repeatedly process the same text.

Alex.

P.S.  quickest 'reverse' function ?

Might be

put the number of chars in tText into K
put K into N
repeat for each char c in tText
   put c into tRev[N]
   subtract 1 from N
end repeat
combine tRev with empty

Alex.



On 23/03/2023 19:03, Alex Tweedly via use-livecode wrote:

OK, I may be going in the wrong direction here, but 

put (the opening string) into temp
set the itemDelimeter to temp
put the number of chars in item 1 to -2 of theWholeText into theAnswer

??

Alex.

On 23/03/2023 17:24, François via use-livecode wrote:

Yes, this is the big picture.

Plus, some environments may live within other environments.

And yes, one of the things the app does all the time is finding 
matched opening strings and closing strings, like finding matched 
parentheses in a programming language.


Fun, as you said!
François

Le 23 mars 2023 à 18:17, Craig Newman via use-livecode 
 a écrit :


Fun, fun…

So if you collect ALL the opening and closing strings, and hopefully 
these never overlap, then each pair can be “ordered”. Now 
identifying each is just a matter of thinking in terms of “pairs” of 
offsets. You can then identify each by their “paired” position in 
the forward direction.


Or am i missing it still?

Craig

On Mar 23, 2023, at 12:29 PM, François via use-livecode 
 wrote:


An example of when a backwards search would be useful is the 
following:


In the app, you have to find command environments. Environments are 
delimited by an opening string and a closing string.


Usually, I search forward for the opening string, then search for 
the closing string afterwards. Once this occurrence is processed, 
the app goes on with a forward search.


Now another problem: I want to see in which environment a text 
position is in, i.e. finding the enclosing opening and closing 
strings.


Looking for the closing string is a no brainer. Looking for the 
opening string is no more difficult if I can do a backwards search.


However, if I can only search forward, I must start the search at 
the beginning of the text to scan all the occurrences of the 
opening string that stand before the text position (if any). The 
complexity of this approach is not the same as in the case where a 
backwards search is available.


François

Le 23 mars 2023 à 16:48, Craig Newman via use-livecode 
 a écrit :


Francois.

I am sure you know what you have and what you need.

But just for my curiosity, if I had to do what you want, I would 
have used the “offset” function and its “charsToSkip” parameter to 
find all instances of the text to find, and then use those values 
in sequence to work backwards. But then how do you know when to stop?


Craig

On Mar 23, 2023, at 11:30 AM, François via use-livecode 
 wrote:


The text source is not very big.

However I implement transcoding from one language to another and 
I do an VERY large amount of search and replace.


I think I have quite optimized my LC code but transcoding can 
take 5 minutes to do, and I need the whole process to chase 
unexpected bugs. This is using the forward search (offset) most 
of the time.


Using a standalone app takes the time down to 4 minutes, which is 
not a sufficient gain for my usage.


François

Le 23 mars 2023 à 16:21, Craig Newman via use-livecode 
 a écrit :


Francois.

Who wouldn’t?

But unless you are working with VERY large datasets, I bet a 
handler would process quickly.


Craig

On Mar 23, 2023, at 10:58 AM, François via use-livecode 
 wrote:


@Ben

Too bad…

@ Craig

I would rather have an optimized version, I do a lot of text 
processing in my app.


Thanks to both of you!
François

Le 23 mars 2023 à 14:43, Craig Newman via use-livecode 
 a écrit :


@Ben.

20 years! Congratulations!.

@Francois

This can be scripted easily. Do you need help with that?

Craig

On Mar 23, 2023, at 8:21 AM, Ben Rubinstein via use-livecode 
 wrote:


https://quality.livecode.com/show_bug.cgi?id=584 (20th 
anniversary this September!)


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



On 23/03/2023 11:35, François via use-livecode wrote:
I would like to search for a string within another string,

Re: Is it possible to use a reverse direction for offset

2023-03-23 Thread Alex Tweedly via use-livecode

OK, I may be going in the wrong direction here, but 

put (the opening string) into temp
set the itemDelimeter to temp
put the number of chars in item 1 to -2 of theWholeText into theAnswer

??

Alex.

On 23/03/2023 17:24, François via use-livecode wrote:

Yes, this is the big picture.

Plus, some environments may live within other environments.

And yes, one of the things the app does all the time is finding matched opening 
strings and closing strings, like finding matched parentheses in a programming 
language.

Fun, as you said!
François


Le 23 mars 2023 à 18:17, Craig Newman via use-livecode 
 a écrit :

Fun, fun…

So if you collect ALL the opening and closing strings, and hopefully these 
never overlap, then each pair can be “ordered”. Now identifying each is just a 
matter of thinking in terms of “pairs” of offsets. You can then identify each 
by their “paired” position in the forward direction.

Or am i missing it still?

Craig


On Mar 23, 2023, at 12:29 PM, François via use-livecode 
 wrote:

An example of when a backwards search would be useful is the following:

In the app, you have to find command environments. Environments are delimited 
by an opening string and a closing string.

Usually, I search forward for the opening string, then search for the closing 
string afterwards. Once this occurrence is processed, the app goes on with a 
forward search.

Now another problem: I want to see in which environment a text position is in, 
i.e. finding the enclosing opening and closing strings.

Looking for the closing string is a no brainer. Looking for the opening string 
is no more difficult if I can do a backwards search.

However, if I can only search forward, I must start the search at the beginning 
of the text to scan all the occurrences of the opening string that stand before 
the text position (if any). The complexity of this approach is not the same as 
in the case where a backwards search is available.

François


Le 23 mars 2023 à 16:48, Craig Newman via use-livecode 
 a écrit :

Francois.

I am sure you know what you have and what you need.

But just for my curiosity, if I had to do what you want, I would have used the 
“offset” function and its “charsToSkip” parameter to find all instances of the 
text to find, and then use those values in sequence to work backwards. But then 
how do you know when to stop?

Craig


On Mar 23, 2023, at 11:30 AM, François via use-livecode 
 wrote:

The text source is not very big.

However I implement transcoding from one language to another and I do an VERY 
large amount of search and replace.

I think I have quite optimized my LC code but transcoding can take 5 minutes to 
do, and I need the whole process to chase unexpected bugs. This is using the 
forward search (offset) most of the time.

Using a standalone app takes the time down to 4 minutes, which is not a 
sufficient gain for my usage.

François


Le 23 mars 2023 à 16:21, Craig Newman via use-livecode 
 a écrit :

Francois.

Who wouldn’t?

But unless you are working with VERY large datasets, I bet a handler would 
process quickly.

Craig


On Mar 23, 2023, at 10:58 AM, François via use-livecode 
 wrote:

@Ben

Too bad…

@ Craig

I would rather have an optimized version, I do a lot of text processing in my 
app.

Thanks to both of you!
François


Le 23 mars 2023 à 14:43, Craig Newman via use-livecode 
 a écrit :

@Ben.

20 years! Congratulations!.

@Francois

This can be scripted easily. Do you need help with that?

Craig


On Mar 23, 2023, at 8:21 AM, Ben Rubinstein via use-livecode 
 wrote:

https://quality.livecode.com/show_bug.cgi?id=584 (20th anniversary this 
September!)

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



On 23/03/2023 11:35, François via use-livecode wrote:

I would like to search for a string within another string, starting at a given 
position, but backward.
In some languages, you can achieve that by providing a negative number for the 
initial position of the search.
Is this possible in LiveCode?
TIA
François
___
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


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

Re: Chat and textarea formatting

2023-02-16 Thread Alex Tweedly via use-livecode
Of course, the other option - depending on your timescale (and maybe 
your license) - would be to build it as a LC app, and then 'build for web'.


That way you'd have control over the formatting options you want to 
allow/provide.


Alex

P.S. but then, I'm strongly averse to any use of JS, HTML, etc. because 
I just don't like using them  and would go out of my way to do 
everything in LC if possible :-)  I am holding my breath for next DPs of 
LC for web.

Your mileage, and your dislike of non-LC languages, may vary.

On 15/02/2023 16:32, harrison--- via use-livecode wrote:

Hi Richard,

It takes care of the line spacing problem fine which is good!

It doesn’t like apostrophes in words, and returns garbage for that.

It doesn’t keep any bold facing or text coloring information.

Thanks for this suggestion.

Rick




On Feb 15, 2023, at 4:52 AM, Richard Gaskin via use-livecode 
 wrote:

You may find it easier to set the contenteditable property of a container 
element like div or p, and then you can retrieve the inner HTML of that element 
with:

  var tFldMainHTML = document.getElementById("fldMain").innerHTML

Save the example below to a text file and run in your browser. There's extra 
stuff there just for appearance, but the meat of it is that one line.

Once the page is loaded, copy some styled text and paste it into the field. 
When the button's clicked you'll see the full HTML tags in an alert dialog.

___
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: Chat and textarea formatting

2023-02-14 Thread Alex Tweedly via use-livecode

It's not really a LC question, it's an HTML thing :-)

textarea etc. only handle plain (unformatted) text.

Googling for suggestions I can only find two common answers:

1. horribly complicated ways to add Javascript to your script to handle 
formatting


2. "use TinyMCE"

I'd go for the second alternative. I did use it years ago, and it was (I 
think I remember) quite easy, but I haven't used it for a long, long time.


Alex.


On 14/02/2023 22:46, harrison--- via use-livecode wrote:

Hi Craig,

No.

I have an HTML5 

Here’s an example from W3Schools:





textarea {
   resize: none;
}




The textarea element - Disable default resize option

Review of W3Schools:


At w3schools.com you will learn how to make a website. They offer free 
tutorials in all web development technologies.





It creates a text box that a user can enter text into for input purposes.
The text box will not however retain any formatting that one
might like to apply such as bold text or even simple carriage returns.
It all ends up being one big block of text such as this one.

The data has to go into my database so I can retrieve it for someone
else at a later time.  When I retrieve the text, it needs to retain whatever
rich text that the original user entered.

I want to know how people are handling this either with or without
the use of .

I hope that clears up any confusion.

Thanks for getting back to me!

Rick


On Feb 14, 2023, at 5:16 PM, Craig Newman via use-livecode 
 wrote:

Hi.

Not sure I understand.

You have an editable field that you cannot type into? Do you get a blinking 
cursor in that field if you click inside it?

Perhaps some properties for that field are such that LC is preventing access?

Craig

___
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: Html mix with livecode server

2023-02-11 Thread Alex Tweedly via use-livecode
Short answer  you can use single quotes and double quotes 
interchangeably in HTML (so long as consistently).


So you can do




Second answer: Or, you could mix html + lc, and do




Third answer: Or, for anything more complex like a full website, you 
might want to look at Ralf Bitter's excellent revigniter.com


Alex.


On 11/02/2023 18:05, Paul Richards via use-livecode wrote:

Hi everyone,

I've been using Livecode for a number of years, and have had no issues 
whatsoever - but recently thought I would give Livecode server a go.

Using another webserver, I can do something like this where you can output true 
HTML. This example would check if username/password correct and display an 
error if not .

$
If  lError = true then
Weboutput $

 
 sErrText

$
Endif
Weboutput  $

Trying to replicate this in Livecode server isn't proving as "simple"

I can see we need to use the put command, so tried the following:



but this simple line results in an error "

row 84, col 31: put: preposition must be 'before', 'into' or 'after' (alert)
   row 84, col 31: if: error in command (alert)
   row 84, col 31: script: bad statement (alert)
"
Is there a way of outputting this line in HTML using the put command and without having to manipulate the 
line in true livecode script ie: put "mailto:p...@smarttsoftware.co.uk>
https://smarttsoftware.uk
https://equinox7.com
Sales: tel:+44(0)442524
sa...@smarttsoftware.co.uk

PRIVACY AND CONFIDENTIALITY NOTICE

This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed.
It may contain information which is covered by legal, professional or other 
privilege. If you are not the intended addressee, you must not disclose, copy, or 
take any action in respect of this transmission, but please notify our system manager 
by emailing supp...@smarttsoftware.co.uk and 
then destroy this message.
The Internet cannot guarantee the integrity of this message or any attachments. 
Smartt Software takes all reasonable precautions to ensure that no viruses are 
transmitted with any electronic communications sent by us, however we can 
accept no responsibility for any loss or damage resulting directly or 
indirectly from the use of this E-mail or any contents or attachments.
Smartt Software Ltd is a company incorporated in England & Wales Registration 
No. 02478683 and whose Registered Office is at 64 Fleet Road, Farnborough, GU14 9RA.

___
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: [[ ANN ]] New Enhancements Bundle v1.0.29 available

2023-02-10 Thread Alex Tweedly via use-livecode

Hi Panos,

I just installed the new Megabundle.

When I opened up 'magic palette', I got an error dialog


There was an error executing a script in
stack magic palette. No more information
is available because the stack is password
protected.


Any suggestions how I can get you a helpful error report ?

Thanks

Alex.

P.S. I haven't used 'magic palette' for a long time, so I don't know if 
this is a new problem or not



On 2/9/2023 9:24 AM, panagiotis merakos via use-livecode wrote:


Hello all,

Just to let you know that there is an update of the enhancements bundle
available in your account area.

Latest update 1.0.29: 9 February 2023

This update includes several bugfixes. I'll update BugZilla later
tonight.

Kind regards,






I just downloaded and installed the new widgets in LC9.6.9rc2 and
tried the Polylist. I don't seem to be able to add any columns via the
Property Inspector. RECIPE on Windows 10: Launch LC9.6.9rc2, create a
new stack, add a Polylist, bring up the Property Inspector for the new
Polylist, click on the columns tab, click on the Plus icon to add a
column. Enter a name for the column (i.e. Test, or Name, or Col1) and
click ok. Result: No column added.

Anyone else see this?


If I add at least 1 data element via the Text (or Array) entry tab, then
I can see and add additional columns under the column tab of the
Property Inspector. It appears the problem is if I am trying to used the
Columns tab of the PI to add the first column to an empty Poliylist.


___
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


___
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: ChatGPT examples

2023-01-20 Thread Alex Tweedly via use-livecode


On 20/01/2023 18:26, Geoff Canyon via use-livecode wrote:

I'm sure someone has done the work to create a more efficient algorithm for
this. Off the top of my head if I were trying to  I'd probably do something
like:


Hmmm. Maybe. But I kind of doubt it (though I'd love to find out I'm wrong).

This (or closely related problems) got a lot of attention on the 
mid70s-mid80s, when we were trying to do Design Rule Verification for 
VLSI circuits, with millions of transistors. Where the rules could 
exploit hierarchy, the "clever tree" data structures and algorithms did 
well (See Quad-CIF etc.) But for non-hierarchical problems (such as this 
'closest points' case), nothing came close to this 'scanning window' or 
'linear scan' approach.


But looking more closely, I realized that the number of times a new 
"closest pair" was found is remarkably small - typically between 6 & 10 
times for 50,000 points. So it's very feasible to bear the cost of 
calculating the actual distance (i.e. doing the sqrt call) each time a 
new 'closest pair' is found, and that means the quick filtering test can 
be done on the x-distance (rather than x*x). Also, you can do a similar 
filter test on the Y coord (though it doesn't let you exit the inner 
loop, only allows you to skip the full comparison).


Adding those changes in gets the time down by another 10% or so - so the 
original 2000 points comes down from approx 35ms to around 28ms (almost 
too small to measure reliably). More reasonably, 50,000 points comes 
down from 880ms to 810ms.


Revised code:
function closestPointsSQ pLines
   sort pLines numeric by item 1 of each
   put pLines into pPoints
   split pPoints by CR
   put infinity into minDistSQ
   put infinity into minDist
   put the number of elements in pPoints into N
   repeat with i = 1 to N-1
  repeat with j = i + 1 to N
 put item 1 of pPoints[j] - item 1 of pPoints[i] into t1
 if t1 > minDist then exit repeat
 put item 2 of pPoints[j] - item 2 of pPoints[i] into t2
 if t2 > minDist OR t2 < -minDist then next repeat
 -- add 1 to compareCount
 put t1 * t1 + t2 * t2 into dist
 if dist < minDistSQ then
    put dist into minDistSQ
    put sqrt(dist) into minDist
    put pPoints[i] & " " & pPoints[j] into closestPoints
    --    add 1 to newClosest
 else if dist = minDistSQ then
    put sqrt(dist) into minDist
    put return & pPoints[i] & " " & pPoints[j] after closestPoints
    --    add 1 to tAlsoClosest
 end if
  end repeat
   end repeat
   --   put "SQ compared" && compareCount && newClosest && tAlsoClosest 
 after msg

   return closestPoints
end closestPointsSQ

Alex.


1. Grab two points at random (in case the points are pre-sorted in some
way) and get the distance.
2. Assume that's a reasonable average distance between points.
3. Define that as the number to beat, and define a grid based on it.
4. Go through all the points, tossing them into buckets based on the grid.
I'd define the buckets as fully overlapping to avoid missing close pairs.
5. The size of the grid buckets is critical: too big and you do too much
work. Too small and you end up with all singletons in the buckets. This
would require some experimentation and thought.
6. Go through the buckets only comparing the points within them.

On Fri, Jan 20, 2023 at 10:14 AM Alex Tweedly via use-livecode <
use-livecode@lists.runrev.com> wrote:


On 20/01/2023 16:52, Mark Waddingham via use-livecode wrote:

On 2023-01-20 13:05, Alex Tweedly via use-livecode wrote:

We need a better algorithm. If we use a "linear scan", we can change
it from essentially Order(N**2) to approx Order(N).

Slightly pedantic point (I appreciate that you did say 'approx')...

Sorting can not be done in any less time than O(N*log N) - so the
revised algorithm is O(N*log N) as you have to sort the input for it
to be able to scan linearly.


I figured someone would pick me up on that :-) It was a pretty big
'approx' :\)

The sorting step is indeed O(NlogN).

And the rest of it also worse than linear, but I don't have the math
knowledge to even begin to think about how much worse. Quick testing
says it's worse than O(NlogN), and in practice, it might even be as bad
as something like O(N * sqrt(N)), guessing about the number of points
within a (variable) sized window to the right of the current scan coord.

But in any "real app" usage that I can imagine, the 'clustering' effect
would seem to improve it over O(N*sqrt(N)); e.g. if the points tend to
cluster rather than be evenly randomly spread, then the number within
the scan window goes down on average. "real app" could be players in a
1st person player game, or vehicles on a road simulation, or (in 3d)
stars in the universe - i

Re: ChatGPT examples

2023-01-20 Thread Alex Tweedly via use-livecode
Duh. What part of Sod's Law says that you always see a bug the first 
time you look at your own code *after* you've made the code public :-(


The 'sort' command below needs to be a numeric sort 

sort pLines by item 1 of each   ->   sort pLines numeric by item 1 
of each


Sorry,

Alex.

On 20/01/2023 13:05, Alex Tweedly via use-livecode wrote:

Fascinating. Thank you so much for that Geoff.

I've been afraid to play with ChatGPT so far - too worried abut 
getting sucked in and spending way too much time 


I did take a look at your third example (since I can never resist a 
performance challenge :-)


There are a number of minor tweaks that could be made to improve 
performance


1. set initial value to infinity rather than calculating a distance 
between the first two points.


2. "number of elements in pPoints" is unvarying within any one call - 
so extract it to a variable at the start


3. use the square of the distance rather than the actual distance - 
save N**2 calls to sqrt


4. use "DX * DX" rather than "DX ^ 2" (about 25% faster)

5. calculate distance in-line rather than call a function

but those all add up to maybe 10% performance improvement (or less - I 
didn't test it). That's useful - but not enough.


For a modest number of points (2000 random points), this takes approx 
16.5 seconds !!


We need a better algorithm. If we use a "linear scan", we can change 
it from essentially Order(N**2) to approx Order(N).


Summary:

 - sort the points by X coordinate

 - while scanning the inner loop, as soon as the difference in Xcoord 
from the 'outer' point exceeds the minDist so far, you can reject not 
just this point, but all subsequent points, and hence exit the inner 
loop immediately.


This brings the time down from 16500 millisecs to 25 millisecs.

BUT - I have no clue how I'd go about describing this to ChatGPT :-)

NB I changed the input parameter to be the list of points rather than 
the array.


Code:

function closestPointsSQ pLines
   sort pLines by item 1 of each
   put pLines into pPoints
   split pPoints by CR
   put infinity into minDist
   put the number of elements in pPoints into N
   repeat with i = 1 to N-1
  repeat with j = i + 1 to N
 put item 1 of pPoints[j] - item 1 of pPoints[i] into t1
 if t1 * t1 > minDist then exit repeat
 put item 2 of pPoints[j] - item 2 of pPoints[i] into t2
 put t1 * t1 + t2 * t2 into dist
 if dist < minDist then
    put dist into minDist
    put pPoints[i] & " " & pPoints[j] into closestPoints
 else if dist = minDist then
    put return & pPoints[i] & " " & pPoints[j] after 
closestPoints

 end if
  end repeat
   end repeat
   return closestPoints
end closestPointsSQ

-- Alex.

On 20/01/2023 06:02, Geoff Canyon via use-livecode wrote:

I tested three use cases, with variations, using ChatGPT for (live)code
generation. There was a lot of back and forth. In the end, I solved 
all the

problems I set, but in some cases I had to hold ChatGPT's hand pretty
tightly.

That said, I learned some things as well -- about LiveCode. ChatGPT's 
code

for Fizz Buzz was faster than mine.

My code was faster for reversing lines. But ChatGPT, when asked to "make
the code faster" gave several suggestions, some of which were wrong or
impossible, but one of them was my method, and when I said "write that
option" it did, with only a few corrections needed.

And one of the ideas, while wrong, caused me to think of a different 
way to

solve the problem, and that way ended up being faster than my original
solution by over 3x on reversing 10k lines. Getting ChatGPT to write 
this

new method was *hard*.

In any case, I wrote it all down in a google doc
<https://docs.google.com/document/d/1W3j5WaFhYZaqSt0ceRQj8j160945gSwG_nyZsCBP6v4/edit?usp=sharing>. 


If you're curious, have a read. That URL is open for comments/edit
suggestions. If you have any I'd love to hear them.

Thanks!

Geoff
___
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


___
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: ChatGPT examples

2023-01-20 Thread Alex Tweedly via use-livecode



On 20/01/2023 16:52, Mark Waddingham via use-livecode wrote:

On 2023-01-20 13:05, Alex Tweedly via use-livecode wrote:

We need a better algorithm. If we use a "linear scan", we can change
it from essentially Order(N**2) to approx Order(N).


Slightly pedantic point (I appreciate that you did say 'approx')...

Sorting can not be done in any less time than O(N*log N) - so the 
revised algorithm is O(N*log N) as you have to sort the input for it 
to be able to scan linearly.


I figured someone would pick me up on that :-) It was a pretty big 
'approx' :\)


The sorting step is indeed O(NlogN).

And the rest of it also worse than linear, but I don't have the math 
knowledge to even begin to think about how much worse. Quick testing 
says it's worse than O(NlogN), and in practice, it might even be as bad 
as something like O(N * sqrt(N)), guessing about the number of points 
within a (variable) sized window to the right of the current scan coord.


But in any "real app" usage that I can imagine, the 'clustering' effect 
would seem to improve it over O(N*sqrt(N)); e.g. if the points tend to 
cluster rather than be evenly randomly spread, then the number within 
the scan window goes down on average. "real app" could be players in a 
1st person player game, or vehicles on a road simulation, or (in 3d) 
stars in the universe - in all cases causing the minDist to decrease 
faster than when they are evenly spread.


Alex.



___
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: ChatGPT examples

2023-01-20 Thread Alex Tweedly via use-livecode

On 20/01/2023 15:55, Geoff Canyon via use-livecode wrote:


Responses inline:

On Fri, Jan 20, 2023 at 5:06 AM Alex Tweedly via use-livecode <
use-livecode@lists.runrev.com> wrote:

I thought of this -- especially since ChatGPT's first (python-esque)
example uses "inf" -- but what would you use as "infinity" in LiveCode? In
practice if I were coding and comfortable with it I'd probably just throw
in 9 and be done, but in the abstract, there are bigger numbers
allowed in LC, and I don't care to find the absolute largest -- plus it
would be some weird long string -- I think, I don't know off the top of my
head what the largest 64-bit value is.


Just use the constant 'infinity'

I think it was added fairly recently, but the dictionary doesn't say 
what version it first appeared in.


Alex.


___
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: ChatGPT examples

2023-01-20 Thread Alex Tweedly via use-livecode

Fascinating. Thank you so much for that Geoff.

I've been afraid to play with ChatGPT so far - too worried abut getting 
sucked in and spending way too much time 


I did take a look at your third example (since I can never resist a 
performance challenge :-)


There are a number of minor tweaks that could be made to improve performance

1. set initial value to infinity rather than calculating a distance 
between the first two points.


2. "number of elements in pPoints" is unvarying within any one call - so 
extract it to a variable at the start


3. use the square of the distance rather than the actual distance - save 
N**2 calls to sqrt


4. use "DX * DX" rather than "DX ^ 2" (about 25% faster)

5. calculate distance in-line rather than call a function

but those all add up to maybe 10% performance improvement (or less - I 
didn't test it). That's useful - but not enough.


For a modest number of points (2000 random points), this takes approx 
16.5 seconds !!


We need a better algorithm. If we use a "linear scan", we can change it 
from essentially Order(N**2) to approx Order(N).


Summary:

 - sort the points by X coordinate

 - while scanning the inner loop, as soon as the difference in Xcoord 
from the 'outer' point exceeds the minDist so far, you can reject not 
just this point, but all subsequent points, and hence exit the inner 
loop immediately.


This brings the time down from 16500 millisecs to 25 millisecs.

BUT - I have no clue how I'd go about describing this to ChatGPT :-)

NB I changed the input parameter to be the list of points rather than 
the array.


Code:

function closestPointsSQ pLines
   sort pLines by item 1 of each
   put pLines into pPoints
   split pPoints by CR
   put infinity into minDist
   put the number of elements in pPoints into N
   repeat with i = 1 to N-1
  repeat with j = i + 1 to N
 put item 1 of pPoints[j] - item 1 of pPoints[i] into t1
 if t1 * t1 > minDist then exit repeat
 put item 2 of pPoints[j] - item 2 of pPoints[i] into t2
 put t1 * t1 + t2 * t2 into dist
 if dist < minDist then
    put dist into minDist
    put pPoints[i] & " " & pPoints[j] into closestPoints
 else if dist = minDist then
    put return & pPoints[i] & " " & pPoints[j] after closestPoints
 end if
  end repeat
   end repeat
   return closestPoints
end closestPointsSQ

-- Alex.

On 20/01/2023 06:02, Geoff Canyon via use-livecode wrote:

I tested three use cases, with variations, using ChatGPT for (live)code
generation. There was a lot of back and forth. In the end, I solved all the
problems I set, but in some cases I had to hold ChatGPT's hand pretty
tightly.

That said, I learned some things as well -- about LiveCode. ChatGPT's code
for Fizz Buzz was faster than mine.

My code was faster for reversing lines. But ChatGPT, when asked to "make
the code faster" gave several suggestions, some of which were wrong or
impossible, but one of them was my method, and when I said "write that
option" it did, with only a few corrections needed.

And one of the ideas, while wrong, caused me to think of a different way to
solve the problem, and that way ended up being faster than my original
solution by over 3x on reversing 10k lines. Getting ChatGPT to write this
new method was *hard*.

In any case, I wrote it all down in a google doc
.
If you're curious, have a read. That URL is open for comments/edit
suggestions. If you have any I'd love to hear them.

Thanks!

Geoff
___
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: Move in Reverse

2023-01-17 Thread Alex Tweedly via use-livecode
He's moving the graphic object "to" the points of a polygon - i.e. to 
each in turn.


So the movement would be reversed.

On 17/01/2023 23:23, Mark Wieder via use-livecode wrote:

On 1/17/23 12:06, Roger Guay via use-livecode wrote:

Hi all,

is there a simple way to move a grc to the points of a polygon in 
reverse? Or, does one have to manipulate the points list to its inverse?


But... why? Don't you end up with the same polygon?



___
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: Field content as parametres in a function

2022-11-29 Thread Alex Tweedly via use-livecode
Yes, your description is correct (except for saying the behavior is 
"puzzling" :-)


The first case you are passing a single parameter (which happens to have 
commas in its current content). You could have said "  paramcount() 
returns 1 as expected".


The second case you pass 5 values.

And the third case, as you say, expands the value first, so it becomes a 
call with 5 parameters.


Alex.

On 29/11/2022 08:03, Tore Nilsen via use-livecode wrote:

I have come across a puzzling behavior when trying to use the content of a 
field as parametres in a function, and I am trying to understand why.

I put the following in a field called «test»: 1,2,3,4,5

When I then call the function like this:
answer testFunction(field «test»), the paramCount() returns 1

If I use the values directly in the script:
answer testFunction(1,2,3,4,5), the paramCount() returns 5 as 
expected

I will also get the expected result if a do the following:

put "answer testFunction(" & field «test»  & ")" into tScript
do tScript

I guess the reason for this is that in the last example, LiveCode compiles the 
content of the variable tScript before execution, and that this turns what is 
first treated as a single block of text into a list of parametres.

The reason why I want to understand what is happening is that I am about to 
teach my students how to write reusable code that will behave correctly for any 
number of parametres.

So my question is if I am on the right track?

Best regards
Tore Nilsen
___
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: IP address and Country

2022-11-15 Thread Alex Tweedly via use-livecode

Hi Rick,

I had missed the fact that you said you already had the database - that 
makes it a much easier problem :-)


While I don't have any Livecode code for this, I do have some C code for 
a (probably) very similar problem.


If you can describe the format of your database, and the query you want 
to make, I'll see if what I have is a good starting place, and then 
convert the C code if practical.


Thanks,

Alex.

On 15/11/2022 17:12, harrison--- via use-livecode wrote:

Hi Martin,

Thanks for the information, but what I really want is a LiveCode solution
that doesn’t depend on third parties.

I have the database. I was asking if other people here
had come up with a fast LiveCode solution.

If all else fails, I will look into one of the third party suggestions,
but third parties can change their code or suddenly disappear
off of the internet.  I don’t want my website breaking all the time
due to such dependencies.

Thanks again,

Rick



On Nov 14, 2022, at 11:22 PM, Martin Koob  wrote:

You can use a website with a api that you send a HTTP request with an IP 
address parameter to and which returns the country info.

Here is an example I found of one site.

https://ipapi.co/api/#introduction 

HTTP Request

GET https://ipapi.co/{ip}/{format}/

URL Parameters

Parameter   Description
ip  An IP address for which you want to retrieve the 
location
format  Data format of response, possible values are json, jsonp, xml, 
csv, yaml

E.g.

https://ipapi.co/8.8.8.8/json/

It is free for up to 30K requests per month,  after that there is a fee.

https://ipapi.co/#pricing 

Martin Koob

___
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: itemoffset & wholematches

2022-11-15 Thread Alex Tweedly via use-livecode

Hi,

I don't know if this will be faster, slower, or what !?! Something like 

  put myVar into tCopy
  replace CR with TAB in tCopy

  put itemoffset("incertain", tCopy) into tmp
  put the number of chars in item 1 to (tmp-1) of tCopy into tCharCount
  put the number of items in char 1 to tCharCount of myVar into 
theRealAnswer



Or, depending on what you do next, just go on using charOffset rather 
than itemOffset for the following code.



Alex.

On 15/11/2022 09:33, jbv via use-livecode wrote:

Hi guys,
Thank you all for your answers.

Actually I thought that some "hierarchy"remained (items inside lines)
when using itemoffset, but obviously I was wrong.
I have about 6 variables to check, so I need my script to be as
fast as possible. I use "replace CR with TAB & CR & TAB in ...", but
as I need to get the exact itemoffset digit, I also need to count
how many items I have added and substract that number from the
result, which is quite cumbersome and slow...

To Jacqueline :
Thanks fro the suggestion, but I have to stick with items and
itemoffset, for some items can contain more that 1 word, like
"pied de biche"...

Le 2022-11-14 14:45, Alex Tweedly via use-livecode a écrit :

That would deal with the last item in a line - but not the first.

Should do

   replace CR with TAB & CR & TAB in ...

and reverse later if needed.

Alex.

On 14/11/2022 18:43, Bob Sneidar via use-livecode wrote:
oic. Odd use case. I suppose a lineOffset function followed by is 
among the items could be used. If he needs the lines to remain 
intact he could also replace cr with tab & cr first.





___
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: itemoffset & wholematches

2022-11-14 Thread Alex Tweedly via use-livecode

That would deal with the last item in a line - but not the first.

Should do

   replace CR with TAB & CR & TAB in ...

and reverse later if needed.

Alex.

On 14/11/2022 18:43, Bob Sneidar via use-livecode wrote:

oic. Odd use case. I suppose a lineOffset function followed by is among the items 
could be used. If he needs the lines to remain intact he could also replace cr with 
tab & cr first.

Bob S


On Nov 14, 2022, at 10:15 , Mike Kerner via use-livecode 
mailto:use-livecode@lists.runrev.com>> wrote:

that still won't work if the text is the last item of a line.

___
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: clearing a polygrid/polylist

2022-10-12 Thread Alex Tweedly via use-livecode

For polygrid

   set the pgdata of widget 1 to empty

For polylist

  set the datacontent of widget 2 to empty

BUT beware - on my trivial test, this appears to cause the last 
character of the header to be removed !!


I'll investigate some more and bug report it if it seems consistent.

Alex


On 12/10/2022 15:49, Mike Kerner via use-livecode wrote:

How do you clear a polylist/polygrid?
set the tsvdata of widget 1 to empty # throws an error



___
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: Quick and simple web demos?

2022-09-30 Thread Alex Tweedly via use-livecode

Short answers:

1. Yes

2. Yes, but probably not.

3. Yes.

Long answers.

1. Yes, absolutely, it's ideal for quick, easy-to-distribute apps or 
demo samples.


2. Yes, you'll need somewhere to store/give access to the files. But it 
probably won't be Google Drive - you want the files of the app to each 
be accessible via https: (and there are assumptions about their relative 
position in the default build version - may be possible to over-ride 
them and use Google Drive, but I suspect lots more work. Easiest is to 
just have a web server and put the bundle created by  build-for-web up 
there.


3. Yes.

4. There are a few samples, etc.

https://lessons.livecode.com/m/4071/l/1496056-how-do-i-put-my-first-app-on-the-web-lc-10-and-later

Note this uses the default-built HTML file, which is pretty unappealing. 
The discussion on the comments says something about replacing it, or 
there have been other examples on the uselist and (more) on the forums 
about this. In one of the LC Global conferences fairly recently, Steve 
Crighton and Michael Macreary did a web app, with custom html/LCS to 
interact to handle resizing etc. Sorry - don't know which one it was, 
and the poor indexing/naming makes it tedious to try to find. It's all a 
bit complex and barely documented for now, but will improve before 
actual release.


Alex.


On 30/09/2022 20:12, Geoff Canyon via use-livecode wrote:

Back in the day, I would create quick and simple demos of something I was
building as a concept, create standalones, and send them to the people I
wanted to demonstrate to. As an example of an example, suppose I wanted to
build a simple Eliza-like chatbot. I could throw a field on a card, put a
"start chat" button on it, and build logic in the field or the card to get
the job done. A few message handlers for EnterInField and ReturnInField
would get the job done.

These days there are at least two flaws with that approach:

1. Often the people I want to demo to are using work computers that are
locked down from random app installs.
2. Sometimes I want to build a demo the world at large can see, and clearly
installing an app from some random person is not the way to do that anymore.

SO: is it accurate to say:

1. The above is possible
2. I'd need a web-accessible place to store the files -- would google drive
be sufficient?
3. I'd need to add an HTML5 license to my account

Any best references for steps to follow?

Thanks,

Geoff
___
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: Charts widget.

2022-09-26 Thread Alex Tweedly via use-livecode

Yes, first appeared in 10..0DP2

https://livecode.com/livecode-10-dp-2-charts-guidelines-web-browser-widget-and-more/

Alex.

On 26/09/2022 22:26, Paul Dupuis via use-livecode wrote:
Yes, I see it in LC10.0.0dp4. It must be a new widget for LC10, 
possibly only working in LC10 and not earlier versions?


Thank you for directing me to 10.


On 9/26/2022 5:11 PM, Mike Kerner via use-livecode wrote:

well, i learned something new.
i don't even see that widget in 9, but i do in 10.

On Mon, Sep 26, 2022 at 4:54 PM Alex Tweedly via use-livecode <
use-livecode@lists.runrev.com> wrote:


No, I mean the chart widget (chart - not charts, my mistake).

The graph (or linegraph) widget - com.livecode.widget.linegraph - does
simple line graphs only.

The chart widget - com.livecode.widget.chart - can do everything you
ever imagined a chart could do, and more. (*)


The Chart widget is a wrapper forChart.js v3.7.0
<https://www.chartjs.org>in LiveCode. It allows you to create
beautiful and highly customizable charts, in a simple way. Data can be
displayed as a line graph, bar chart, radar chart, donut/pie chart,
polar chart, bubble chart or scatter plot.

It really is wonderful - all kinds of charts, very fast, animations,
etc. The only drawback I've found so far is that doing time sequence or
date sequence charts needs some extra magic, and I don't know how to
find that magic.

Thanks for the suggestion of reading the .lcb; I probably couldn't have
made sense of it anyway - but there is no .lcb file for the chart 
widget.


It's just my bad luck that all the charts I want to do are the kind 
that

is beyond me :-)

Alex.

(*) not quite true, I don't think it can do the complex time + bubble
animations that Hans Rosling uses to such amazing effect -

https://singularityhub.com/2010/12/09/hans-rosling-shows-you-200-years-of-global-growth-in-4-minutes-video/ 



On 25/09/2022 23:21, Mike Kerner via use-livecode wrote:

do you mean the graph widget?
if that's what you mean, then...
sorry this isn't more helpful, but to get you started, the 
graph.lcb file
is in Tools/Extensions/com.livecode.widget.linegraph, if you want 
to try

reading through it.
it's only 1300 lines, total, including the docs. there is not that 
much

going on.
there are no private properties that i can see.

On Sun, Sep 25, 2022 at 4:55 PM Alex Tweedly via use-livecode <
use-livecode@lists.runrev.com> wrote:


Anyone using this widget ?

Is there some documentation (other than the obvious dictionary 
entries)

about how to do different kinds of chart ?

In the last 4-6 months, I've done 3 or 4 little personal projects 
where
I wanted to create a chart, but I've not been able to figure out 
how to

use the charts widget to do time-based charts.

What I mean is, e.g., create a chart for the following data 

2022-02-01    100
2022-02-04    500
2022-02-05    525
2022-02-17    900


Obviously, the dates along the X-axis should be spaced properly
according to their data value, not equally spaced and simply 
labelled.


Looking at the charts.js documentation, it tells me (or rather, 
fails to
tell me, since I can't understand it) that I need to define an 
'adapter'
and shows some sample javascript. I don't really understand how to 
do it

simply in javascript - far less how I could use that in the widget.

Can anyone give me a clue or a pointer ?

Many thanks,

Alex.

P.S. currently I solved it using my own GraphMaker library (see LC
conference from 2018) - but I'd really like to retire that library in
favour of the new widget.



___
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






___
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: Charts widget.

2022-09-26 Thread Alex Tweedly via use-livecode

No, I mean the chart widget (chart - not charts, my mistake).

The graph (or linegraph) widget - com.livecode.widget.linegraph - does 
simple line graphs only.


The chart widget - com.livecode.widget.chart - can do everything you 
ever imagined a chart could do, and more. (*)


The Chart widget is a wrapper forChart.js v3.7.0 
<https://www.chartjs.org>in LiveCode. It allows you to create 
beautiful and highly customizable charts, in a simple way. Data can be 
displayed as a line graph, bar chart, radar chart, donut/pie chart, 
polar chart, bubble chart or scatter plot.
It really is wonderful - all kinds of charts, very fast, animations, 
etc. The only drawback I've found so far is that doing time sequence or 
date sequence charts needs some extra magic, and I don't know how to 
find that magic.


Thanks for the suggestion of reading the .lcb; I probably couldn't have 
made sense of it anyway - but there is no .lcb file for the chart widget.


It's just my bad luck that all the charts I want to do are the kind that 
is beyond me :-)


Alex.

(*) not quite true, I don't think it can do the complex time + bubble 
animations that Hans Rosling uses to such amazing effect - 
https://singularityhub.com/2010/12/09/hans-rosling-shows-you-200-years-of-global-growth-in-4-minutes-video/


On 25/09/2022 23:21, Mike Kerner via use-livecode wrote:

do you mean the graph widget?
if that's what you mean, then...
sorry this isn't more helpful, but to get you started, the graph.lcb file
is in Tools/Extensions/com.livecode.widget.linegraph, if you want to try
reading through it.
it's only 1300 lines, total, including the docs. there is not that much
going on.
there are no private properties that i can see.

On Sun, Sep 25, 2022 at 4:55 PM Alex Tweedly via use-livecode <
use-livecode@lists.runrev.com> wrote:


Anyone using this widget ?

Is there some documentation (other than the obvious dictionary entries)
about how to do different kinds of chart ?

In the last 4-6 months, I've done 3 or 4 little personal projects where
I wanted to create a chart, but I've not been able to figure out how to
use the charts widget to do time-based charts.

What I mean is, e.g., create a chart for the following data 

2022-02-01100
2022-02-04500
2022-02-05525
2022-02-17900


Obviously, the dates along the X-axis should be spaced properly
according to their data value, not equally spaced and simply labelled.

Looking at the charts.js documentation, it tells me (or rather, fails to
tell me, since I can't understand it) that I need to define an 'adapter'
and shows some sample javascript. I don't really understand how to do it
simply in javascript - far less how I could use that in the widget.

Can anyone give me a clue or a pointer ?

Many thanks,

Alex.

P.S. currently I solved it using my own GraphMaker library (see LC
conference from 2018) - but I'd really like to retire that library in
favour of the new widget.



___
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


Charts widget.

2022-09-25 Thread Alex Tweedly via use-livecode

Anyone using this widget ?

Is there some documentation (other than the obvious dictionary entries) 
about how to do different kinds of chart ?


In the last 4-6 months, I've done 3 or 4 little personal projects where 
I wanted to create a chart, but I've not been able to figure out how to 
use the charts widget to do time-based charts.


What I mean is, e.g., create a chart for the following data 

2022-02-01    100
2022-02-04    500
2022-02-05    525
2022-02-17    900


Obviously, the dates along the X-axis should be spaced properly 
according to their data value, not equally spaced and simply labelled.


Looking at the charts.js documentation, it tells me (or rather, fails to 
tell me, since I can't understand it) that I need to define an 'adapter' 
and shows some sample javascript. I don't really understand how to do it 
simply in javascript - far less how I could use that in the widget.


Can anyone give me a clue or a pointer ?

Many thanks,

Alex.

P.S. currently I solved it using my own GraphMaker library (see LC 
conference from 2018) - but I'd really like to retire that library in 
favour of the new widget.




___
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: NAVRAD was: lcb missing manual

2022-09-17 Thread Alex Tweedly via use-livecode



On 17/09/2022 08:54, Jacques Clavel via use-livecode wrote:

point 6. maybe potential for future performance gains :
- But today LCB is surprisingly less efficient (/3) than LCS (???)

Yes, at first glance it is surprising; typed variables etc. *should* 
make it possible to be more efficient. And I think some day they will.


But for now, I think that isn't, and shouldn't be, a priority for LC Ltd.

The intended uses for LCB are to interface to other libraries/languages, 
and to provide graphic / UI widgets - and performance is not critical to 
either of those roles. If I have a LC app which is suffering 
performance, I should first look at the algorithm, the data structures, 
engine features I might be able to use, , separate process, ...


And if none of them fix it for me, then I'm probably going to want a 
high-performance library in some other language (C, C++, even NumPY, 
whatever) which allows it to be highly optimized.


My new slogan :

If I'm suffering for performance, I don't want a 10% improvement from 
LCB, I want a 10x improvement from C.


Alex.


___
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: NAVRAD was: lcb missing manual

2022-09-16 Thread Alex Tweedly via use-livecode



On 15/09/2022 16:37, Ralph DiMola via use-livecode wrote:

Docs aside... I still think that widgets and lcb is one of best additions to
LC. Community collaboration like this will make for better documentation and
more new/improved widgets. A robust library of widgets can only help LC to
penetrate the market. If only we had these when I started...


I so much want to agree - but unfortunately it looks to me more like the 
biggest missed opportunity.


The combination of widgets and LCB is a powerful one (and may indeed be 
one of the best additions). But I think if you unpick and pull apart the 
two parts (widget vs LCB) then there is what looks, to the naive 
observer like me, a missed chance.


Widgets + LCB gives us (amongst other things):

1. naming + distribution + installation schemes.

2. integration with the docs / dictionary and IDE tools (inspectors, 
editors)


3. efficient "direct" drawing to canvas

4. typed variables

5. access to foreign languages / libraries.

6. maybe potential for future performance gains.


But of those, only the last two *require* LCB; the others *could* have 
been done in a way that allows LCScript authors to benefit. (1) and (2) 
are clearly feasible for LCS almost without change from what's been done 
for LCB widgets, and I have to believe it would have been possible to 
provide LCS commands and functions to manipulate the canvas.


Given those three things, many of the widgets (e.g. rotatedtext, navRAD) 
look like they could have been done easily using LCS.


I still hold on to the hope that this will become a feature in some 
future release. And when (if) it ever does, then maybe we will see "1000 
widgets by Christmas" because it will be so much more approachable for 
the average LS Scripter.


Alex.




___
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: NAVRAD was: lcb missing manual

2022-09-16 Thread Alex Tweedly via use-livecode
Sorry, I confused things by using the word "outdated". I wasn't 
referring to the date in the copyright statement, but to the fact that 
it says "Livecode is free software [...  GPL]", and "this file is part 
of Livecode", and implications that may have on the license situation 
for the widget and anyone who uses it in an app.


Alex.


On 16/09/2022 01:19, J. Landman Gay via use-livecode wrote:
Legally the only date that matters is the date of creation. Almost 
everyone adds the current date as well, and I keep trying to talk my 
clients out of it but they won't listen. Then I have to keep updating 
the copyright string, knowing it doesn't matter, but if I don't the 
app looks old and unsupported. Some time back I wrote a handler that 
updates the end date to the current year on launch so I don't have to 
worry about it.


A single copyright creation date is valid for the life of the creator 
plus (in the US) 75 years.


Oh well.
--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
On September 15, 2022 5:12:59 PM Alex Tweedly via use-livecode 
 wrote:



On 15/09/2022 15:44, Mike Kerner via use-livecode wrote:

What's NavRAD? It's a better version of LiveCode's NavBar widget.
Why "RAD"? Cos Ralph A DiMola said so, since he added the first two 
nifty

updates to it:


I see the code has an outdated copyright statement, which would (I
think) currently mean that any app using it would (potentially) become
open-source (GPL). If that;s not the intent, maybe it could be updated ?

Currently it says


  Copyright (C) 2015-2022 LiveCode Ltd.icon

  This file is part of LiveCode.

  LiveCode is free software; you can redistribute it and/or modify it
under
  the terms of the GNU General Public License v3 as published by the 
Free

  Software Foundation.

  LiveCode is distributed in the hope that it will be useful, but
WITHOUT ANY
  WARRANTY; without even the implied warranty of MERCHANTABILITY or
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  for more details.

  You should have received a copy of the GNU General Public License
  along with LiveCode.  If not see <http://www.gnu.org/licenses/>.  */


Alex.




Copyright (C) 2015-2022 LiveCode Ltd.icon



This file is part of LiveCode.



LiveCode is free software; you can redistribute it and/or modify it
under

the terms of the GNU General Public License v3 as published by 
the Free


Software Foundation.



LiveCode is distributed in the hope that it will be useful, but
WITHOUT ANY

WARRANTY; without even the implied warranty of MERCHANTABILITY or

FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 
License


for more details.



You should have received a copy of the GNU General Public License

along with LiveCode. If not see <http://www.gnu.org/licenses/>. */



___
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


___
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: NAVRAD was: lcb missing manual

2022-09-15 Thread Alex Tweedly via use-livecode


On 15/09/2022 15:44, Mike Kerner via use-livecode wrote:

What's NavRAD? It's a better version of LiveCode's NavBar widget.
Why "RAD"? Cos Ralph A DiMola said so, since he added the first two nifty
updates to it:


I see the code has an outdated copyright statement, which would (I 
think) currently mean that any app using it would (potentially) become 
open-source (GPL). If that;s not the intent, maybe it could be updated ?


Currently it says


  Copyright (C) 2015-2022 LiveCode Ltd.icon

  This file is part of LiveCode.

  LiveCode is free software; you can redistribute it and/or modify it 
under

  the terms of the GNU General Public License v3 as published by the Free
  Software Foundation.

  LiveCode is distributed in the hope that it will be useful, but 
WITHOUT ANY

  WARRANTY; without even the implied warranty of MERCHANTABILITY or
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  for more details.

  You should have received a copy of the GNU General Public License
  along with LiveCode.  If not see .  */


Alex.




Copyright (C) 2015-2022 LiveCode Ltd.icon



This file is part of LiveCode.



	LiveCode is free software; you can redistribute it and/or modify it 
under


the terms of the GNU General Public License v3 as published by the Free

Software Foundation.



	LiveCode is distributed in the hope that it will be useful, but 
WITHOUT ANY


WARRANTY; without even the implied warranty of MERCHANTABILITY or

FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License

for more details.



You should have received a copy of the GNU General Public License

along with LiveCode. If not see . */



___
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: Standardize Font Appearance

2022-09-13 Thread Alex Tweedly via use-livecode


On 13/09/2022 03:51, Richard Gaskin via use-livecode wrote:


So help me understand: what are you working on where a user expects 
fine-grained font rendering consistency on multiple OSes? What do 
these apps do?


One example that (almost) applied for me was where the target display is 
not an OS, and indeed the viewer doesn't think they are looking at a 
'computer', e.g. an information display in a museum.


I started doing something like this for a local organisation, but their 
funding never materialized. But while talking about it, they had no idea 
whether they'd use Macs or PCs or most likely both, and  they expected 
it to look the same regardless, and they wanted the content creator (who 
would typically only have one of the platforms to try it out on) to be 
able to get a good idea of how things would look.


Alex.


___
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 converts phone number to scientific notation

2022-09-09 Thread Alex Tweedly via use-livecode
No, not all are 2-digits.   USA is one digit, many are 3 digits, none 
are (yet) 4 digits.


A phone number would have a leading zero in many countries; usually 
indicating it's a non-local number (kind of similar to the leading 1- in 
long distance in the US, e.g. 1-800-555-1212). In the UK, numbers are, 
for example, 01x1 ddd , but a local number will never begin with a 0.


Alex.

On 09/09/2022 16:38, Bob Sneidar via use-livecode wrote:

I have a function called formatPhone() I can modify it to support international 
notation and send it to you. Are all country codes 2 digits? And why would a 
phone number have a leading 0?

Bob S



On Sep 9, 2022, at 03:00 , Klaus major-k via use-livecode 
 wrote:

Hi friends,

I have a very strange problem, but also found a workaround for it.

I first convert an 8 MB CSV file with 6 lines to TAB delimited data, then I 
parse the file
and just extract some columns from the 6 lines to display in a field.
E.g. the column "number dialled", which contains phone number like
-> 447973100123

The CSV files are definitively correct but I found that in the resulting field 
some of these numbers
appear in scientific notation
-> 4.47888E+11

This does not happen with phone numbers with a leading ZERO: like
-> 07557162491
So maybe this a small hint?

However I do not even touch these items I just use:
...
put item 9 of tLine into item 6 of tNewLine
## tLine is the line from the CSV and tNewLine is for the data in the display 
field.
...

My simple workaround, no idea why, but it obviously works:
...
put item 9 of tLine into ttt
put ttt into item 6 of tNewLine
...
This avoids the scientific notation, what the hell is going on here?
Any hints welcome.


Best

Klaus
--
Klaus Major
https://www.major-k.de
https://www.major-k.de/bass
kl...@major-k.de


___
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


___
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 converts phone number to scientific notation

2022-09-09 Thread Alex Tweedly via use-livecode

No, I just need to learn to not type emails on my iPhone :-)

I do it so rarely, I forget to be careful about autocorrect.

On 09/09/2022 16:39, Bob Sneidar via use-livecode wrote:

Someone needs to debug their emails. ;-)

Bob S


On Sep 9, 2022, at 06:32 , Klaus major-k via use-livecode 
mailto:use-livecode@lists.runrev.com>> wrote:

Put (“” & item 9 of globe) onto item 6 of tnewline


___
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: LC converts phone number to scientific notation

2022-09-09 Thread Alex Tweedly via use-livecode
How about 

Put (“” & item 9 of globe) onto item 6 of tnewline

Alex

Sent from my iPhone

> On 9 Sep 2022, at 11:40, Klaus major-k via use-livecode 
>  wrote:
> 
> Hi Panos,
> 
>> Am 09.09.2022 um 12:27 schrieb panagiotis m via use-livecode 
>> :
>> 
>> Hello Klaus,
>> 
>> I guess what happens here is that if you fetch item X of line Y and use it
>> directly, LC treats it as a number and displays it in scientific notation.
> 
> obviously!
> 
>> On the contrary, if you first put item X of line Y into a variable, then
>> the variable is treated as text, so it is not converted.
> 
> Yo, that's why my workaround erm. works. :-)
> Thank you for the explanation!
> 
>> Kind regards,
>> Panos
>> --
>> 
>>> On Fri, 9 Sept 2022 at 13:01, Klaus major-k via use-livecode <
>>> use-livecode@lists.runrev.com> wrote:
>>> 
>>> Hi friends,
>>> 
>>> I have a very strange problem, but also found a workaround for it.
>>> 
>>> I first convert an 8 MB CSV file with 6 lines to TAB delimited data,
>>> then I parse the file
>>> and just extract some columns from the 6 lines to display in a field.
>>> E.g. the column "number dialled", which contains phone number like
>>> -> 447973100123
>>> 
>>> The CSV files are definitively correct but I found that in the resulting
>>> field some of these numbers
>>> appear in scientific notation
>>> -> 4.47888E+11
>>> 
>>> This does not happen with phone numbers with a leading ZERO: like
>>> -> 07557162491
>>> So maybe this a small hint?
>>> 
>>> However I do not even touch these items I just use:
>>> ...
>>> put item 9 of tLine into item 6 of tNewLine
>>> ## tLine is the line from the CSV and tNewLine is for the data in the
>>> display field.
>>> ...
>>> 
>>> My simple workaround, no idea why, but it obviously works:
>>> ...
>>> put item 9 of tLine into ttt
>>> put ttt into item 6 of tNewLine
>>> ...
>>> This avoids the scientific notation, what the hell is going on here?
>>> Any hints welcome.
>> 
> 
> Best
> 
> Klaus
> 
> --
> Klaus Major
> https://www.major-k.de
> https://www.major-k.de/bass
> kl...@major-k.de
> 
> 
> ___
> 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: BN Guides

2022-08-25 Thread Alex Tweedly via use-livecode
Bob,

Just email Heather- she can do everything !

Probably the support @ livecode.com address would be more correct than her 
directly.

Alex

Sent from my iPhone

> On 25 Aug 2022, at 17:18, Bob Sneidar via use-livecode 
>  wrote:
> 
> I found the link to the Board Administrator. The board administrator link 
> has been disabled. LOL!
> 
> Bob S
> 
> 
> On Aug 25, 2022, at 09:15 , Bob Sneidar via use-livecode 
> mailto:use-livecode@lists.runrev.com>> wrote:
> 
> I am then advised to contact the administrator, but there is no link I can 
> find on the forums page for an administrator.
> 
> ___
> 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: case sensitivity of the keys in an associative array

2022-08-23 Thread Alex Tweedly via use-livecode

Not quite.

It is dependent on the value of "casesensitive".

If you do

set the casesensitve to true

then the keys are different (i.e. Ddt  would NOT replace the existing 
value for ddt)


but if it is false (which it would be by default) thne DDt and ddt are 
teh same.


[Only tested on 10.0.0 DP4 - but I think that's how it's always been]

Alex.


on mouseup
   local tA
   put 1 into tA["a"]
   put "1" && the keys of tA  after msg
   set the casesensitive to true
   put 2 into tA["A"]
   put "2" && tA["a"] && the keys of tA  after msg
end mouseup


On 23/08/2022 15:31, francois.chaplais via use-livecode wrote:

Dear list

 From my current work on a LiveCode project, it seems that the keys of an 
associative array are not case sensitive.

For instance, I may define
theArray[« Ddt »]

If I define now
theArray[« ddt »]

this entry replaces the previous one (forgive apple mail which replaces my 
double quotes by french double quotes)

Is this behavior confirmed?

Best regards
François
___
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: Livecode performance problem

2022-08-20 Thread Alex Tweedly via use-livecode
I can't answer for anyone else, but for me - because I never thought 
about it :-)


Combine by column - never used it before, so never thought of it.

It's significantly faster, roughly 40% improvement over the previous best.

Note, the spec requires that each line begins with the line number, so 
you need to add something like:



   local tmp
   repeat with i = 1 to the number of lines in g1
  put i  after tmp
   end repeat
   put tmp into x[1]

   put g1 into x[2]
   put g2 into x[3]
   put g3 into x[4]
   put g4 into x[5]

and finish off with

   combine x by column
   put cr after x

to fully match the earlier results.

Alex.

On 20/08/2022 18:45, David Epstein via use-livecode wrote:

I didn’t text the speed, but why not

put fld A into x[1]
put fld B into x[2]
put fld C into x[3]
put fld D into x[4]
combine x by column
return x


I have a set of fields, call them A, B, C, and D. Each has the same
number of lines. Each field has different text (per line)

I need to combine the data - frequently - into a form that look like:




___
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


The use-livecode list.

2022-08-19 Thread Alex Tweedly via use-livecode
I've had a pretty shitty day. A variety of things have happened, or not 
happened, that made it not one of the good days.


So I was not happy, and rather grumpy. (My apologies to Panos for being 
ungracious in an earlier post - it was meant to be a plea for 
completeness of the product in preference to more work-arounds - but it 
came across wrongly. Sorry, Panos).


And then, the use-list comes up with a nice, tight, well-defined problem 
to tackle - and now I can end my day on a puzzle-solving high note, 
rather than dragging myself off to bed on a downbeat.


Thanks again, use-list !!

Alex.



___
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: Livecode performance problem

2022-08-19 Thread Alex Tweedly via use-livecode



On 20/08/2022 00:03, Bob Sneidar via use-livecode wrote:

It's probably a lot of text. The engine has to start from the beginning of 
every string then scan through for every cr or lf or cr/lf or whatever counts 
as a line break, until if finds the nth one. The more lines, the longer the 
scan takes each time, and the more text per line the exponentially more time it 
takes. Multiply that by 4 times plus the combinination of all of them as the 
code progresses *4 for the output string and you have the makings of a mountain 
that keeps getting steeper the higher you go.


Yes, for all the input strings. For the output string, it's just a "put 
... after ...", so there is no need to count or scan the output string; 
LC already keeps (effectively) a pointer to the end of a string, and 
optimizes the straightforward extension at the end of a string.


Alex.



___
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: Livecode performance problem

2022-08-19 Thread Alex Tweedly via use-livecode


On 19/08/2022 23:32, Mark Wieder via use-livecode wrote:


It is indeed faster. Here's what I came up with. I'm not sure why 2000 
lines of text in four fields should take that long, I came up with


original code: 320 ms
array version: 21 ms

   put empty into vCombined
   put fld "A" into v1
   put fld "B" into v2
   put fld "C" into v3
   put fld "D" into v4
   split v1 by cr
   split v2 by cr
   split v3 by cr
   split v4 by cr
   put 1 into i
   repeat for each element tLine in v1
  put i[i][i][i][i] after 
vCombined

  add 1 to i
   end repeat


which is already quick enough that any further improvement is mainly 
academic.


But for the record:

"repeat for each line " is very efficient for a single variable, o you 
can avoid one of the four 'split's, and use the line variable to count 
your loop.



   --   split v1 by cr
   split v2 by cr
   split v3 by cr
   split v4 by cr
   put 1 into i
   repeat for each line tLine in v1
  put i& tLine & v2[i] & v3[i] & v4[i] & cr after 
vCombined

  add 1 to i
   end repeat

to trim about another 15% off the time (for my sample data, 24ms down to 
20ms.)


(and if you know that one of the four fields typically contains much 
more text (i.e. longer lines) than the others, you would choose it to 
not be split).


Alex.



___
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


Polylist widget Lazy Loading images example. [was Re: polylist toys]

2022-08-18 Thread Alex Tweedly via use-livecode


On 18/08/2022 23:13, Alex Tweedly via use-livecode wrote:


However, the lazy load example still contains bugs due to race conditions


Solution:

replace the card script with the following  should fix all the race 
conditions I can see.



local sURLToIndex

on onlineImage pIndex, pURL
   put  pIndex  after sURLToIndex[pURL]
   load URL pURL  with message "downloadComplete"
end onlineImage

on downloadComplete pURL, pSatus
  local tURL
  repeat for each line L in sURLToIndex[pURL]
 set the itemPointer of widget "PolyList" to L
 set the subItemPointer of widget "PolyList" to "url"
 put the subitemContent of widget "PolyList" into tURL
 if tURL = pURL then -- still the right URL
    set the subItemPointer of widget "PolyList" to "image"
    set the subitemContent of widget "PolyList" to URL pURL
 end if
  end repeat
  put empty into sURLToIndex[pURL]
end downloadComplete


And in the real world, add in cache aging, limit on number of entries, 
limit on total cache size in bytes, ...


Alex.



1. if multiple entries reference the same image, then there is a 
chance the earlier ones never get properly updated (sURLToIndex[pURL] 
will have been overwritten by the next call to onlineImage before the 
image value gets set).


2. if the user (or anything else) resets the dataContent of the widget 
while there are outstanding "load URL"s, then when the 
downloadComplete is triggered, it will set the image value for some 
random new item to the image of the earlier one.


3. And if the one which was wrongly set in case 2 above also happens 
to be a URL that occurs multiple time (i.e. case 1 above), then that 
wrongly set image will remain "forever".





___
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: polylist toys

2022-08-18 Thread Alex Tweedly via use-livecode



On 18/08/2022 17:34, Steven Crighton via use-livecode wrote:

Hi Mike,

I just tested the lazy load example and hit populate and clicked around etc and 
could not trigger an error.


As already confirmed, that problem is fixed in 10.

However, the lazy load example still contains bugs due to race 
conditions, some of which I described in some forum post somewhere (Boy 
do I hate the forums! Surely there's some way to check what posts I have 
done myself).


Thinking about it more, there are other race conditions which are 
perhaps more obscure, but more serious. I know it's only an example, and 
maybe can't be expected to be bulletproof, but as an example of how to 
do Lazy Loading it is (IMHO) really too naive and simplistic. People 
expect to take those examples and just use them.


The obvious race conditions are:

1. if multiple entries reference the same image, then there is a chance 
the earlier ones never get properly updated (sURLToIndex[pURL] will have 
been overwritten by the next call to onlineImage before the image value 
gets set).


2. if the user (or anything else) resets the dataContent of the widget 
while there are outstanding "load URL"s, then when the downloadComplete 
is triggered, it will set the image value for some random new item to 
the image of the earlier one.


3. And if the one which was wrongly set in case 2 above also happens to 
be a URL that occurs multiple time (i.e. case 1 above), then that 
wrongly set image will remain "forever".


Alex.
___
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


Sorting [was: Polygrid sorting]

2022-08-15 Thread Alex Tweedly via use-livecode
So it occurred to me, while playing with sorting by columns, that it 
might be nice to have an additional "sortType" available.


I'd like to be able to say

 - if all the 'things' being sorted on are numbers, then sort numeric, 
otherwise sort alphabetical.


Would that be a reasonable enhancement request ?

Would "natural" be a reasonable suggested name ?

Alex.


___
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: Polygrid sorting (problems)

2022-08-15 Thread Alex Tweedly via use-livecode


On 15/08/2022 20:34, Paul Dupuis via use-livecode wrote:
So there is an example of sorting in the PolyGrid documentation under 
the entry for the MESSAGE "headerClick" and under the entry to the 
PROPERTY "text" (and in 'the text of me')


The example code only sort the visible rows as "the text of widget X" 
returns the data of PolyGrid X as tab delimited, WITHOUT the column 
headers, but ONLY the visible rows.


I'm using (I think) the latest version 
(com.livecode.widget.polygrid.1.1.1) and I don't see that problem at all.


Both "the text and "the pgtext" return the entire grid (without headers).

I haven't tried csvdata or tsvdata (they're not listed in the 
dictionary, so I'd tend to avoid them if possible.


And come to think of it - why did they need to invent a new property 
name "pgText" ?  It seems to be a synonym for "the text", so would it 
not have been better to just use that ?  Full consistency with many 
other controls, no added "mental clutter", and "the text" colours nicely 
in the script editor, so more obvious if you mistype it.


Alex.



___
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: A web app launcher with responsive design

2022-08-13 Thread Alex Tweedly via use-livecode


On 13/08/2022 20:24, Andreas Bergendal via use-livecode wrote:

Friends, I have done wonderful things with LC10 web deployment!

I’m excited to share with you the fruits of this week's extensive research and 
testing!


Wow. Thanks Andreas.

Resize, etc. work well for me on Safari, but fail badly on Chrome 
browser (details not included) - all build-for-web attempts fail on this 
version of Chrome.  (which it says is up-to-date).



However, the way I read your email ( "...excited to share with you the 
fruits of this week's..."), I think ui intend to make this code 
available for the rest of us to use. But, I cant see a link, or a way to 
get access to the source.


Please tell me I'm not over-interpreting your words. Please say that you 
have, or will, publish the text of the stacks involved.


Many thanks again,

Alex.



___
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: Server globals

2022-08-12 Thread Alex Tweedly via use-livecode

Hi Tim,

I think there are many easy ways to do this - and many not-so-easy ones too.

IMO, easiest for something simple like this is to just use the url.

See tweedly.net/page_by_url.txt for the code, or try it out at 
tweedly.net/page_by_url.lc


(or try tweedly.net/page_by_url.lc?row=14 )

You can do something very similar using a cookie, with the 'row' value 
stored in the cookie each time (remember to "put cookie ..." before 
*any* other output.)


Or by using the cookie to hold the name of a file in which you store 
this kind of info. This is necessary if you need to store a lot of data 
- if there is not already a cookie, create a filename using something 
like uuid(), and store the file name in it - then retrieve the cookie, 
and read or write the file.


Alex.

On 12/08/2022 14:18, Tim Selander via use-livecode wrote:

Hi Matthias,

It is user specific, but I just tried the saving to a text file on the 
server -- very fast. Got the user IP from $_Server, and used that in 
the filename for easy later retrieval. How much data can a cookie 
hold? Guess I'll test that.


One of the reasons I'm fussing with this is I'm trying to come up with 
some kind of pagination system. I'm probably trying to re-invent the 
wheel -- badly.


It's a simple membership list, with a few hundred records. Only want 
to show 30 on the page at a time. I wonder if anyone has a LC sample 
for doing that. I tried Ralph Bitter's Revigniter but just can't wrap 
my head around it.


Using MySQL for testing, so could try to figure out using the CURSOR 
feature. But know nothing about avoiding injection attacks, so may 
fall back to using  a .csv for the datafile. I've done that for all my 
other projects


Anyway, thanks for the info; no global variables, but file saves look 
like they'll work!


Tim

On 2022.08.12 21:26, matthias rebbe via use-livecode wrote:

Hi Tim,

does the variable have a user specific value or a value, that changes 
from time to time, but is the same for all users?


I've done something some time ago and used a text file on the server 
which stored that value. In my case the value was not user specific 
so it was an easy task.



If the variable is user specific, why don't you use a  cookies for 
that? That will grant that the value is available  at all pages in 
the same domain.


Regards,
Matthias


Am 12.08.2022 um 13:27 schrieb Tim Selander via use-livecode 
:


As always, appreciate everyone's help.

Have made several little projects using LC Server on the on-rev.com 
host. For the first time, I would like a global variable -- that is 
a variable that would retain it's value even if the page is 
re-loaded. Or if a user goes to another .lc page/file in the domain.


All my playing around, and Googling around, has been for nought. Is 
there a way to hang on to a bit of data was you move around pages in 
the same domain?


Thanks.

Tim Selander
Tokyo, Japan

___
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



___
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: How to use addEventListener for browser window resizing in web deployment?

2022-08-06 Thread Alex Tweedly via use-livecode
You are correct Andreas - all this basic javascript interaction *really* 
should be in the default built already.


A sample stack for building a web app was discussed in a session in the 
LC Global conference, by Steven Crichton and Michael McReary. It has all 
kinds of javascript magic, and the corresponding LC pairing. AFAIK, that 
stack hasn't been made public, so it wouldn't be up to me to show large 
sections - but I'm sure it's ok to give a couple of snippets .


In the stack script of the app (includes some stuff with 'spinner - 
probably not generally needed) :



on openStack
   if the platform is "web" then
  do "document.querySelector('#canvas').removeAttribute('width');" 
as "javascript"
  do 
"document.querySelector('#canvas').removeAttribute('height');" as 
"javascript"
  do "document.querySelector('#canvas').style.width = '100%';" as 
"javascript"
  do 
"document.querySelector('#emscripten_main').removeAttribute('width');" 
as "javascript"
  do 
"document.querySelector('#emscripten_main').removeAttribute('height');" 
as "javascript"
  do "document.querySelector('#emscripten_main').style.width = 
'100%';" as "javascript"
  do "var element = 
document.getElementById('spinner');element.parentNode.removeChild(element);" 
as "javascript"
  do "var element = 
document.getElementById('status');element.parentNode.removeChild(element);" 
as "javascript"
  do 
"document.querySelector('#donestatus').removeAttribute('style');" as 
"javascript"
  do "document.querySelector('#by').removeAttribute('style');" as 
"javascript"


  send "doBrowserResize" to me in 0 millisecs
   end if
end openStack

on browserResized pInnerHeight
   set the height of this stack to pInnerHeight
   do 
"document.querySelector('#emscripten_main').removeAttribute('width');" 
as "javascript"
   do "document.querySelector('#emscripten_main').style.width = 
'100%';" as "javascript"

end browserResized

on doBrowserResize
   set the cJavascriptHandlers of this stack to "browserResized" & 
return & "scrollEvent"

   set the visible of this stack to true
   do "getInnerHeight();" as "javascript"
   browserResized the result
end doBrowserResize

on scrollEvent pHScroll, pVScroll
   send "scrollEvent" && pHScroll & comma & pVScroll to this card in 0 
seconds

end scrollEvent


and in the standalone.html :

Hmmm - I don't understand it well enough to clip out the needed parts - 
so I've included the whole thing below  :-(   Again, it includes stuff 
with spinner, and stripe - which probably should be removed in the 
general case. Hopefully, LC will get their act together and provide a 
default build where basic functionality works.


Good luck,

Alex.



    
    
    

    LiveCode Conference - Meeting Space

    
    body {
        font-family: arial;
        margin: 0;
        padding: none;
        background-color:#fafafa !important;
        border-top: 0px solid #282828;
    }
    .emscripten {
        padding-right: 0;
        margin-left: auto;
        margin-right: auto;
        display: block
    }
    div.emscripten {
        text-align: center
    }
    div.emscripten_border {
        border: 0px solid #000
    }
    canvas.emscripten {
        border: 0 none
    }
    #emscripten_logo {
        display: inline-block;
        margin: 0
    }
    .spinner {
        position: fixed;
        left: 0px;
        top: 0px;
        width: 100%;
        height: 100%;
        z-index: 1000;
       background: url('https://michael.on-rev.com/Meeting%20Space/spinner.gif') no-repeat center center;
        background-color:#fafafa !important;
        border-top: 0px solid #282828;
    }
    @-webkit-keyframes rotation {
        from {
            -webkit-transform: rotate(0)
        }
        to {
            -webkit-transform: rotate(360deg)
        }
    }
    @-moz-keyframes rotation {
        from {
            -moz-transform: rotate(0)
        }
        to {
            -moz-transform: rotate(360deg)
        }
    }
    @-o-keyframes rotation {
        from {
            -o-transform: rotate(0)
        }
        to {
            -o-transform: rotate(360deg)
        }
    }
    @keyframes rotation {
        from {
            transform: rotate(0)
        }
        to {
            transform: rotate(360deg)
        }
    }
    #status {
        position:absolute;
        left: 0px;
        bottom: 50px;
        z-index: 1000;
        vertical-align: bottom;
        font-weight: 700;
        color: #787878
        text-align: center;
    

Re: megabundle thoughts

2022-08-05 Thread Alex Tweedly via use-livecode

I kind of agree with Paul (though I ame to the opposite conclusion).

Once I discounted the items I'd already paid for (conferences, courses, 
books, etc.) and the multi-year future licensing already paid, the value 
of the megabundle shrank from "amazing" to "pretty good".


I decided to go ahead anyway (so I now have a $300 or $399 voucher that 
I may never get to use).



But about the widgets 

I am very impressed by the PolyList widget; it lets you make 
sophisticated looking lists, including multi-column ones, very easy; I 
always disliked the fact that DataGrid couldn't do multi-column. I do 
think it needs, and will get, improvements (for example, I'd like to see 
a graphic UI to specify dataLayout - the current way seems kind of 
late-80's-ish :-)


Polygrid looks like it could be useful in the right place - haven't used 
it yet.


Responsive layout - seems like a great addition - I look forward to 
trying it out, but haven't got there yet.


Haven't yet investigated the others. I think they could all do with 
better documentation and examples, so I'm really waiting for a tutorial 
or blog from Steven before I dive into each :-)


Oh - and last thought - they could *really* do with a better release / 
version system, but that should resolve itself over time.


Alex.


On 05/08/2022 17:51, Paul Dupuis via use-livecode wrote:

On 8/5/2022 12:32 PM, Mike Kerner via use-livecode wrote:

i have not seen much discussion of the megabundle, especially about the
widgets, etc.
i'm not sure if it's worth the $.
thoughts?



I think the widgets are great additions to Livecode. That said, I have 
not purchased the MegaBundle. My Livecode commercial/business/whatever 
license is paid out to something like 2023 or 2024 due to past fund 
raising where the mothership offered license extensions as part of the 
packages in those efforts. I am licensed for all platforms, with the 
professional extensions, so I don't need any more platforms and I 
really don't need my license extended or any store credits. If there 
had been a bundle offering that was JUST the extra widgets and stuff 
without an LC license stuff bundled in, I would have bought one.


I don't like to get too far ahead of LC licensing. After all I could 
get hit by the proverbial bus tomorrow and having 2 years or prepaid 
LC licensing would go to waste (for me at least).


So, I think it is worth the $ if you need additional platforms and/or 
your license extended (if it is about to expire in, say, another 15 
months or less). It may not be worth the $ if you are all set for the 
next couple of years on LC licensing itself.


___
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: deleting folders on server with revDeleteFolder

2022-07-17 Thread Alex Tweedly via use-livecode

Those folders are

"." - the folder itself

".." - the parent of the folder itself.

As such, neither can be deleted directly, nor do they need to be in 
order to delete the folder itself. The folder itself should be deleted 
when the current folder is set to somewhere else.


So - there isn't really a problem, just don't try to delete them by 
those names.



Alex.


On 17/07/2022 10:16, jbv via use-livecode wrote:

Hi list,

On my LC Hosting account, I have a php script that creates directories :
   mkdir($dirname, 0755);
Each directory is used to temporarily store text & image files.

Then I have a LC script that is supposed to delete those directories
under certain conditions. No problem for deleting files inside each
directory, but 2 sub-directories are systematically created, named
"." and ".." and those can't be deleted, either by script of via ftp.
Therefore, there's no way to delete the directories created via php.

Last but not least, the doc for LC 9.6.8 says that "revDeleteFolder"
is the command to use to remove a folder and all its contents and that
it is available on both desktop and server platforms, but on my LC
hosting account I get : Handler: can't find handler (revDeleteFolder)

Any idea how to solve this problem ?
Thank you in advance.
jbv

___
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: Encrypted Data over Sockets

2022-07-08 Thread Alex Tweedly via use-livecode
But, an encoded array is STILL binary data. So any issues with "read 
until linefeed" will still exist.


Try sending a header with number of bytes, followed by the bytes.

If you really wanted, you could do:

   write  (the number of bytes in tSocketData) & linefeed to socket tSocket
   write tSocketData & linefeed to socket tSocket

and then when you read,

   read from socket tSocket until linefeed
   put it into tNumBytes
   read from socket tSocket until linefeed
   put it into tData

and compare tNumbytes with the number of bytes in tData

Or, just do

   read tnumbytes form socket tSocket

Alex.

On 09/07/2022 00:49, Bob Sneidar via use-livecode wrote:

Well I disabled encryption alltogether, sending and receiving an encoded array 
instead. Upon trying to decode I still get an error, and looking at what I get 
back, it LOOKS like an encoded array. They is just something wrong with the 
data. Curiously, if I just send and receive plain text it works every time.

Bob S



On Jul 8, 2022, at 16:35 , Mark Wieder via use-livecode 
 wrote:

On 7/8/22 16:14, Bob Sneidar via use-livecode wrote:


My suspicion is that the hash contains a linefeed (sometimes). So the question 
I have is, what character is GUARANTEED to NOT be in an aes256 hash?

Not a valid question.

If you really need to send binary data over a socket connection, start by 
sending a header that contains the data length. Extract that and then read that 
many bytes.

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


___
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: arrayencode

2022-06-23 Thread Alex Tweedly via use-livecode

On 23/06/2022 17:48, Ralf Bitter via use-livecode wrote:



Hi Alex, have you added the mergJSON External to your server installation?

No. In fact, I didn't realize I needed to, or even could :-)


You guessed it, use "load extension", example (tested on on-rev):

load extension from file 
"/home/rabit/public_html/ritest/application/extensions/com.livecode.library.json/module.lcm"


Well, I finally found that file, buried inside the Livecode Application 
bundle (inside Tools of all places). I don't know how anyone not 
familiar with command line tools would ever get there.


And having uploaded it and then loaded it, JSONImport works !! Thank you 
Ralf for sticking with me patiently, and everyone else for their help.


Now - back to that quick 5-minute test I was going to do 1-1/2 days ago :-(

Alex.





___
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: How to color a "cell"?

2022-06-23 Thread Alex Tweedly via use-livecode



On 23/06/2022 19:28, Richard Gaskin via use-livecode wrote:


Thanks. I could get away with setting the backgroundColor of the whole 
line, but that does the same as setting the backgroundColor of a 
"cell": it draws the color only beneath the portion of the line that 
contains text, leaving the rest blank.



H - is there a non-visible character that would count as text ?

then you could replace all spaces by it, and adjust back later.

Alex


___
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: arrayencode

2022-06-23 Thread Alex Tweedly via use-livecode


On 23/06/2022 10:31, Ralf Bitter via use-livecode wrote:

Hi Alex,

the JSONtoArray() function is part of the mergJSON external.
The README of this external describes how to use this function
and it's counterpart JSONtoArray as follows:

Thanks Ralf. I did see that code in the dictionary - but it also says 
that those functions are provided in 
thews.goulding.script-library.mergjson library, so (I think) I shouldn't 
need to put them in myself.


In fact, I did try it anyway - but that simply changes the error to 
"handler not found: mergJSONDecode"



Another option would be to load the JSON extension and to use
the JsonImport() function.

Didn't know about jsonImport; it's not mentioned in the dictionary, but 
I now see it shows up in a few lessons, etc.


However,I think the real problem for me is "... to load the JSON 
extension ...". I wasn't aware I had to load those extensions which are 
already part of the standard package (maybe I did that years ago and 
have had time to forget :-).


I can't find anything about loading extensions other than what to do in 
the IDE.


How do you load extensions to LC Server ?  On a shared web provider ?  
(on-rev)


Thanks,
Alex



Ralf



On 23.06.22 01:31, Alex Tweedly via use-livecode wrote:


On 22/06/2022 17:02, Richard Gaskin via use-livecode wrote:

[ ... about using JSON ... ]
But if you don't need interoperability, you wouldn't need to write a 
parser, since LC includes a good one built into the engine.


What did I miss?


The fact that Livecode's support for JSON is, hmmm, mediocre at best ??

The parser "built-in" seems to work fine in the IDE, but not on the 
server :




fails with -

file "/home/alextwee/public_html/rampuk/tJSON.lc"
   row 7, col 5: Function: error in function handler (JSONtoarray)
   row 7, col 5: put: error in expression

(there's no mention of any platform restricitons in the dictionary).

I tried copying in the sample ode for wrapping JSONToArray around 
mergJSONDecode,

which then fails with "error in function handler mergJSONDecode.


(I must admit I encountered this a while ago, figured it was probably 
a temporary issue
so I replaced JSON by LSON, and forgot all about it.) This discussion 
prompted me to re-try it.


I can't believe this problem isn't causing widespread problems, so 
it's probably
something specific about me, or my on-rev account. If anyone has 
suggestions, I'll

try them; if not, I'll put it as a bug report into QCC see what happens.

Alex.




___
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: arrayencode

2022-06-22 Thread Alex Tweedly via use-livecode


On 23/06/2022 00:38, Richard Gaskin via use-livecode wrote:


Interesting take. Thanks. I'd read Tom's post as being about LSON, 
with LC in both producer and consumer roles, which would make a 
JavaScript-optimized format unnecessary.  Perhaps I'd misunderstood.


No, you didn't misunderstand. I misread your earlier post.  Your 
reference to  "built-in parser" was indeed about LSON, and obviously 
so;  I just misread it as being about JSON.


Nevertheless, my central point remains (afact) valid - the support for 
JSON in Livecode seems incomplete, and in particular it seems 
flaky/missing on LCServer.


Alex.



___
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: arrayencode

2022-06-22 Thread Alex Tweedly via use-livecode



On 22/06/2022 17:02, Richard Gaskin via use-livecode wrote:

[ ... about using JSON ... ]
But if you don't need interoperability, you wouldn't need to write a 
parser, since LC includes a good one built into the engine.


What did I miss?


The fact that Livecode's support for JSON is, hmmm, mediocre at best ??

The parser "built-in" seems to work fine in the IDE, but not on the server :



fails with -

file "/home/alextwee/public_html/rampuk/tJSON.lc"
  row 7, col 5: Function: error in function handler (JSONtoarray)
  row 7, col 5: put: error in expression

(there's no mention of any platform restricitons in the dictionary).

I tried copying in the sample ode for wrapping JSONToArray around 
mergJSONDecode,
which then fails with "error in function handler mergJSONDecode.


(I must admit I encountered this a while ago, figured it was probably a 
temporary issue
so I replaced JSON by LSON, and forgot all about it.) This discussion prompted 
me to re-try it.

I can't believe this problem isn't causing widespread problems, so it's probably
something specific about me, or my on-rev account. If anyone has suggestions, 
I'll
try them; if not, I'll put it as a bug report into QCC see what happens.

Alex.

___
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: Stylistic question.

2022-06-19 Thread Alex Tweedly via use-livecode


On 20/06/2022 00:19, Bob Sneidar via use-livecode wrote:

Well code shared commonly between multiple objects should generally be in an 
object shared by those objects. That can be the card, stack, behavior or 
front/back script. The script of a group as well.


Absolutely. And the converse - code that is not shared should be as low 
in the hierarchy as possible.


In this case, there is really no shared code.

If it's button "first" you call one handler. If it's button "whatever I 
called the second", you call a different handler. etc.  Nothing shared 
at all.



As to Brian's point about behaviours and Git, I can see that. I admit to 
being slightly "slack" about what code needs to go into behaviour 
scripts so it can be Gitted. If it's code that is very brief, and will 
"never" change, I put that in the regular stack. So in this case, I'd 
have the script of button "first" be


on mouseUp
   doCommandFirst
end mouseUp

and I'm willing to bet that will ever change :-)


For example I have a behavior for all my datagrids. Each datagrid has a 
property called gridconstants which is an array of all the things specific to 
each datagrid. The behavior handlers will get this property so that I can use 
generic terms in the behavior like cTableName and cPriKey etc. Now my behavior 
handlers like selectionChanged and such become universal to all my datagrids. 
Only one place to edit the handlers now.


Sounds cool. If I ever use a Datagrid, I'll do that.

Alex.


If I need to do anything specific with a datagrid, I keep those handlers in 
each datagrid script.

Sent from my iPhone


On Jun 19, 2022, at 14:09, Brian Milby via use-livecode 
 wrote:

One reason would be if you were trying to use behaviors so you could manage 
your code with a repository like Git.  This would greatly reduce the number of 
behavior scripts that you would create.  One app that work on has the code in 
the stack’s behavior script.

Sent from my iPhone


On Jun 19, 2022, at 4:33 PM, Alex Tweedly via use-livecode 
 wrote:

I've noticed that in a lot of the example code I've seen recently, there's a 
bit of a common pattern.

In the card script, there will be code like

on mouseUp
  switch the short name of the target
case "first"
doCommandFirst
break
case "another"
doCommandAnother
break
case "lastnotleast"
doCommandlastnotleast
break
  end switch
end mouseUp

I've seen this in examples from Livecloud, Appli, the WebApp example from 
Steven/Michael, and a few other places.

I would generally have put this code in each button (or other control) 
directly, and I'm wondering whether there are advantages or preferences for one 
of those versus the other.

Thanks for any opinions,

Alex.


___
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

___
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


Stylistic question.

2022-06-19 Thread Alex Tweedly via use-livecode
I've noticed that in a lot of the example code I've seen recently, 
there's a bit of a common pattern.


In the card script, there will be code like

on mouseUp
  switch the short name of the target
    case "first"
    doCommandFirst
    break
    case "another"
    doCommandAnother
    break
    case "lastnotleast"
    doCommandlastnotleast
    break
  end switch
end mouseUp

I've seen this in examples from Livecloud, Appli, the WebApp example 
from Steven/Michael, and a few other places.


I would generally have put this code in each button (or other control) 
directly, and I'm wondering whether there are advantages or preferences 
for one of those versus the other.


Thanks for any opinions,

Alex.


___
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: Case sensitivity in Livecode ??

2022-06-07 Thread Alex Tweedly via use-livecode
{ Aside: any discussion where both Mark Weider and Mark Waddingham take 
part is all the better because of that; two very knowledgeable people 
with two very different viewpoints (in some areas) is a good thing. BUT 
it makes it hard to refer to what each of them said - "MarkW" is still 
ambiguous. So I'm adopting the "English public school" solution - refer 
to everyone by their surname. ]


On 07/06/2022 18:55, Mark Waddingham via use-livecode wrote:

On 2022-06-07 17:16, Mark Wieder via use-livecode wrote:

1. Because it's a function, not a constant.

function myRestLibraryGetRootUrl
    return "http://example.com/aUrlThatMightChange/api/v2;
  end myRestLibraryGetRootUrl


Here I agree with Waddingham. *IF* it's a library, then it feels right 
to have a function api.


The cases where it doesn't, to me, are those where the constants are 
intrinsic to a (widespread) part of an app or subsystem ... more below.



2. Because the server already build supports the "include" keyword
which would neatly solve the issue, but none of the other platforms
do. Why?



I don't see that 'include' does what you expect in the context of lcserver.

From the dictionary:


If you place the *constant* statement in a handler, you can use the
constant anywhere in the handler. If you place the*
constant* statement in a script outside any handler, you can use
the constant anywhere in the handlers of that
script.

The crucial phrase is the last one - "of that script". That script seems 
to be define such that the included text file is considered to be a 
different script from the main script.


So you cannot put "constant k = 17" in an included file (outside of a 
handler) and have it take effect anywhere except within the included 
file !?! And obviously if you put it inside a handle then it can only be 
used within that handler.


i.e.

include "a.txt"
    -- where a.txt contains
    -- So, afaict, 'include' and 'constant' do not combine well enough to be 
useful.



And in any case I think include is just too confusing / error-prone in 
the dynamic context of the IDE.





4. Because it gets tiresome having to explain to new developers that
you have to declare constants in multiple scripts even though it's the
same constant you already declared and the workaround is to use a
getter function as you described.


Then tell new developers that the xTalk way to do global constants is 
constant functions in the message path!



or perhaps as custom props  ?

FWIW, I'm not entirely sure whether what you (Mark) want from 'global 
constants' is quite the same as what Alex wants from 'global constants', 
and I'm not entirely sure whether what I *think* you both mean when you 
ask for 'global constants' is what you are actually thinking of when you 
ask for 'global constants'...



I'm not sure Tweedly knows properly what he wants from 'global 
constants'  :-) Maybe what I actually want would be better called 
"stack-local constants" ?



In that vein, what would be helpful is, instead of just going 'can we 
have global constants', propose problems you need to solve / would 
like to solve and use-cases you have encountered where the existing 
xTalky feature set is not sufficient to solve it in some reasonably 
elegant fashion without 'global constants'.*




"global variables" in LC have a particular meaning - they are *NOT* 
usable globally, they are only available in any script in which the 
developer has chosen to declare them.


That's a very different granularity of scope than 'available where the 
function is in the message path', and I think that higher level of 
granularity could/should/might-be-able-to-be provided for constants. As 
well as being more granular, it's also more consistent (I think) with 
'global variables'.


In my earlier email I tried to avoid the problems of dynamic re-setting 
of 'global constants' by describing them as "write-protected variables" 
or "write-once" variables - but I'm not sure if that really works.



Case :  I have a CSV or TSV file, no headers, that I read in, and 
process various ways at various times. I'd like to use (in many places 
throughout the app) snippets like


 put item kTitleColumn of tLine into myTitle
 put the text of fld "Last Name" into item kLastName of myNewLine

But I have a sneaking suspicion that at some point in the future 
additional columns will appear, or be re-arranged, or  so I won't 
use literal constant values (NOT put item 3 of ...), however some form 
of 'global constant' seems like it should work here.


There are (of course) a million ways that could be done - but none that 
I can think of provide the simplicity of usage as above, combined with 
the safety of the 'variables' being write-protected, as well as some 
form of pan-stack constants; variables which can be used (read) in the 
scope where the developer wants (by declaring as global variables), but 
are protected from inadvertent over-writing by somehow limiting 
when/where they can be written 

Re: Property Sheet for LC (was Re: Right click in field for menu)

2022-06-05 Thread Alex Tweedly via use-livecode

I'll add my thanks for such a usefull tool.

On 04/06/2022 19:38, Richard Gaskin via use-livecode wrote:


Thanks for the report. Please keep me posted if you find any other 
anomalies.



I don't know if it's an anomaly or another failing in widget support :-)

The NavBar widget has a number of properties (itemNames, itemStyle, 
hilitedItem, itemArray, ..) which are visible in the Object Inspector, 
but not in 4WProps.


Alex.


___
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: Case sensitivity in Livecode ??

2022-06-01 Thread Alex Tweedly via use-livecode


On 01/06/2022 18:05, Mark Waddingham via use-livecode wrote:


Anyway, this rather odd and obscure facet of the language will 
disappear in 10 as we've made it so that initializers for constants 
and locals can be constant expressions. Thus:


    constant kTrue = TRUE
    local sEmptyString = empty

Will do precisely what they look like they should do...


Good.

Also, you'll be able to do things like:

    constant kPiBy2 = pi / 2
    constant kPiBy2Squared = kPiBy2 * kPiBy2
    constant kPiBy2String = format("%f", kPiBy2)
    local sPiMap = { "pi-by-2": kPiBy2, "pi-by-2-sq": kPiBy2Squared }


Very good. In fact, great !! Thank you!

Would you be ale to do something like

constant kPiMap = { ... as above ... }


And now I'll push my luck and ponder the possibility of 'global' constants.

OK - 'global constant' is likely counter to the scope concepts. But 
perhaps they could be done as "write-once" variables, or as a more 
general "write-protected' variable.


e.g.

(somewhere in a start-up script ...)

   put 17 into gkMyMagicValue
   writeprotect "gkMyMagicValue"

and any *subsequent* attempt to change the value would fail.

P.S. Amusingly, your question came up on exactly the same day I 
'finished' my patch for the above - it now awaits review which may 
result in it not being quite finished ;)


Yes, coincidences do happen :-)

Thanks for the explanation Mark.

Alex.


___
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


Case sensitivity in Livecode ??

2022-06-01 Thread Alex Tweedly via use-livecode

I was surprised to find that

   constant K = TRUE

produces an error, though

  constant K = true

is fine. In other contexts, you can say

   put TRUE into myVar
   put true into hisVar
   etc.

but in a constant statement, it seems to be case sensitive.

Anyone got an interesting story (or theory) on why ?   :-)

Thanks

Alex.



___
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: A test, move along

2022-05-27 Thread Alex Tweedly via use-livecode


On 28/05/2022 00:28, Mark Wieder via use-livecode wrote:

On 5/27/22 16:03, doc hawk via use-livecode wrote:

As a professor, I’ll grade it a B-.


I thought that was a pessimistic blood type.


I thought it was short for balderdash!



___
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: Nested loops

2022-05-17 Thread Alex Tweedly via use-livecode

Direct equivalent is probably

repeat with i = 0 to myArrayLength-1
   put i-1 into j
   if j < 0 then put myArrayLength-1 into j
   .
end repeat

OR, if you prefer a single-statement version

repeat with i = 0 to myArrayLength-1
   put (i + myArrayLength-1) mod myArrayLength  into j
   .
end repeat

OR - most efficient but risky - i.e. a bad choice iMHO :-)

put myArrayLength-1 into j
repeat with i = 0 to myArrayLength-1
   .
   put i into j   -- NB at the very end of the loop body
end repeat

This is risky in case you ever do a "next repeat" inside the loop body !!

Alex.

On 17/05/2022 07:35, jbv via use-livecode wrote:

Hi list,

What is the best and most efficient way to write the following
javascript loops in LC ?

for (let i = 0, j = myArray.length - 1; i < myArray.length; j = i++) {
}

This goes beyond simple nested loops.
So far, because of lack of time, I have pre-calculated the successive
values of i and j, and have put them into lists of words :
0 1 2 3 4 5
5 0 1 2 3 4
it remains fast enough for what I need to do, but there must be a more 
elegant approach...


Thanks.
jbv

___
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: Flash Talks - 3 slots remaining

2022-04-05 Thread Alex Tweedly via use-livecode

Do you need to be in front of the running machine ?

Could you maybe video the machine going through its sequence - then 
record your voice-over later (either muting or turning down the machine 
audio, whichever is better) ?


(Or, to put it another way, I have no real idea :-) but I'm sure Heather 
can help you.


Alex.

On 05/04/2022 18:54, Craig Newman via use-livecode wrote:

How is that done? From my phone with a cameraman? The talk would only make 
sense with me in front of the running machine itself, making noise.

Craig


On Apr 5, 2022, at 1:41 PM, Andre Garzia via use-livecode 
 wrote:

I think this is very interesting. I’d love to watch a flash talk on it.

Sent from my iPhone


On 5 Apr 2022, at 18:38, Craig Newman via use-livecode 
 wrote:

Heather.

I probably am one of the oddest LC users. Entirely for either my own use or for 
my company. Only once did I sell a system commercially.

But I do use LC to control three very different machines in our shop. Would it 
be of any interest to anyone to see one of these in operation?

Regards,

Craig Newman  (dunbarx)




On Apr 5, 2022, at 12:54 PM, Heather Laine via use-livecode 
 wrote:

Dear Good Folks of the Use-list,

I'm in the final throes of scheduling our upcoming online conference on 25-27th 
April. Its looking great! Multiple fabulous talks have come in, there is loads 
of rich content, we have panels, keynotes and workshops galore! We're just 
missing 3 flashtalks to round out the Flash Talks section on Day 3. I know at 
least 3 of you good people can speak for a mere 7 minutes on your topic of 
choice. Roll up roll up... and send me a talk submission :) Pretty please?

https://livecode.com/global/apply-to-speak/ 


It's going to be a great event.

Warmest Regards to all,

Heather

P.S. Where is the conference schedule to be seen, I hear you ask? Right here:

https://livecode.com/global/schedule/

Heather Laine
Customer Services Manager and Conference Organizer Extraordinaire
LiveCode Ltd
www.livecode.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


___
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


___
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: Flash Talks - 3 slots remaining

2022-04-05 Thread Alex Tweedly via use-livecode

Sounds fascinating - I'd love to hear about that.

Alex.

On 05/04/2022 18:36, Craig Newman via use-livecode wrote:

Heather.

I probably am one of the oddest LC users. Entirely for either my own use or for 
my company. Only once did I sell a system commercially.

But I do use LC to control three very different machines in our shop. Would it 
be of any interest to anyone to see one of these in operation?

Regards,

Craig Newman  (dunbarx)




On Apr 5, 2022, at 12:54 PM, Heather Laine via use-livecode 
 wrote:

Dear Good Folks of the Use-list,

I'm in the final throes of scheduling our upcoming online conference on 25-27th 
April. Its looking great! Multiple fabulous talks have come in, there is loads 
of rich content, we have panels, keynotes and workshops galore! We're just 
missing 3 flashtalks to round out the Flash Talks section on Day 3. I know at 
least 3 of you good people can speak for a mere 7 minutes on your topic of 
choice. Roll up roll up... and send me a talk submission :) Pretty please?

https://livecode.com/global/apply-to-speak/ 


It's going to be a great event.

Warmest Regards to all,

Heather

P.S. Where is the conference schedule to be seen, I hear you ask? Right here:

https://livecode.com/global/schedule/

Heather Laine
Customer Services Manager and Conference Organizer Extraordinaire
LiveCode Ltd
www.livecode.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


___
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: CSV to TSV (was Re: Tools & techniques for one-off consolidation of multiple 'similar' CSV files?)

2022-04-05 Thread Alex Tweedly via use-livecode

Hi Keith,

that code will fail for any commas which occur within quoted entries - 
they will be wrongly converted to TABs


I'd suggest getting cvsToTab (a community effort by Richard Gaskin, me 
and a whole host of others over the years) as a good starting place, and 
perhaps finishing place. It will handle most CSV oddities (not all of 
them - that is provably impossible :-).


This does an efficient walk through the data, remembering whether it is 
inside or outside quoted entries, and hence handles commas accordingly.


https://github.com/macMikey/csvToText/blob/master/csvToTab.livecodescript

Alex.

On 05/04/2022 17:02, Keith Clarke via use-livecode wrote:

Hi folks,
Thanks all for the responses and ideas on consolidating multiple CSV files into 
- much appreciated.

Ben - Thank you for sharing your working recipe. This lifted my spirits as it 
showed I was on the right path (very nearly!) and you moved me on a big step 
from where I was stuck.

My script was successfully iterating through folders and files, with filtering 
to get a file list of just CSVs with their paths for onward processing. I’d 
also identified the need to maintain registers of (growing) column names, 
together with  a master row template and a mapping of the current file’s column 
headers in row-1 to the master to put align output columns. I got stuck when I 
set up nested repeat loops for files, then lines, then items and was trying to 
deal with row 1 column headers and data rows at the same time, which got rather 
confusing. Separating the column name processing from parsing row data made 
life a lot simpler and I’ve now got LC parsing the ~200 CSV files into a 
~60,000 row TSV file that opens in Excel.

However… I’m getting cells dropped into the wrong columns in the output file. 
So, I’m wondering if delimiters are broken in my CSV-to-TSV pre-processing. Can 
anyone spot any obvious errors or omissions in the following...
-- convert from CSV to TSV

replace tab with space in tFileData -- clear any tabs in the content before 
setting as a delimiter

replace quote & comma & quote with tab in tFileData -- change delimiter for 
quoted values

replace comma with tab in tFileData -- change delimiter for unquoted values

replace quote with "" in tFileData -- clear quotes in first & last items

set the itemDelimiter to tab

Best,
Keith

___

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: playrate & templateimage

2022-03-30 Thread Alex Tweedly via use-livecode



On 30/03/2022 22:18, Klaus major-k via use-livecode wrote:



At least on a Mac. Is this also the case on Windows?

could someone please test it and report here?
Thank you!

really noone has a minute to test? :-(


Oh, I have a minute. Unfortunately, I don't have a 'Windows".

Alex.

P.S. Actually, I think it's "fortunately I don't have a Windows" :-)


___
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: Speed up a slow loop

2022-03-09 Thread Alex Tweedly via use-livecode

Hmmm - I have to correct myself :-)

It's not 110; there are 144 digraphs on a 5x5 board

 - nine centre tiles each have 8 neighbours

 - four corner tiles each have 3 neighbours

 - twelve remaining edge tiles each have 5 neighbours

giving 72 + 12 + 60 - so 144 pairs (already including both directions 
for each adjacency).


Now if you allow edge-to-edge wrapping (i.e. from the top right tile you 
can move to the right - and find yourself back on the top left, etc.) 
then there are simply 25 * 8 pairs - but then you've moved a long way 
from genuine Boggle rules :-)


Alex.

On 09/03/2022 23:09, Alex Tweedly via use-livecode wrote:
Yes, Quentin's allowing for diagonals (that's how the number of 
digraphs on a 5x5 board gets up to 110).


And it's probably a good idea, allowing an even finer filter - if you 
aren't doing the boardwalk method..


If you do use the boardwalk to generate the exact list of words, you 
get no benefit from single-letter or digraph filtering, because the 
tree-walk is constrained to only those valid "next char"s, and so 
implicitly avoids using those non-present digraphs.


Oh - so many different ways to do things, all interesting, and all 
good for some variation of the problem.



btw - that reminds me - back when I used to play real, physical Boggle 
with friends, we often played variants of the word rules; either


 - you can reuse the same tile later in a word (e.g.
Y  L  A
X  E  T

would allow "lately" as a word.

OR

- you can double-up on a tile (e.g. M I L would allow 'mill')
(more important if you're British than if you're American :-)

Alex.



___
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: Speed up a slow loop

2022-03-09 Thread Alex Tweedly via use-livecode
Yes, Quentin's allowing for diagonals (that's how the number of digraphs 
on a 5x5 board gets up to 110).


And it's probably a good idea, allowing an even finer filter - if you 
aren't doing the boardwalk method..


If you do use the boardwalk to generate the exact list of words, you get 
no benefit from single-letter or digraph filtering, because the 
tree-walk is constrained to only those valid "next char"s, and so 
implicitly avoids using those non-present digraphs.


Oh - so many different ways to do things, all interesting, and all good 
for some variation of the problem.



btw - that reminds me - back when I used to play real, physical Boggle 
with friends, we often played variants of the word rules; either


 - you can reuse the same tile later in a word (e.g.
Y  L  A
X  E  T

would allow "lately" as a word.

OR

- you can double-up on a tile (e.g. M I L would allow 'mill')
(more important if you're British than if you're American :-)

Alex.



___
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: Speed up a slow loop

2022-03-08 Thread Alex Tweedly via use-livecode


On 08/03/2022 07:27, Neville Smythe via use-livecode wrote:

I believe there were two problems: a) the original search search algorithm was 
too slow, and b) when implemented on certain devices the app went into an 
unusable state. Both problems were caused by the wordlist being stored being 
too large (275K words for a file size of  2.5 MB). The second issue we are 
pretty sure was Virtual Memory swap space thrashing.


I guess I'm not convinced about VM space thrashing being the problem, 
certainly not due to the wordlist. It's 2.5 Mb - i.e. 0.02% of the real 
RAM in a Pixel 5. There may be something else in the app making the 
total VM space very large - but the wordlist wouldn't do it on its own.




An alternative is to use an sqlite database, always an option which should be 
considered when handling large data. This completely removes the issue of 
having the wordlist in memory, and at the same time provides an extremely fast 
search engine, so was worth exploring as a solution to both problems.  Storing 
the words in a db single table with an index on initial letter and word length, 
or as lots of tables, one for each initial and length (!), both return a result 
for a search for a word in a small fraction of a millisecond, so definitely 
this would be a viable solution which would handle all letter distributions.
Sounds cool. I'd like to see an example of how this would be created and 
used (I'm very much a SQL novice).

There is however a downside: both methods produce a db file size of 7.1 MB for 
the SOWPODS wordlist, which rather bloats the app footprint, even when you 
discount the text file version of the wordlist which no longer needs to be 
stored.
You could do the opposite. Store the wordlist (700Kb compressed), and 
decompress/populate into the SQLite database on initial run.

But now, speaking of databases, I have a question. I have an update to my 
nsScriptDatabase stack which I want to upload to the Sample Stacks. Because it 
really should be compiled to a standalone, I really need to upload a pair of 
stacks, a launch stack and one to hold data which can one modified by the user. 
But it would seem a sample stack must be a single item. What to do?


Yep -this is a big drawback of the Sample Stacks system.

Maybe you could make a single app, which contains the two desired stacks 
as custom props.


(Sometimes it's easier to type code than to describe it :-)
In your preparation, you'd do:
 put URL ("binfile:launchstack.livecode") into tmp
 set the cLaunch of me to compress(tmp)
 put URL ("binfile:userdatastack.livecode") into tmp
 set the cUser of me to compress(tmp)

And then when the user downloads your sample stack, it does the inverse 
to create the two local stacks, with an info box telling them about it.


Alex.

___
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: Speed up a slow loop

2022-03-07 Thread Alex Tweedly via use-livecode



On 06/03/2022 22:56, J. Landman Gay via use-livecode wrote:


The board walk took 179 ms for all 108 words because I ditched my old, 
juvenile, inefficient code and swiped yours. :) As Bill requested, 
I've marked all the stuff I used with credits for the people who 
suggested or provided code, so you're in there. The two most impactful 
changes were your board walk and Quentin's filtered dictionary idea, 
but there are also other improvements.


Oh, well, if you've got the fast boardwalk code in there anyway, that 
opens up another possibility (with one caveat).


The boardwalk will find all valid words on the board. So that list of 
words can be used as the "dictionary" for the user's guesses - and now 
you have a "dictionary" of only a few hundred words, rather than than 
the many thousands of either the original or the filtered dictionaries.


And it's worth saying that the fast boardwalk only explores those 
potential words that are on the board, so there's no need to filter the 
dictionary for it.


The caveat - a user guess which isn't in the word list found by the 
boardwalk can be either "not a word" or "a word, but not present on the 
board", and you don't know which. If your UI needs to distinguish 
between those cases, you'd need to do another step of checking these 
(hopefully very few) failure cases against the full dictionary.


Alex.


___
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: Speed up a slow loop

2022-03-06 Thread Alex Tweedly via use-livecode
Another thought on this problem; I think worth discussing even if the 
various suggestions so far have already got you a solution. I think it's 
a general observation ...


You don't really care how long it takes to do this.
What you care about is how long the user has to wait for your (the 
app's) response.


So don't wait until the user has found all their possible words (i.e. 
the app is doing effectively nothing for the 30 seconds or so that the 
user gets for each board). Check each word as they type it, and store 
the result. Then, when the 30-sec timer is up, you will have only one or 
two last words to test - all the others have already been checked.


So you never care about how long it takes to check 50 or so words 
against the dictionary - you check 49 of them one-at-a-time during the 
time you are otherwise idle. And the user has only to wait for the 
negligible delay while you check one or two words.



Alex.


___
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: Speed up a slow loop

2022-03-06 Thread Alex Tweedly via use-livecode


On 06/03/2022 06:35, J. Landman Gay via use-livecode wrote:


Combined with Ken's suggestion to use "difference", looking up a list 
of about 50 words in the filtered dictionary reduces the time from 2-4 
seconds to about 40 ms. It varies, depending on a lot of things, but 
it's fast enough that you don't notice. That's on my Pixel 5; on the 
Mac a lookup takes 5ms. And I can do it all in LC script.



5ms !?!

I did a (very simple) test  (see code below)

 - take the whole sowpods.txt file (267k words)

 - create a set (i.e. split by CR as set)

 - look up 50 randomly chosen words + 5 non-words (just in case failed 
searches were expensive).


Doing this 100 times takes 6-10 ms (on an old MacBook Pro).

Could you maybe post the code that you're using that takes 5ms ?


I love these little speed contests we have here. Thank you.


Alex.



on mouseup
   local tmp, tNumberOfLines, tNumberOfLoops
   local tWords, tAWords, tTries

   put the cWords of me into tWords
   if tWords is empty then
  put URL ("file:" & specialfolderpath("resources") & 
"/sowpods.txt") into tWords

  set the cwords of me to tWords
  put "From file"  into fld "F"
   else
  put "using custom property"  into fld "F"
   end if

   put tWords into tAWords
   split tAWords by CR as set

   repeat with I = 1 to 50
  put random(the number of lines in tWords) into tmp
  put line tmp of tWords  after tTries
   end repeat
   repeat with I = 1 to 5
  put "azazaz"  after tTries
   end repeat

   put 100 into tNumberofLoops

   local t1, t2, tCount, tTotal

   --   put the millisecs into t1
   --   repeat tNumberOfLoops times
   --  put 0 into tCount
   --  repeat for each line L in tTries
   -- if L is among the lines of tWords then add 1 to tCount
   --  end repeat
   --   end repeat
   --   put the millisecs into t2
   --   put tCOunt && "iterate lines" && t2-t1  after fld "F"

   put the millisecs into t1
   repeat tNumberOfLoops times
  put 0 into tCount
  put 0 into tTotal
  repeat for each line L in tTries
 add 1 to tTotal
 if tAWords[L] then add 1 to tCount
  end repeat
   end repeat
   put the millisecs into t2
   put tCount && "of" && tTotal && "each element" && t2-t1  after 
fld "F"



end mouseup



___
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: Chart widget and axes which are time values.

2022-02-25 Thread Alex Tweedly via use-livecode

Sorry Scott, I can't be of any help.

I hadn't tried anything like that before - and trying it in response to 
your email, I have no success at all; cannot get a transparent 
background. So maybe a mild confirmation that there's a problem, but 
nothing better than that.


Alex.


On 23/02/2022 02:23, scott--- via use-livecode wrote:

Alex, I’m replying off list because my ulterior motive is to ask you a question.

Argh.  I see, after re-reading your post, that my remarks are useless.

I’ve been spending a bit of time trying to replace my old chartsEngine library with the 
new chart widget. I haven’t tried any of the commands that wrap JSON. So, ultimately I 
have no answer to your question. I’ve used the more simplistic COMMA delimited [ set the 
csvData of widget "Chart" to tCSVData ].  (The TAB delimited one seems to work 
also.)

One thing that sometimes made a difference about what displayed was using: [ set the 
lockChartUpdates of widget "Chart" to “true” ] before messing with the widget and then [ 
set the lockChartUpdates of widget "Chart" to “false” ] when I was done.

I suspect that you have tried this already but...

Using [ put 
"cats"&"19"&"dogs"&"12"&&"gerbils"&"5"&&"wombats"&"9"
 into tCSVData ]  puts “cats, dogs, gerbils and wombats” along the X-axis for me.

I found that:  [ set the dataLabels of widget "Chart" to 
"Cats,Dogs,Gerbils,Wombats” ]  would also set the X-axis labels if it matched up with the 
number of data points.


My question for you, since you’ve been messing with the widget, is about 
setting the alpha / transparency of the chartBackgroundColor property. Only one 
time have I seen it work as expected from the property inspector and never have 
I been able to produce a transparent background by script. I was wondering if 
you had tried this property. (I posted about this in bugzilla and the 
mothership asked me to create a separate bug report because it worked fine for 
them… I don’t have a problem creating a bug report, it just seemed odd that it 
absolutely doesn’t work for me.)

--
Scott Morrow

Elementary Software
(Now with 20% less chalk dust!)
web   https://elementarysoftware.com/
email sc...@elementarysoftware.com
booth1-360-734-4701
mobile   1-360-920-0715
--





On Feb 22, 2022, at 5:54 AM, Alex Tweedly via use-livecode 
 wrote:

I've been trying to use the new chart widget, but no success yet.

All the charts I want to do have times (or dates) along the X axis.

I can see that any options which have not been wrapped in LC can be set by 
doing something like:

put the chartJSONOptions of widget "mine" into tA
put "time" into tA["scales"]["x"]["type"]
set the chartJSONOptions of widget "mine" to tA

but this still gives me

 Error: This method is not implemented:
 Check that a complete date adapter is provided.


and I have no idea how to provide a date adapter from LC.

Has anyone else tried date/times with more success ?

(The chart.js documentation implies there is a default adapter - so nothing 
should need to be done. It also talks about installing JS libraries for other 
adapters - but I don't quite get it).

Thanks,

Alex.


___
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


___
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


Chart widget and axes which are time values.

2022-02-22 Thread Alex Tweedly via use-livecode

I've been trying to use the new chart widget, but no success yet.

All the charts I want to do have times (or dates) along the X axis.

I can see that any options which have not been wrapped in LC can be set 
by doing something like:


   put the chartJSONOptions of widget "mine" into tA
   put "time" into tA["scales"]["x"]["type"]
   set the chartJSONOptions of widget "mine" to tA

but this still gives me

    Error: This method is not implemented:
    Check that a complete date adapter is provided.


and I have no idea how to provide a date adapter from LC.

Has anyone else tried date/times with more success ?

(The chart.js documentation implies there is a default adapter - so 
nothing should need to be done. It also talks about installing JS 
libraries for other adapters - but I don't quite get it).


Thanks,

Alex.


___
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: Creating a simple menu

2022-01-08 Thread Alex Tweedly via use-livecode



On 08/01/2022 13:14, Alex Tweedly via use-livecode wrote:


I think you mean "[...] menu is not an option in the list of styles in 
the dictionary".


I meant to say "in the list of styles in the drop-down list, although it 
is in the dictionary"


Hope that wasn't confusing.

Apart from that, the answer remains  can be done in script or msg box.

Alex.


___
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: Creating a simple menu

2022-01-08 Thread Alex Tweedly via use-livecode

caveat - I've never done any of this in real life :-)

On 08/01/2022 03:41, David Squance via use-livecode wrote:

Hi all,
I want to create a mock-up of a web site, so some menus are required. It’s 
something I’ve done very little with, and the last was years ago. I’m an 
infrequent  LC user, anyway, though have dabbled with it since it’s beginnings. 
According to the User Guide (this with version 10):

Button Menus

You can create a button menu by dragging out one of the menu controls from the tools 
palette. However,if you want to create one by script, the easiest is to create a button 
and set the style of the button to "menu". Next, you can set the menuMode of 
the button to the appropriate menu type. You can either set the menuMode in a handler, or 
use the Type menu in the button's property inspector to set the menu type.


However, if I create a button, menu is not an option in the list of styles.


I think you mean "[...] menu is not an option in the list of styles in 
the dictionary".


But in a script (I did it in the message box), you can do

set the style of button "bbb" to "menu"

and it does change the style, and subsequent 'put the style of btn 
"bbb"' does say 'menu', so I think it has worked.



And what do the “menu controls” in the tools palette look like?

Sorry, no idea.


I’m sure I’m missing something pretty basic, but I am definitely missing it. I 
guess I can copy and paste a menu button from an old stack, and change its 
attributes, or work around it with a bunch of hidden buttons, but there must be 
a more streamlined approach than that.


afaict, you can indeed do what you need in a script - set the style, 
etc. - and once you've done that, you then get different options in the 
Property Inspector.


Alex.


___
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


ANN: BoggleSolver now on sample stacks

2022-01-02 Thread Alex Tweedly via use-livecode

I've put a little 'game' up on "sample stacks", and also on the web.

It "solves" Boggle style puzzles, i.e. you give it a 5x5 grid of 
letters, and it finds all words within it, following the prescribed 
rules - words are formed by moving to adjacent (including diagonal) grid 
positions, and you cannot re-use a grid position within a word. You can 
modify the input field, and click on "Solve it" to see the new results.


The list of words is that used by Jacqueline in her JQBoggle game.

The UI is very basic - but there is one clever (I think) thing within 
it. It uses a dictionary of words which is a hierarchical 
character-by-character array, so it represents not only "what is a word" 
but also "what can be the initial substring of a word", and therefore it 
can prune the search tree immediately. This takes the time to solve a 
puzzle down from approx 10 - 50 minutes using a simple dictionary, to 
around 40 millisecs.


NB I have also built a Web-based standalone version of it using 10.0.0 
(dp1), which can be found at


https://www.tweedly.org/BoggleSolver/BoggleSolver.html

Note - the "Load URL ..." portion does not yet work in the web version. 
Loading is fairly slow, but the run times re (IMHO) impressive - 80msecs 
against the 40msecs or so running in the IDE. I am very impressed by the 
performance of this early web implementation.


Having a 'solver' like this opens up possible new games such as:

1. given we have 25 grid positions, and 25 letters (omitting 'Q'), what 
arrangement of letters gives the most, or least, words.


2. given a random selection of letters, what arrangement gives 
most/least words.


3. (a 2-player game) given an arrangement of letters, change one letter 
and increase the number of words that can be formed; score the value of 
the increase (or decrease), playing alternately, until neither player 
can get a positive score change.


Alex.


___
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


  1   2   3   4   5   6   >