The basis for an xtalk engine [I/we] control

A place to discuss any and all xTalk implementations, not just LC LCC Forks, but HyperCard, SuperCard, MetaCard, Gain Momentum, Oracle MediaTalk, OpenXION, etc.
Forum rules
Please limit any bashing/harping on any commercial interests to a minimum, thanks!
Post Reply
User avatar
tperry2x
Posts: 3488
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: The basis for an xtalk engine [I/we] control

Post by tperry2x »

richmond62 wrote: Fri Apr 04, 2025 10:59 am So? How on earth one can get anything to run on ALL browsers on ALL operating systems ALL of the time . . . might be a very tall order.
At the moment, it seems like anything Firefox-based, but also Edge, Opera... they all seem to work. Safari and the ogg audio thing... who knows what Apple want to do. I thought that was a standard web audio format?
Thank god for Firefox.

Among other things, I've added support for "compound-expression" today:
compound-expression.png
compound-expression.png (46.63 KiB) Viewed 8088 times
I'm busy moving house and putting bits into storage this weekend, so perhaps don't expect much until the middle of next week.
User avatar
richmond62
Posts: 5230
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: The basis for an xtalk engine [I/we] control

Post by richmond62 »

Well, .ogg is open source, as is Firefox: and Apple pinches whatever open source stuff it can to integrate into its closed system . . .

As, so far, Apple have not blocked open source software from running on their systems (I bet they'd like to), Firefox should suffice.

On my older Macs I use Firefox, and on my newer ones I use Brave (which is basically a deformed version of Chrome): and the very few times I have played with Safari it has felt the way I imagine it must feel sitting in a driverless car: horrible.
https://richmondmathewson.owlstown.net/
User avatar
OpenXTalkPaul
Posts: 2793
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: The basis for an xtalk engine [I/we] control

Post by OpenXTalkPaul »

richmond62 wrote: Fri Apr 04, 2025 2:15 pm Well, .ogg is open source, as is Firefox: and Apple pinches whatever open source stuff it can to integrate into its closed system
Not that I like having to defend Apple much but Webkit (Safari) https://en.wikipedia.org/wiki/WebKit, is actually built on top of KHTML/Konquerer from KDE project from the late 1990s, Apple took over the project at some point, but it is still very much open-source. It was the browser engine originally used in Chrome before it switched to Blink, and It's become system browser engine that comes with recent 'Buntus by default. Anyway, it's been the ONLY browser engine allowed on iOS mobile devices, even Firefox/Chrome have actually (been forced to) use webkit on iDevices. So for my iPad it's the only game in town. It's not as bloated as Chromium and has always felt snappier to me, but it doesn't support as many bleeding-edge things (ok, ogg has been around a long time now).
MPEG4 is a standard and almost unencumbered by patents now days, many have expired.
mp3 is no longer patent encumbered, the patents expired, although .aac is a better choice for lossy compression, it's not as commonly supported as the much older mp3 format (I have decade+ old digital picture frame that can play mp3) and I already had decades worth of a mp3 collection, so I've stuck with that (with highest bit rates/sample rates as I could).
User avatar
tperry2x
Posts: 3488
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: The basis for an xtalk engine [I/we] control

Post by tperry2x »

Progress (believe it or not). It might seem like a backwards step, but I'm slowly bringing the tokenized version back to the point the regex version was at.

What? (you may ask). Well, the previous versions of this I had been making was a lot easier to write functions for, but it was only doing simplistic pattern matching to work out the xtalk syntax. That could have only taken me so far, if I'm honest with myself.

I couldn't have run this command:

Code: Select all

if ("Hello World" contains "World" into tResult) is not "" then put "true"
progress-a.png
progress-a.png (48.69 KiB) Viewed 7514 times
I'm slowly getting back to the point where I started on GUI objects. I did redesign the test page too a bit:
progress-b.png
progress-b.png (54.42 KiB) Viewed 7514 times
More news towards the end of the week no doubt. ;)
User avatar
OpenXTalkPaul
Posts: 2793
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: The basis for an xtalk engine [I/we] control

Post by OpenXTalkPaul »

Awesome! I can't wait to check it out and hopefully be able to contribute to it!
User avatar
tperry2x
Posts: 3488
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: The basis for an xtalk engine [I/we] control

Post by tperry2x »

OpenXTalkPaul wrote: Tue Apr 08, 2025 12:52 am Awesome! I can't wait to check it out and hopefully be able to contribute to it!
I've just added what I've been up to in that shared folder (v133)

I would be grateful if you could fix this:
2025-04-08-22-41-52.png
2025-04-08-22-41-52.png (49.13 KiB) Viewed 7295 times
Only because I've not implemented 'the seconds' in what is essentially a rewrite (post tokenizer). I know I had all this working back in the regex version, but a lot of it I'm having to reinvent. It's slower to develop for, but at least the results are consistent.

I had started on date conversion though (/js/conversiondates.js)
2025-04-08-22-45-25.png
2025-04-08-22-45-25.png (26.94 KiB) Viewed 7294 times
User avatar
OpenXTalkPaul
Posts: 2793
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: The basis for an xtalk engine [I/we] control

Post by OpenXTalkPaul »

tperry2x wrote: Tue Apr 08, 2025 9:41 pm
OpenXTalkPaul wrote: Tue Apr 08, 2025 12:52 am Awesome! I can't wait to check it out and hopefully be able to contribute to it!
I've just added what I've been up to in that shared folder (v133)

I would be grateful if you could fix this:
2025-04-08-22-41-52.png

Only because I've not implemented 'the seconds' in what is essentially a rewrite (post tokenizer). I know I had all this working back in the regex version, but a lot of it I'm having to reinvent. It's slower to develop for, but at least the results are consistent.

I had started on date conversion though (/js/conversiondates.js)
2025-04-08-22-45-25.png
OK cool, the seconds and don't forget 'the ticks' and the most accurate timing 'the milliseconds', I'll get on that...

Milliseconds is the finest unit of time measurement that OXT engine supports, although I think modern C++ can actually be a tiny as nanosecond timing (probably would not yield a high degree of accuracy but I only need close-enough for rock & roll accuracy)
To get the current millisecond in Javascript would be something like:

Code: Select all

 millisecond = Date.now();
 return millisecond.toString();
Returns the number of milliseconds that have elapsed since the Unix Epoch up to the current moment.
That is, from the first second of 1970 (a good year for me :) ), which is the same starting point that OXT engines use.

'The Milliseconds' is also what you get when you use the 'long' form of seconds.
Divide the milliseconds by 1000 and you have the value for 'the seconds'.
So:

Code: Select all

millisecond = Date.now();
second = millisecond / 1000;
return Math.trunc(second);
You have it as 'current time in seconds since midnight' in the seconds.js file, which probably wouldn't cause any problems with scripts, but I'd like to keep consistent if possible.

I'm not sure how to connect those functions to the syntax in the grammar js.
Every keyword seems to be separated out into its own separate .js module in this version.
Just need an example for simple 'the propertyName' syntax to use as a template to copy/paste/modify for 'the seconds' and ''the milliseconds'. These also have abbrev. forms 'the secs' and 'the millisecs' so an example with synonyms would be good.
User avatar
tperry2x
Posts: 3488
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: The basis for an xtalk engine [I/we] control

Post by tperry2x »

I added this before I went off to work this morning. :D
I'll do you a write-up explanation of what needed to be changed:

What I changed:

Line 3 of seconds.js

changed this from:

Code: Select all

   This file provides functionality to get the current time in seconds since midnight

to:

Code: Select all

	This file provides functionality to get the current time in seconds since the Unix Epoch

Then changed the actual bit that does that calculation:

removed line 13 to 19, from this:

Code: Select all

        // Get hours, minutes, and seconds
        const hours = now.getHours();
        const minutes = now.getMinutes();
        const seconds = now.getSeconds();
        
        // Calculate total seconds since midnight
        const totalSeconds = (hours * 3600) + (minutes * 60) + seconds;

changed to this:

Code: Select all

        // Get seconds since Unix Epoch (January 1, 1970, 00:00:00 UTC)
        const totalSeconds = Math.floor(now.getTime() / 1000);

Now we modify the get.js function:

(to support "the seconds")
This is in the "async function handleGetCommand(expression)"

Inserted this on line 20 to 29:

Code: Select all

        // Special case for "the" followed by a property name
        if (expression.type === "WORD" && expression.value.toLowerCase() === "the") {
            // Look for the next token in the original command
            // Since we don't have direct access to the token stream,
            // we'll check if there are more tokens after processing this command
            
            // We need to check if the next token after "the" is "seconds"
            // This is a special case for "get the seconds"
            return await window.evaluateProperty("seconds");
        }

Then in hyperTalkGrammar.js, line 194, I added support for loading seconds.js

Code: Select all

        } else if (handlerName === 'handleSeconds') {
            moduleName = 'seconds.js';

At line 1374 in HyperTalkGrammar.js, I added support for "get the seconds":

Code: Select all

        // add support for 'get the seconds':
        processedTokens[2].value.toLowerCase() === "seconds" ||
Then some test cases would be good, so I added these in testing.html:
(I've commended where these should go when you add tests)

Code: Select all

            },
            {
                description: "Get seconds property",
                script: 'put the seconds',
                customValidator: (output) => {
                    // Check if output is a valid Unix timestamp (large integer)
                    const seconds = parseInt(output);
                    return !isNaN(seconds) && seconds > 1000000000; // Valid Unix timestamp should be > 1 billion
                }
            },
            {
                description: "Get the seconds and put it",
                script: 'get the seconds\nput it',
                customValidator: (output) => {
                    // Check if output is a valid Unix timestamp (large integer)
                    const seconds = parseInt(output);
                    return !isNaN(seconds) && seconds > 1000000000; // Valid Unix timestamp should be > 1 billion
                }
            },
That adds support for:

Code: Select all

get the seconds
and

Code: Select all

put the seconds
which now calculates it from the epoch, not from midnight. :lol: Sorry, I was very tired!
seconds.png
seconds.png (23.33 KiB) Viewed 7064 times
micmac
Posts: 168
Joined: Mon Sep 13, 2021 9:46 pm
Contact:

Re: The basis for an xtalk engine [I/we] control

Post by micmac »

Where is it we can test your engine, Tom?

Mic
User avatar
tperry2x
Posts: 3488
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: The basis for an xtalk engine [I/we] control

Post by tperry2x »

micmac wrote: Wed Apr 09, 2025 12:12 pm Where is it we can test your engine, Tom?
Comments like this are the reason it's not available to everyone.
User avatar
OpenXTalkPaul
Posts: 2793
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: The basis for an xtalk engine [I/we] control

Post by OpenXTalkPaul »

tperry2x wrote: Wed Apr 09, 2025 6:10 am That adds support for:

Code: Select all

get the seconds
and

Code: Select all

put the seconds
which now calculates it from the epoch, not from midnight. :lol: Sorry, I was very tired!

seconds.png
OK thanks for a guide, I figured some of it last night, i'll try to add 'the milliseconds/millisecs tonight to see if I got the flow right.
User avatar
tperry2x
Posts: 3488
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: The basis for an xtalk engine [I/we] control

Post by tperry2x »

Don't do any work on this tonight Paul and/or Dan.
I've noticed a major flaw in the tokenizer regarding variable allocation, which means a lot needs fixing... Any work you do on things will be for nothing at the moment until I fix this.
User avatar
OpenXTalkPaul
Posts: 2793
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: The basis for an xtalk engine [I/we] control

Post by OpenXTalkPaul »

tperry2x wrote: Wed Apr 09, 2025 8:14 pm Don't do any work on this tonight Paul and/or Dan.
I've noticed a major flaw in the tokenizer regarding variable allocation, which means a lot needs fixing... Any work you do on things will be for nothing at the moment until I fix this.
I just downloaded the last one in there and tested 'the seconds' like this:

Code: Select all

Put "The seconds = " & the seconds 
Without any 'get' or 'put' command preceding the property name.
Result:
'The seconds = ' -- without the value for 'the seconds'.
User avatar
tperry2x
Posts: 3488
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: The basis for an xtalk engine [I/we] control

Post by tperry2x »

OpenXTalkPaul wrote: Wed Apr 09, 2025 9:34 pm tested 'the seconds' like this:

Code: Select all

Put "The seconds = " & the seconds 
Without any 'get' or 'put' command preceding the property name.
Result:
'The seconds = ' -- without the value for 'the seconds'.
That's weird, yet I can do:

Code: Select all

put the seconds into tseconds
Put "The seconds = " & tseconds
if the seconds are in a variable, then it works. Will look into that one.
2025-04-10-00-27-54.png
2025-04-10-00-27-54.png (51.87 KiB) Viewed 6758 times
User avatar
tperry2x
Posts: 3488
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: The basis for an xtalk engine [I/we] control

Post by tperry2x »

I found the reason for the concatenation expression when you run:

Code: Select all

Put "The seconds = " & the seconds.
The problem was in the createConcatenationExpression function in hyperTalkGrammar.js.
The right side of the concatenation expression was only capturing "the" and not the complete "the seconds" expression. This happened because of how the createConcatenationExpression function processed the right side of the expression.

In the function at line 411-419:

Code: Select all

return {
    type: withSpace ? "CONCATENATION_WITH_SPACE_EXPRESSION" : "CONCATENATION_EXPRESSION",
    left: left.type === "STRING" ? 
        { type: "STRING_LITERAL", value: left.value } : 
        left.type === "WORD" ?
            left.value :
            left,
    right: right
};
The function properly transformed the left side of the expression, but it didn't do the same for the right side. It simply assigned right without any transformation or checking if it's a compound expression like "the seconds"!

When the concatenation handler then tried to evaluate this expression, it spotted "the" as a variable name rather than the start of a property expression "the seconds". (Yes, it's kind of dumb, but it's only doing what it was told).

I modified the processTokensComplex function where it creates the concatenation expression:

Code: Select all

// If we have an operator waiting, create a concatenation expression
if (operatorStack.length > 0 && result.length > 0) {
    const operator = operatorStack.pop();
    const left = result.pop();
    
    // Check if this is a concatenation with space
    const withSpace = operator.value === "&&" || operator.value === ",";
    
    // Check if the current token is "the" and the next token exists
    let rightExpr = expr;
    if (token.type === "WORD" && token.value.toLowerCase() === "the" && 
        i + 1 < preprocessedTokens.length && preprocessedTokens[i + 1].type === "WORD") {
        // Create a THE_EXPRESSION object
        rightExpr = {
            type: "THE_EXPRESSION",
            property: preprocessedTokens[i + 1].value
        };
        // Skip the next token since we've used it
        i++;
    }
    
    // Create the concatenation expression with the proper right expression
    const concatExpr = {
        type: withSpace ? "CONCATENATION_WITH_SPACE_EXPRESSION" : "CONCATENATION_EXPRESSION",
        left: left.type === "STRING" ? 
            { type: "STRING_LITERAL", value: left.value } : 
            left.type === "WORD" ?
                left.value :
                left,
        right: rightExpr
    };
    
    result.push(concatExpr);
} else {
    result.push(token);
}

This now properly handles "the seconds" as a "THE_EXPRESSION" when it appears on the right side of a concatenation operator, fixing the issue with Put "The seconds = " & the seconds.

It does make perfect sense as to why it was doing this. Thankfully it's not an error with the parser, or the tokenizer, more how those expressions are being made sense of after the fact.

I'll try and put my amended version in that shared folder this evening. Then I can carry on with playing catchup to the old regex version, then overtake it and start making forward progress again!
stupid-mistake-by-me.png
stupid-mistake-by-me.png (18.63 KiB) Viewed 6507 times
Oh, almost forgot.
You can now also do ctrl M (cmd M for those mac users), and it'll toggle that message box and parserLogic fields - leaving you with just the card area. (Good for some canvas element type action at a later stage).
TerryL
Posts: 130
Joined: Sat Oct 16, 2021 5:05 pm
Contact:

Re: The basis for an xtalk engine [I/we] control

Post by TerryL »

Welcome back. I hope you saw my previous post with questions: https://www.openxtalk.org/forum/viewtop ... 515#p14515

I made the start of what could be a webtalk dictionary. It's a stripped 4-item text-database that could be reordered and modified as desired. Current up to WebTalk Doc-128 with 195 entries. My intent was to squeeze only the most essential info on one line of text. It could be used to display the info in another field more conventionally. I'll carry on with it if requested.

I've a few questions on webtalk syntax.
- Does 'the scrollable' field property true enable vertical AND horizontal scrollbars or just vertical?
- Can the popular 'cr' (carriage return) be a synonym for 'return' and 'lf' (linefeed)?
- Are join() and combine() functions the same?
put join("a,b,c","-") --a-b-c? Replace old itemDel with new itemDel
put combine("a,b,c","-") --a-b-c?
- Is itemDelimiter restricted to 1 char or also accepts a string?
- Are there preOpenCard and closeCard handlers to complement openCard?
Attachments
WebTalk Dict.zip
(7.47 KiB) Downloaded 105 times
User avatar
tperry2x
Posts: 3488
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: The basis for an xtalk engine [I/we] control

Post by tperry2x »

TerryL wrote: Thu Apr 10, 2025 9:23 pm Welcome back. I hope you saw my previous post with questions: https://www.openxtalk.org/forum/viewtop ... 515#p14515
No, I missed that. Sorry.
- the target, target() --similar to 'me' but probably hard to translate
- result() --the result synonym
- global/local (script local and within a handler) declarations for container names.
- switch/case/break
- arrays --maybe include split and combine
- repeat while <condition>, repeat until <condition>, next repeat --example: repeat while intersect(fld "A", grc "Ball")
- specialFolderPath("desktop") --desktop, documents, resources
- window.find() //launch browser's find dialog
- window.confirm() //answer dialog with cancel and ok btns
- Can js be coaxed to translate:
answer "Please select a color." with "Cancel" or "Red" or "Green" or "Blue" --oxt: max = 7 buttons
The result is something I had implemented previously* more on this further down.
I hadn't implemented global variable handling specifically. At the moment, variables are globals. For example, if I run:

Code: Select all

put "Current time" && the time into msgVar
answer msgVar with "Close Dialog"
put it
alert.png
alert.png (10.98 KiB) Viewed 6101 times
it would return the name of the clicked button "Close Dialog" and put it.
If I clear the message box and type "put it", I get "Close Dialog" -- I will probably make variables non-global as default.

switch, case, break -- not done yet.
arrays -- not done yet.
repeat while -- done
next repeat -- not done yet
repeat while [condition] -- done
- specialFolderPath("[anything]") -- very limited and don't know if this can even be done due to browser sandboxing
answer dialogs -- done (and re-done*)
I'm sure I can do answer color [& colour synonym]
max 7 buttons on alert dialogs -- why contrain ourselves when we can support as many choices as the screen width will allow?
buttons.png
buttons.png (10.49 KiB) Viewed 6101 times
TerryL wrote: Thu Apr 10, 2025 9:23 pm I made the start of what could be a webtalk dictionary. It's a stripped 4-item text-database that could be reordered and modified as desired. Current up to WebTalk Doc-128 with 195 entries. My intent was to squeeze only the most essential info on one line of text. It could be used to display the info in another field more conventionally. I'll carry on with it if requested.
That's cool - I'm looking forward to seeing that & it will help me track what I don't yet have added.
TerryL wrote: Thu Apr 10, 2025 9:23 pm I've a few questions on webtalk syntax.
- Does 'the scrollable' field property true enable vertical AND horizontal scrollbars or just vertical?
- Can the popular 'cr' (carriage return) be a synonym for 'return' and 'lf' (linefeed)?
- Are join() and combine() functions the same?
put join("a,b,c","-") --a-b-c? Replace old itemDel with new itemDel
put combine("a,b,c","-") --a-b-c?
- Is itemDelimiter restricted to 1 char or also accepts a string?
- Are there preOpenCard and closeCard handlers to complement openCard?
The scollable field property - fields were assumed to be non-scrolling when created, and you would have been able to toggle the hscrollbar / vscrollbar property*

cr carriage returns, return & lf -- at the moment I'm using \n newline - and return is a synonym for \n as that's supported without any ambiguity across multiple platforms and browsers. I will look into adding cr as well.

join -- not specifically as join yet.
For example, you can use:

Code: Select all

put "a" & "b" & "c" into myvariable
but I would like to add the join function -- shouldn't be too hard.

is combine a synonym for join? -- silly question perhaps.

Itemdelimiter -- I don't know if it's restricted to one character... hang on, will go test it... yes - this works fine.
custom-itemdelimiter.png
custom-itemdelimiter.png (20.01 KiB) Viewed 6061 times
preopencard / opencard*

Everything with a * WAS implemented.
However, and this is what is taking me a while, I've been constantly busy behind the scenes with a tokenizer and parser approach to all this (I haven't been anywhere! :lol: ) - it essentially meant I had to rewrite ALL the handlers and functions that I already have to accomodate this approach. It DID need to be done though, as I was starting to run into problems with the regex version - so this means I'm currently playing catchup back to where I was.
User avatar
tperry2x
Posts: 3488
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: The basis for an xtalk engine [I/we] control

Post by tperry2x »

I'll also add that I've just re-done the ask dialog:
ask-dialog.png
ask-dialog.png (31.1 KiB) Viewed 6014 times
Going to add the ask password and ask list again tomorrow. Headache time again :?
User avatar
tperry2x
Posts: 3488
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: The basis for an xtalk engine [I/we] control

Post by tperry2x »

I won't have a chance to implement this over the weekend, as family-related (good and bad) things to sort out - so have implemented the ask password too:
2025-04-11-17-20-47.png
2025-04-11-17-20-47.png (25.69 KiB) Viewed 5806 times
User avatar
OpenXTalkPaul
Posts: 2793
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: The basis for an xtalk engine [I/we] control

Post by OpenXTalkPaul »

Thanks for all your work!
While I've been waiting I've been collecting a bunch of Javascript code that might be used to implement various syntax (for example 'move' object along path in x secs' can be done with JS with CSS properties and using HyperCard Sim and/pr the Emscripten Engine real-world test them. Somethings can't be done yet, like not until I know the model for scriptObjects. For example I have a handler in my HC Sim 'SimScript' that gets ' the openStacks' (also stacksIUse, but not sure if those are meant to be synonymous).
arrays -- not done yet.
I was thinking Javascript Arrays are basically the same as Arrays in LCS/OXT script.

Adding Command+M for Mac won't work for in-Browser context on macOS because the browsers treat out 'web stacks' like any other document window in an app and so it minimizes the window into the Dock. It's a problem with HyperCard Sim and Emscripten Engine too. Something other than Cmn+M, like command+option+shift+M might work.

That's another example of differences between a 'web app' and a 'desktop app', a desktop app can trap / override the key-combo message before it reaches the operating system, while as far as a 'web app' is concerned the browser IS effectively the operating system.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests