Re: [semi OT] mySQL question

2023-05-11 Thread Ken Ray via use-livecode
I would recommend a table for People, a table for Companies, and a table for 
Employment that acts as a linking table between the first two. Something like 
(at its simplest):

people

id  INT(11)
first_name  VARCHAR(255)
last_name   VARCHAR(255)


companies
===
id  INT(11)
nameVARCHAR(255)


employment

id  INT(11)
person_id   INT(11) 
company_id  INT(11)
job_descrip VARCHAR(255)


To get a list of everyone that worked at a particular company, you'd do:

SELECT * FROM people
INNER JOIN employment ON (people.id = employment.person_id)
INNER JOIN companies ON (employment.company_id = companies.id)
WHERE companies.name="XYZ, Inc."

To get a list of all companies where a person has worked, you'd do:

SELECT * FROM companies
INNER JOIN employment ON (companies.id = employment.company_id)
INNER JOIN people ON (employment.person_id = people.id)
WHERE people.first_name="John" AND people.last_name="Smith"

Make sure to index the 'id' and '_id' columns, and you can use the 
employment.job_descrip to hold info on the particular job an individual had at 
a specific company.

This is all off the top of my head, so it may need a little massaging, but you 
get the idea.


Ken Ray
Sons of Thunder Software, Inc.
Email: k...@sonsothunder.com
Website: https://www.sonsothunder.com


> On May 11, 2023, at 9:55 AM, jbv via use-livecode 
>  wrote:
> 
> Hi list,
> 
> This is a question for mySQL experts, which I am not.
> 
> I have a table of individuals.
> I have another table of companies.
> 
> Many individuals have worked in more than 1 company with
> different jobs descriptions.
> 
> I need to build my DB so that, with single requests, I
> can get a list of either :
> - all individuals who worked in a specific company with
> the job description of each one
> - all companies in which a specific individual has worked,
> along with the job description he had in each company.
> 
> The main problem is that the tables might become huge with
> the time (several Gb), so searching the tables might take
> forever if not carefully built.
> 
> I guess I will need to use a third table for the job descriptions
> and a combination of fulltext indexes and foreign keys
> might do the trick, but my limited skills don't allow me
> to find the best solution...
> 
> Any help will be much appreciated.
> 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: ChatGPT

2022-12-20 Thread Ken Ray via use-livecode
I just tried it and got this instead:

-
ME: Write a calendar app in livecode

CHATGPT:

To create a calendar app in LiveCode, you will need to use the LiveCode 
programming language and the LiveCode development environment. Here is a 
step-by-step guide to help you get started:

1. Open LiveCode and create a new stack.
2. Design the layout of your calendar app. You can use LiveCode's 
built-in layout tools to create a grid of squares representing the days of the 
month, as well as buttons for navigating between months and years.
3. Use LiveCode's control structures and looping statements to create 
the logic for displaying the current month and year, and for navigating between 
months and years.
4. Add functionality to highlight the current day and to display events 
for each day. You can use LiveCode's data structures, such as lists and arrays, 
to store the events for each day.
5. Use LiveCode's built-in date and time functions to help with the 
calendar calculations, such as determining the number of days in a given month 
and the day of the week for a given date.
6. Test your calendar app thoroughly to ensure that it is working as 
expected.
7. Customize the appearance of your calendar app using LiveCode's 
graphics and styling features.

I hope this helps! Let me know if you have any questions or need further 
guidance.
-

Amazing!

Ken


> On Dec 9, 2022, at 3:54 PM, Jim Lambert via use-livecode 
>  wrote:
> 
> Even more interesting I issued the same chat request a few hours later and 
> got an entirely different coding approach. 
> It even helpfully put the code into formatted, copy-able blocks. (formatting 
> not shown here.)
> 
> ME: Write a calendar app in livecode
> 
> CHATGPT:
> Here is an example of how you could implement a simple calendar app in 
> LiveCode:
> 
> Copy code
> -- Set the default date to the current date put the short date into 
> currentDate 
> 
> -- Create the calendar UI 
> create calendar 
> set the date of calendar to currentDate 
> set the rect of calendar to the rect of this card  
> 
> -- Function to handle date changes in the calendar 
> on dateChanged pNewDate 
> put pNewDate into currentDate 
> end dateChanged
> 
> This script creates a calendar widget and sets its default date to the 
> current date. It also defines a dateChanged handler that is called whenever 
> the selected date in the calendar changes. In this handler, the currentDate 
> variable is updated with the new selected date.
> 
> You can then add other UI elements and functions to your app to allow the 
> user to view and manage events for the selected date. For example, you could 
> add a list widget to display the events for the current date, and buttons to 
> add and remove events.
> 
> Here is an example of how you could add a list widget to display the events 
> for the current date:
> 
> Copy code
> -- Create a list widget to display the events for the current date 
> create field "eventsList" 
> set the rect of "eventsList" to 100,100,200,200 
> set the text of "eventsList" to "No events for this date" 
> 
> -- Function to update the events list 
> on updateEventsList 
> -- Clear the events list 
> put empty into field "eventsList" 
> 
> -- Retrieve the events for the current date from a database or file 
> put the events for currentDate from database or file into events 
> 
> -- Add the events to the list 
> repeat for each event in events 
> put event & cr after field "eventsList"
> end repeat 
> end updateEventsList
> 
> This script creates a list widget called eventsList, and defines an 
> updateEventsList function that retrieves the events for the current date from 
> a database or file and adds them to the list.
> 
> You can then call the updateEventsList function whenever the date in the 
> calendar changes, so that the list of events is updated to show the events 
> for the new selected date. You can do this by adding the following code to 
> the dateChanged handler:
> 
> Copy code
> on dateChanged pNewDate 
> put pNewDate into currentDate 
> updateEventsList 
> end dateChanged
> 
> You can also add buttons to allow the user to add and remove events. For 
> example, you could add the following code to create "Add" and "Remove" 
> buttons and define the corresponding event handlers:
> 
> Copy code
> -- Create "Add" and "Remove" buttons
> 
> But, of course, this code doesn't actually work. But it could be re-written 
> to work.
> 
> JimL
> ___
> 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

Ken Ray
Sons of Thunder Software, Inc.
Email: k...@sonsothunder.com
Website: https://www.sonsothunder.com




___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this 

Re: Speed up a slow loop

2022-03-03 Thread Ken Ray via use-livecode
BTW you an also use this "split" trick to remove dupes (although you lose the 
order of the word list):

function stripDupes pWordList
  split pWordList by cr and tab
  return (the keys of pWordList)
end stripDupes

on mouseUp
   put stripDupes("test" & cr & "ball" & cr & "test" & cr & "orange")
end mouseUp

Result:
ball
orange
test

Not sure if it's faster, but it may work in your situation,

Ken


> On Mar 3, 2022, at 2:28 PM, J. Landman Gay via use-livecode 
>  wrote:
> 
> On 3/3/22 12:53 AM, Mark Waddingham via use-livecode wrote:
>> If the difference between `the milliseconds` before the loop, and then after 
>> is 0 or 1 millisecond - then that is how long it is taking. This means the 
>> issue is somewhere else. Are you sure there isn't anything you are doing 
>> either before that loop or after that loop which doesn't wait for ages (due 
>> to the ANRs you mentioned).
> 
> Today I'm getting slightly faster results. Repeatedly creating new boards is 
> not slowing down. Maybe some background processes were stopped (there was a 
> system update last night.)
> 
> The scoring handler does three things with the user word list, calling out to 
> 3 different handlers:
>  1. Remove any duplicates
>  2. Check the dicionary for the remaining words
>  3. Walk the board for each word to ensure it's a legal path
> 
> I just ran tests with LC 9.6.6 on a Pixel 5 that timed each callout 
> independently. Times are in milliseconds. No words were longer than 4 letters.
> 
> Dupes Dictionary Boardwalk word counts
> 12   1954   1404   -- 5 wds + 2 dupes, 2 illegals (total 9)
> 1   1934   2542   -- 9 wds, all legal
> 0   1960   1966   -- 7 wds + 2 illegals (total 9)
> 0   1921   1142   -- 4 wds, all legal
> 17   2015   8321   -- 30 wds + 1 dupe, 1 illegal (total 32)
> 
> My recursive board walk could probably be optimized but for now I'm just 
> focusing on the dictionary lookup. For reference, here is the whole handler:
> 
> function checkDictionary pList -- plist is the user words
>  repeat for each line l in pList
>if sDictFile[l] = true then put l & cr after tCheckedList
>else put l & cr after tNonWords
>wait 0 with messages  -- prevent ANRs
>  end repeat
>  set wholematches to true
>  put fld "wordList" into tWList -- no longer the same as pList since 
> removeDupes has already run
>  repeat for each line l in tNonWords -- mark non-words in list
>set the textcolor of line lineoffset(l,tWList) of fld "wordList" to "red"
>  end repeat
>  if tNonWords <> "" then put tNonWords into sStats["unknowns"] -- for later 
> display
>  return tCheckedList
> end checkDictionary
> 
> I suppose the delay could be updating the field? But updating a field for 2 
> or 3 entries shouldn't take too long, should it? Also note that in the 2 runs 
> where there were no illegals, the timings didn't vary much. The checkDupes 
> handler also colorizes duplicate words, which is why those 2 runs have longer 
> times.
> 
>> If there are only 3 reasonable length words in pList (I.e. 3 lines) then 
>> there's no way that loop can take 4 seconds.
> 
> When testing I don't have patience to think, so all words are usually 3-4 
> letters each.
> 
> 
>>> Even stranger: on my cheapo Android tablet with 4 megs of RAM running
>>> Android 9 the response is nearly instantaneous, even if the user list
>>> has 200+ words. On my Pixel phone with 8 megs of RAM and Android 12
>>> the response is slow enough to trigger the ANR with only 3 words. I'm
>>> building for ARM 64.
>> This strongly suggests it is something else either on your phone, or in your 
>> code which your phone doesn't like I think.
> 
> I have two Pixels, a 5 and a 6, and they both behave the same (slow) way, 
> though the 6 has the new Tensor chip. Yesterday I was wondering if the delay 
> isn't the calculations but rather the screen redraws. I have a lot of 
> controls stacked up on the card, though many are not visible. However, I've 
> run the handlers with the screen both locked and unlocked with no changes.
> 
> -- 
> Jacqueline Landman Gay | jac...@hyperactivesw.com
> HyperActive Software   | http://www.hyperactivesw.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

Ken Ray
Sons of Thunder Software, Inc.
Email: k...@sonsothunder.com
Website: https://www.sonsothunder.com




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


Re: Speed up a slow loop

2022-03-03 Thread Ken Ray via use-livecode
Jacque,

How about using the 'difference' command? Here's a simple example:


on mouseUp
   put "true" into tDict["test"]
   put "true" into tDict["word"]
   put "true" into tDict["ball"]
   
   put "test" & cr & "ball" & cr & "boat" & cr & "unicorn" into tUserWords

   split tUserWords by cr and tab
   difference tUserWords with tDict
   
   if tUserWords is not an array then
  answer "All words matched!"
   else
  answer "Sorry, try again, these words didn't match:" & cr & cr & (the 
keys of tUserWords)
   end if
end mouseUp

If you run this, it will say that "boat" and "unicorn" don't match; if 
tUserWords is "test" and "ball" you get "all words matched".

Will this work?


Ken



> On Mar 3, 2022, at 2:34 PM, J. Landman Gay via use-livecode 
>  wrote:
> 
> On 3/3/22 2:00 PM, Tom Glod via use-livecode wrote:
>> But what prevents you from loading all your data into an array?  and just
>> iterating over the keys or index of an array?  vs the lines of a long list.?
>> That will yield the fastest performance.
> 
> Right, it's an array, and I don't iterate. I just check the array key 
> directly for a value.
> 
> I realize I'm kind of monopolizing things here. I wrote the game for myself 
> and I ignored the speed issues and just played it on my tablet where it works 
> fine, but now someone else wants to include it in a distributed app so I need 
> to figure it out.
> 
> -- 
> Jacqueline Landman Gay | jac...@hyperactivesw.com
> HyperActive Software   | http://www.hyperactivesw.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

Ken Ray
Sons of Thunder Software, Inc.
Email: k...@sonsothunder.com
Website: https://www.sonsothunder.com




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


Re: lineOffset wildcard

2021-04-19 Thread Ken Ray via use-livecode
> On Apr 19, 2021, at 1:47 PM, Mark Wieder via use-livecode 
>  wrote:
> 
> On 4/19/21 11:04 AM, J. Landman Gay via use-livecode wrote:
> 
>> I don't think lineoffset supports wildcards, but you could do it with 
>> matchChunk.
> 
> Ah! matchChunk and the the number of lines of... etc...
> That should do it.

Another way to do it is to use 'filter' to get the text of the line that 
matches your wildcard, and then 'lineOffset' to find that line:

put tScript into tTemp
filter tTemp with ("local*" & tFunctionName & "*")
put lineOffset((cr & tTemp & cr),(cr & tScript & cr)) into tPos

Not sure if 'filter' is faster than 'matchChunk' when dealing with large 
scripts, but I have a feeling it might be...


Ken Ray
Sons of Thunder Software, Inc.
Email: k...@sonsothunder.com
Website: https://www.sonsothunder.com




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


Re: We don't need a Player (was Re: New(?) Idea for Standalones)

2021-04-13 Thread Ken Ray via use-livecode


> On Apr 13, 2021, at 5:28 AM, Andre Garzia via use-livecode 
>  wrote:
> 
> I like all that I read here. There are things that are really hard when 
> building standalone apps that I don’t think should be handled by LC HQ, such 
> as “adding AppleScript dictionary” to your app. This is harder than it seems 
> and it involves plist manipulation, fancy sdef xml creation, etc. This is too 
> large a product to develop with a small target base.
> 
> On the other hand, I think that the SB should create standalones that can 
> actually be deployed, this means that it should be able to handle 
> notarisation on the mac out-of-the-box.

Amen, brother! 

:)


Ken Ray
Sons of Thunder Software, Inc.
Email: k...@sonsothunder.com
Website: https://www.sonsothunder.com




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


Re: sort container parameters

2021-03-03 Thread Ken Ray via use-livecode
Craig,

It's because when you try to sort something, it's got to be a variable that's 
being sorted. So all of the examples you used put "toSort" into the statement 
to be "done" coming out compiled as:

sort items of "A,C,T,B" ascending

... which won't work. You need to execute:

do "sort items of toSort" && sortDir

which compiles to:

sort items of toSort ascending

... and that works.

:)


Ken Ray
Sons of Thunder Software, Inc.
Email: k...@sonsothunder.com
Website: https://www.sonsothunder.com


> On Mar 3, 2021, at 12:23 PM, Craig Newman via use-livecode 
>  wrote:
> 
> I thought I was pretty clever at using “do”, often going down several levels, 
>  evaluating the whole way before trying to execute a single  “do” statement.
> 
> Neither of the last lines seem to work:
> 
> on mouseup
> 
> put "A,C,T,B" into toSort
> 
> put "ascending" into sortDir
> 
> get "sort items of" && quote & toSort & quote && sortDir
> 
> breakpoint
> 
> --do it
> 
> --do "sort" && toSort && sortDir
> 
> do "sort" && quote & toSort & quote && sortDir
> 
> end mouseup
> 
> 
> I feel there must be a way…
> 
> Craig
> 
> 
>> On Mar 2, 2021, at 7:36 PM, Alex Tweedly via use-livecode 
>>  wrote:
>> 
>> The number of lines being sorted makes o difference.
>> 
>> The number of distinct sorts will - but at a single 'do' for each of 
>> "several hundreds", you'll not even notice except (maybe) if you are 
>> benchmarking it (around 5ms per 1000 'do's on an elderly MacBook Pro).
>> 
>> Alex.
>> 
>> On 02/03/2021 22:52, Paul Dupuis via use-livecode wrote:
>>> Okay. Thank you Ralph.
>>> 
>>> I was reluctant to use "do" for performance reasons. The sort could be 
>>> sorting a large number of lines - as many as several hundred sorts of a 
>>> thousand to ten thousand lines.
>>> 
>>> I could of course do timing trials, but does anyone from the mothership (or 
>>> anyone period) know if using "do" with a container sort causes any 
>>> appreciable performance hit? All the data is in a variable (vs fields).
>>> 
>>> 
>>> On 3/2/2021 5:19 PM, Ralph DiMola via use-livecode wrote:
 I found that you must us a "Do"(thank heaven for "Do"s) if you want to 
 make variable any LC token that colorizes like "stack", "the", "field", 
 "button", "put" or "ascending".
 
 I don't think "Do" is a kludge is this case.
 
 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 Paul Dupuis via use-livecode
 Sent: Tuesday, March 02, 2021 4:56 PM
 To: use-livecode@lists.runrev.com
 Cc: Paul Dupuis
 Subject: sort container parameters
 
 I just discovered much to my dismay that you can not execute the following:
 
 put "ascending" into tDirection
 soft lines of tContainer tDirection international
 
 apparently neither the sort direction (ascending|descending) nor the sort 
 type (international|text|datetime|numeric|binary) can be variable!
 
 That means if you want to parameterize a sort direction, you have to do 
 something like:
 
 if tDirection is "ascending" then
sort lines of tContainer ascending international else
sort lines of tCOntainer descending international end if
 
 I see this a a bug or perhaps a failure to fully robust impliment the sort 
 container command? Does any one else see this as a bug?
 
 I suppose I could work around it with a "do" but that seems like a cludge
 
 do ("sort line of tContainer" && tDirection && tSortType)
 
 Thoughts? Comments? Opinions? Am I expecting too much of LiveCode to have 
 sort direction and type actual parameters?
 
 
 ___
 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: "within graphic" question

2021-02-22 Thread Ken Ray via use-livecode
If you're willing to do something "hackish", you could do this:

on mouseDown
  lock screen
  show grc "mygraphic"
  put within(grc "mygraphic",the clickloc)
  hide grc "mygraphic"
  unlock screen
end mouseDown

:D

Ken


> On Feb 22, 2021, at 1:49 PM, jbv via use-livecode 
>  wrote:
> 
> Hi list,
> 
> I have a graphic made of a list of points. This graphic is opaque
> and invisible, its filled property is set to true (according to
> the doc).
> In my card script I have something like :
> on mousedown
>  put within(grc "mygraphic", the clickloc)
> end mousedown
> 
> but it always returns false, even when I click
> inside the clickable area of the graphic...
> What am I missing ?
> 
> Thanks 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: How to find the offset of the first character in a string that's not a tab?

2021-01-22 Thread Ken Ray via use-livecode


> On Jan 21, 2021, at 8:36 AM, Keith Clarke via use-livecode 
>  wrote:
> 
> Thanks Brian. I looked at matchChunk in the dictionary & it seems to return a 
> boolean, rather than the offset. 

The boolean is just whether or not the matchChunk operation was successful; you 
need to provide variables for the start and end character offsets in the 
function call:

if matchChunk(myString,"([^\t])",tStart,tEnd) then
  put "The offset to the first non-tab character is:" && tStart
else
  -- matchChunk had an error because the regex was bad or something
end if

I know you've moved on, but just for the record...

:D


Ken Ray
Sons of Thunder Software, Inc.
Email: k...@sonsothunder.com
Website: https://www.sonsothunder.com


> 
> Thanks all - I’ve stopped trying to find the syntax for ‘find any char but 
> this’ in offset and instead, taken Dick’s advice to iterate through the chars 
> and count the loops until char <> tab. :)
> Best,
> Keith 
> 
>> On 21 Jan 2021, at 14:03, Brian Milby via use-livecode 
>>  wrote:
>> 
>> You could also use matchChunk with a regular expression that excludes the 
>> tab character.
>> 
>> Sent from my iPhone
>> 
>>> On Jan 21, 2021, at 7:14 AM, Keith Clarke via use-livecode 
>>>  wrote:
>>> 
>>> Ah yes indeed, I’d forgotten I could test with 'put not(tab)’ in the 
>>> message box - that certainly proves the syntax was wrong! :-)
>>> Best,
>>> Keith
>>> 
> On 21 Jan 2021, at 10:49, Dick Kriesel via use-livecode 
>  wrote:
> 
> 
> 
>> On Jan 21, 2021, at 2:34 AM, Keith Clarke via use-livecode 
>>  wrote:
> 
> I was just keen to understand why offset wasn’t happy with the ‘not(tab)’ 
> in this instance.
 
 expression "not(tab)" evaluates to true, which doesn’t serve your purpose
 
 — Dick
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your 
 subscription preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode
>>> 
>>> ___
>>> 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: return "error" code from standalone compile

2020-12-11 Thread Ken Ray via use-livecode
Wow... I've been using Livecode since its inception (and Revolution before 
that, and even MetaCard before *that*!), and I never knew this existed!

Just goes to show that there's always something new to learn about our favorite 
development tool. 

(I wonder if anyone's put together a "list of things Livecode can do that you 
probably didn't know about" ?)

:D


Ken Ray
Sons of Thunder Software, Inc.
Email: k...@sonsothunder.com
Website: https://www.sonsothunder.com


> On Dec 10, 2020, at 11:51 AM, Douglas A. Ruisaard via use-livecode 
>  wrote:
> 
> I use AUTOHOTKEY... as a fast, dirty way to "get stuff done" when I'm either 
> too lazy or too rushed to do a "quality" job with Livecode.  It has a command 
> called "Run" & "Runwait" ... which returns the calling program's (Livecode 
> executable, in this case) return code into a predefined variable called 
> "ErrorLevel" (how original!).  So a line in a AUTOHOTKEY script for this 
> would look like:
> 
>   cmd = c:\livecode\SomeLiveCode.exe
>   RunWait, %cmd%,,UseErrorLevel
>   exitcode := ErrorLevel
>   if (exitcode > 1)
> 
> Autohotkey takes some getting used to but I think it's a handy addition to 
> development projects.. since AHK scripts can be compiled into executables, 
> themselves.
> 
> My 4.5 cents
> 
> Douglas Ruisaard
> 
>Trilogy Software
>  (250) 573-3935
> 
> 
> -Original Message-
> From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On Behalf 
> Of John Balgenorth via use-livecode
> Sent: Thursday, December 10, 2020 4:03 AM
> To: How to use LiveCode
> Cc: John Balgenorth
> Subject: Re: return "error" code from standalone compile
> 
> Since Livecode is written in C++ here is some
> info about using return  in  C.
> 
> Every C program has a function named main.   At the
> end of the function the programmer usually writes a
> return 0;
> 
> That tells  the c  program the code has  completed
> and is exiting with  a  0 value which confirms it  has
> successfully executed the code and is quitting.
> 
> At any point above that line the programmer can  write
> a return call  but they will usually use a 1  on another
> value.  The program will exit the code at that point  and
> it does not matter what value is entered after the  return
> but 1 usually means the code failed and any other value
> but 0 means anything you want it to mean.
> 
> JB
> 
> 
>> On Dec 9, 2020, at 8:52 PM, J. Landman Gay via use-livecode 
>>  wrote:
>> 
>> I don't know much about this but it looks interesting. Is there a list of 
>> exit codes somewhere? When the OS receives the exit code, what happens? 
>> I.e., how would I use it?
>> --
>> Jacqueline Landman Gay | jac...@hyperactivesw.com
>> HyperActive Software | http://www.hyperactivesw.com
>>> On December 9, 2020 7:48:10 PM Mark Wieder via use-livecode 
>>>  wrote:
>>> 
 On 12/9/20 5:32 PM, Douglas A. Ruisaard via use-livecode wrote:
 On the completion of a stack, can the compiled executable return an error
 code like the old DOS ErrorLevel value(s)?  If so, how do you specify the
 error code?  in the on closeStack call?
>>> 
>>> See the quit command in the dictionary.
>>> 
>>> quit 42
>>> 
>>> --
>>> 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
> 
> 
> ___
> 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: Naive XML questions

2020-10-25 Thread Ken Ray via use-livecode
Graham, here's the basic approach (assuming your XML is in the variable 'tXML'):

put revXMLCreateTree(tXML,false,true,false) into tTreeID
put  "/gpx/trk/trkseg/trkpt[1]" into tNode  -- the brackets identify 
the instance of "trkpt" to work with
put revXMLAttribute(tTreeID, tNode,"lon") into tLonValue
put revXMLNodeContents(tTreeID,(tNode & "/ele")) into tEleValue
put tLonValue && "/" && tEleValue

>> 2.128369 / 169.623637

So to work with the third instance of "trkpt", you'd do:

put  "/gpx/trk/trkseg/trkpt[3]" into tNode

Hope this helps,

Ken


> On Oct 25, 2020, at 12:21 PM, Graham Samuel via use-livecode 
>  wrote:
> 
> I feel stupid, but even with Sarah Reichelt’s help, there are very very 
> simple things I can’t do with the LC XML functions. My current problem is 
> this:
> 
> I have a series of XML files which are in fact .gpx files - a collection of 
> GPS coordinates representing a route on the Earth’s surface. There are 
> thousands of files around which I can use as test data, so I don’t have to 
> roll my own. Taking just one of these examples, I can do the following in LC
> 
> 1. Get the user to find the file and download it
> 
> 2. Check it’s a .gpx file
> 
> 3. Turn it into an LC XML data structure with an integer ID
> 
> 4. Find out how many child nodes there are.
> 
> Then it all goes wrong, because I don’t seem to be able to address the 
> individual nodes. This is obviously needed for further progress, in functions 
> like revXMLFirstChild  and revXMLNodeContents.
> 
> I just don’t know what format to use. Sarah’s tutorial doesn’t help because 
> her data structure is too simplified.
> 
> If you’re still with me, this is what the beginning of a typical file looks 
> like:
> 
>> 
>> http://www.topografix.com/GPX/1/1; creator="Digital Crow" 
>> version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; 
>> xsi:schemaLocation="http://www.topografix.com/GPX/1/1 
>> http://www.topografix.com/GPX/1/1/gpx.xsd;>
>> 
>> 
>>   
> 
>> 
>> 169.623637 
> 
>> 
>> 169.744722 
> 
>> 
>> 169.744722 
> 
>> 
>> 169.266626 
>> 
> etc - there may sometimes be thousands of these “trkpt” elements.
> 
> So, suppose I want to get the first instance of the “lon” attribute into a 
> local variable. How do I address the first  node etc in order to do it? 
> I have attempted various common-sense methods, but none work.
> 
> This must be child’s play to a lot of people, just not me.
> 
> Hoping for some guidance.
> 
> Graham
> ___
> 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

Ken Ray
Sons of Thunder Software, Inc.
Email: k...@sonsothunder.com
Website: https://www.sonsothunder.com




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


Re: macOS, is my app active?

2019-11-23 Thread Ken Ray via use-livecode
Klaus,

I have a function that generally works with this AppleScript:

function stsGetFrontmostProcess
  put "tell app `System Events`" & cr & \
  "get (the name of every application process whose frontmost is true) 
as string" & cr & \
  "end tell" into tScript
  replace "`" with quote in tScript
  do tScript as AppleScript
  put the result into tResult
  replace quote with "" in tResult
  return tResult
end stsGetFrontmostProcess

Give that a try and see if it works for you.

Ken

> On Nov 23, 2019, at 6:24 AM, Klaus major-k via use-livecode 
>  wrote:
> 
> Hi friends,
> 
> can we check if our standalone is currently active, means in
> the "foreground" or if it is not active? Know what I mean?
> If yes, how can we do that? LC? AppleScript?
> 
> I want to alert the user if the app is active, but not if the app 
> is not active.
> 
> Thanks in advance!
> 
> 
> Best
> 
> Klaus
> --
> Klaus Major
> https://www.major-k.de
> 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