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 we control

Post by tperry2x »

Version 118
(lots of changes here)
Firstly, these can all be found in "testing3.html"
I split them up to make it easier to manage.
Because the interpreter was getting a bit large, I added an extra "extended-functions.js" which is called as an extension of the interpreter now. Just means that as the file grows in size, we can add extras coming off it. (I was getting too confused by the size of the "interpreter.js" and it was getting difficult to make changes).

Mentioning that, I've been busy adding the following functions:
Examples:

Format function

Code: Select all

put format(123.456, "#.#") into tResult
put tResult -- outputs 123.5
BaseConvert function -- (Convert decimal 255 to hexadecimal)

Code: Select all

put baseConvert(255, 10, 16) into tResult
put tResult -- would output ff
Pi function (Get the value of pi)

Code: Select all

put pi() into tResult
put tResult -- outputs 3.141592653589793
Variance function - (Calculate variance of 1,2,3,4,5)

Code: Select all

put variance("1,2,3,4,5") into tResult
put tResult -- outputs 2
Variance function - (Calculate variance using variable)

Code: Select all

put "1,2,3,4,5" into tNumbers
put variance(tNumbers) into tResult
put tResult -- outputs 2
StandardDeviation function - (Calculate standard deviation of 1,2,3,4,5)

Code: Select all

put standardDeviation("1,2,3,4,5") into tResult
put tResult -- outputs 1.4142135623730951
Union function example - using variables as input

Code: Select all

put "a,b,c" into tList1
put "c,d,e" into tList2
put union(tList1, tList2) into tResult
put tResult -- outputs a,b,c,d,e
Intersection function - (Intersection example)

Code: Select all

put "a,b,c" into tList1
put "c,d,e" into tList2
put intersection(tList1, tList2) into tResult
put tResult -- outputs c
Split function - (Split string by delimiter)

Code: Select all

put split("a-b-c", "-") into tResult
put tResult -- outputs a,b,c
Join function - (Join list with delimiter)

Code: Select all

put "a,b,c" into tList1
put "-" into tDelimiter -- new delimiter to put between items of tList1
put join(tList1, tDelimiter) into tResult
put tResult -- outputs a-b-c
Base64Encode function - (Encode string to base64)

Code: Select all

put base64Encode("Hello, World!") into tResult
put tResult -- returns SGVsbG8sIFdvcmxkIQ==
Base64Decode function - (Decode base64 to string)

Code: Select all

put base64Decode("SGVsbG8sIFdvcmxkIQ==") into tResult
put tResult -- returns Hello, World!
MD5Digest function - (Calculate MD5 hash)

Code: Select all

put md5Digest("Hello, World!") into tResult
put tResult
-- outputs: 06050a080e02070d080807090208030803010b0606040b0d080b070f000a0d04
SHA1Digest function - (Calculate SHA1 hash)

Code: Select all

put sha1Digest("Hello, World!") into tResult
put tResult -- returns 0a0a9f2a6772942557ab5355-28950bbe-709a1ff
Just a further note about the additional "extended-functions.js" file:
I modified the prototype of the InterpreterClass. This makes sure that wherever I include the interpreter, including the one in in main.js, it'll have access to the extended functions.
I've also added a transparent retry check that will attempt to extend the InterpreterClass multiple times if it's not available. (this silently prevents errors, and I thought it was better than adding any wait commands)
This support situations where the script loading order might not be right for example.
This means the interpreter now uses the original evaluateExpression as a function reference instead of a class inheritance. This should be more reliable for edits and changes when you want to see it in realtime.

I now have a headache and am going to take "a few days out" to reset my head.
Attachments
documentation.pdf
(169.79 KiB) Downloaded 43 times
User avatar
OpenXTalkPaul
Posts: 2798
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: The basis for an xtalk engine we control

Post by OpenXTalkPaul »

tperry2x wrote: Fri Mar 21, 2025 11:23 am I now have a headache and am going to take "a few days out" to reset my head.
WOW! GREAT WORK! My goodness that's a lot, no wonder yuo have a headache!
Thanks!
User avatar
OpenXTalkPaul
Posts: 2798
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: The basis for an xtalk engine we control

Post by OpenXTalkPaul »

...now do BinaryDecode / BinaryEncode and ByteOffset ... jK :)
https://livecode.fandom.com/wiki/BinaryDecode
https://livecode.fandom.com/wiki/BinaryEncode
https://livecode.fandom.com/wiki/ByteOffset
:twisted:
I know you said you need a break, but would you mind sharing v117 on MEGA so I can have a play?
The last version in there is 113

You got a lot of useful math functions added very quickly, so I guess I'll start looking at the controls / objects and properties? Or maybe go back to tinkering around with the File,Blob,and FileReader stuff again? I'd to get a working import image command, but that would require creating a new part/control/element with properties on the card.

I want to help but you've been moving much faster on this than I coould and I don't want to replicate the same work you're doing.
dandandandan
Posts: 16
Joined: Thu May 05, 2022 9:02 pm
Contact:

Re: The basis for an xtalk engine we control

Post by dandandandan »

OpenXTalkPaul wrote: Thu Mar 20, 2025 7:24 pm The code for the interpreter is currently being shared by Tom on a shared mega account that I created to use for collaboration since some people are really not keen on using GitHub. Personally I think it would be better to use GitHub or similar version control system, out in the open / open-source, but I'm flexible.
Can someone send me a link? Private message if you want.
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 we control

Post by tperry2x »

haha, in all seriousness - I'm sure I will. Just got real life issues to deal with currently.
OpenXTalkPaul wrote: Fri Mar 21, 2025 3:58 pm I know you said you need a break, but would you mind sharing v117 on MEGA so I can have a play?
Have uploaded into your shared folder, we are up to 118 now.
OpenXTalkPaul wrote: Fri Mar 21, 2025 3:58 pm You got a lot of useful math functions added very quickly
I enlisted the help of a very skillful maths teacher at our school to explain each. Was still a headache transforming that into various javascript though.
OpenXTalkPaul wrote: Fri Mar 21, 2025 3:58 pm ...so I guess I'll start looking at the controls / objects and properties? Or maybe go back to tinkering around with the File,Blob,and FileReader stuff again? I'd to get a working import image command, but that would require creating a new part/control/element with properties on the card.
Feel free to have a go with whatever part of it you like. You've already given me some interesting ideas on file I/O, so I'll try and tackle the saving/loading if you like.
OpenXTalkPaul wrote: Fri Mar 21, 2025 3:58 pm I want to help but you've been moving much faster on this than I could and I don't want to replicate the same work you're doing.
That's no problem. As long as if you can post what you added, could be in that ODT file if you like, then I can pick it up from there. I've been having a lot of sleepless nights lately, so have been up coding and reading, but that's another story.
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 we control

Post by tperry2x »

dandandandan wrote: Fri Mar 21, 2025 4:05 pm Can someone send me a link? Private message if you want.
@PaulMcClernan - please can you share with Dan as well, feel free to modify / pull it about, do whatever. I'll be back in probably about a week I think, perhaps a bit longer.
User avatar
OpenXTalkPaul
Posts: 2798
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: The basis for an xtalk engine we control

Post by OpenXTalkPaul »

tperry2x wrote: Fri Mar 21, 2025 5:12 pm
dandandandan wrote: Fri Mar 21, 2025 4:05 pm Can someone send me a link? Private message if you want.
@PaulMcClernan - please can you share with Dan as well, feel free to modify / pull it about, do whatever. I'll be back in probably about a week I think, perhaps a bit longer.
Sure I'll send Dan info later today, soon as I get a minute.
I know you've got other stuff going on, real life is a bitch, don't sweat this.

Lately it seems I've always got other stuff going on so I totally understand.
Last week we said goodbye to our most beloved family dog, and this week I've got a little baby puppy running around at home like a little gremlin. :D
TerryL
Posts: 130
Joined: Sat Oct 16, 2021 5:05 pm
Contact:

Re: The basis for an xtalk engine we control

Post by TerryL »

Tremendous progress on math functions, very impressive. Break well earned. I should have included more info on standard deviation and hyperbolic sin/cos/tan with the math functions .txt, as the dictionary is a bit limited and could be improved.
--
Standard Deviation. Standard Deviation is a statistical tool to measure the cohesiveness or closeness of data below and above the mean average of the data. Cohesive data would yield a smaller standard deviation from the mean, while loose un-cohesive data would yield a larger standard deviation. By definition, one standard deviation below the mean + one standard deviation above the mean represents 68.27% of the data points assuming a normal bell-shaped probability curve. Two stdDevs = 95.45% and three stdDevs = 99.73%.
For example, if the mean average of data = 7.0 and one stdDev = 1.5 then 68.27% of the data points lie between 7.0-1.5 and 7.0+1.5.
There are two separate versions of standard deviation: the entire population of data (popStdDev, populationStandardDeviation) and a portion or sample of data (stdDev, standardDeviation, sampStdDev, sampleStandardDeviation).
(Note there is an averageDeviation (avgDev) function that is probably related to standard deviation but I have no idea what it is and probably LC too when they added it in v6.1).
--
Hyperbolic Sin/Cos/Tan. The hyperbolic functions sinh, cosh, and tanh are used to calculate three exponential curves frequently found in physics and engineering. Using formulas with e^x to return value y, a series of x,y data points can be graphed to create the curve.
For example, sinh(3) = 10.017875 resulting in a 3,10 data point. sinh(6) = 201.713157 resulting in a 6,202 data point on the curve.
----
User avatar
richmond62
Posts: 5234
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: The basis for an xtalk engine we control

Post by richmond62 »

About 4 years ago our beloved cat had to be put to sleep as she has seriously nasty terminal cancer and . . .

About 3 weeks later my wife and I were out in the garden looking at her grave and feeling a bit . . .

When a 9-month old cat appeared from nowhere and wound herself round my legs . . .

So: the snag about keeping pets (except tortoises) is that they have shorter lives than we do.

The advantage (certainly here in Bulgaria) is that with cats there is always a 'drop in replacement' waiting in the wings.

(We have, and feed, 9 pretenders to the throne who live in a wooden cat-shack I constructed out of some old doors in our garden).

HOWEVER, unlike puppies, cats come already potty-trained and don't pee and poo all over the house.

TIP from my Mother (who at 95 has been through about 12 dogs): when a puppy poos or pees in the house rub the animal's nose in it: it will stop 'performing' in the house every quickly indeed.

AT LEAST, that is the basis for a puppy you control. 8-) And while that may not be much in the great scheme of things, it will be some comfort while working on an xtalk engine we/you control.

OH, and 'while I am here', while the inherited IDE relies on 'engines' to function, is the upcoming web-thang technically an engine?
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 5234
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: The basis for an xtalk engine we control

Post by richmond62 »

the dictionary is a bit limited and could be improved
Really? I had not noticed. :lol:
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 5234
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: The basis for an xtalk engine we control

Post by richmond62 »

Standard Deviation. Standard Deviation is a statistical tool to measure the cohesiveness or closeness of data below and above the mean average of the data. Cohesive data would yield a smaller standard deviation from the mean, while loose un-cohesive data would yield a larger standard deviation. By definition, one standard deviation below the mean + one standard deviation above the mean represents 68.27% of the data points assuming a normal bell-shaped probability curve. Two stdDevs = 95.45% and three stdDevs = 99.73%.
For example, if the mean average of data = 7.0 and one stdDev = 1.5 then 68.27% of the data points lie between 7.0-1.5 and 7.0+1.5.
There are two separate versions of standard deviation: the entire population of data (popStdDev, populationStandardDeviation) and a portion or sample of data (stdDev, standardDeviation, sampStdDev, sampleStandardDeviation).
(Note there is an averageDeviation (avgDev) function that is probably related to standard deviation but I have no idea what it is and probably LC too when they added it in v6.1).
--
Hyperbolic Sin/Cos/Tan. The hyperbolic functions sinh, cosh, and tanh are used to calculate three exponential curves frequently found in physics and engineering. Using formulas with e^x to return value y, a series of x,y data points can be graphed to create the curve.
For example, sinh(3) = 10.017875 resulting in a 3,10 data point. sinh(6) = 201.713157 resulting in a 6,202 data point on the curve.
Should Richmond 'pull his finger out' and write text documents for those functions, or . . .
https://richmondmathewson.owlstown.net/
User avatar
OpenXTalkPaul
Posts: 2798
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: The basis for an xtalk engine we control

Post by OpenXTalkPaul »

richmond62 wrote: Fri Mar 21, 2025 6:09 pm+
HOWEVER, unlike puppies, cats come already potty-trained and don't pee and poo all over the house.

TIP from my Mother (who at 95 has been through about 12 dogs): when a puppy poos or pees in the house rub the animal's nose in it: it will stop 'performing' in the house every quickly indeed.
We had 3 dogs and 3 cats living in our house at one point, but now we are down to 4 pets: 2 x 7-year-old labradors (the wonder twins), and one senior-citizen cat (15), and one rescued mixed-breed baby pup.
I hate dealing with kitty-litter and clawed up fabric coverings (it's illegal, as it should be, to de-claw cats here in New Jersey), so this is likely our last pet cat.
I agree with your Mum, rub their nose in it is how we've potty trained them, it doesn't take long, and I have a fenced in yard so I don't have to go out with 'em when it's raining or snowing out.
OH, and 'while I am here', while the inherited IDE relies on 'engines' to function, is the upcoming web-thang technically an engine?
I would say that this effort is not so much an engine as it is an interpreter/translator that runs on top of a web browser as it's runtime 'engine', It's an engine that is not specifically built with xTalk in mind, but a lot of non-Javascript languages, such as Smalltalk, Python, Lua, etc. have been ported (mostly re-compiled to web assembly modules from C++ source) to run in a browser as the engine. We have already working examples in Decker, ViperCard, Dan's HyperCard Sim, etc. that have proven that this can work for xTalk-like use. I think it's ironic because of the claims that HTML and JavaScript were originally inspired by HyperCard/HyperTalk (I see little that makes me believe that).
User avatar
richmond62
Posts: 5234
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: The basis for an xtalk engine we control

Post by richmond62 »

Luckily we live in the country: so no indoor cat toilet!
https://richmondmathewson.owlstown.net/
User avatar
OpenXTalkPaul
Posts: 2798
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: The basis for an xtalk engine we control

Post by OpenXTalkPaul »

Real quick adds to the interpreter.
expression 'the version':

Code: Select all

this.version = 118;

// Handle "the version"
        if (expr.trim().toLowerCase() === 'the version') {
        return this.version;
        }
put the version -- 118 -- hypercard sim returns 2.4.1 here

That's a little different than HyperTalk's 'the version': https://www.hypercard.center/HyperTalkReference/version

All xTalks seem to have this 'the version' property which is the 'engine' or interpreter's version number.


This one is from the JS snippets popup menu in the OXT Web Playground

Code: Select all


        this.userAgent = window.navigator.userAgent;

        // Handle "the userAgent"
        if (expr.trim().toLowerCase() === 'the useragent') {
        return this.userAgent;
        }
put the userAgent
result:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3.1 Safari/605.1.15

10.15.7??? I'm running 15.3.2 with the latest Safari at the moment!
I thought Apple fixed this problem? I guess they did not for WebKit:
https://github.com/faisalman/ua-parser- ... 1689320154

Anyway I wanted to mention that the Emscripten engine with OXT Web Playground can run xTScript and JavaScript too, so it could come in handy for testing out some code snippets (and some are included in that popup menu).
I know Browsers can have Dev Mode with JS console where you can run JS snippets from, and this stack is basically doing the same thing. But it is also a live copy of the OXT Emscripten engine so you can use it for xTalk script snippets like you would from the 'message box' stack. including multi-line scripts as well, like this snippet which creates something like an empty template image and appends it to the page:

Code: Select all

var oxtimg = document.createElement("IMG");
oxtimg.setAttribute('src','data:image/png;base64,');
oxtimg.setAttribute('width','100');
oxtimg.setAttribute('height','200');
oxtimg.setAttribute('alt','new-image');
document.body.appendChild(oxtimg);
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 we control

Post by tperry2x »

Hi Paul.
Thanks for those bits, will check them out when I have time.
OpenXTalkPaul wrote: Sat Mar 22, 2025 12:35 am This one is from the JS snippets popup menu in the OXT Web Playground

Code: Select all


        this.userAgent = window.navigator.userAgent;

        // Handle "the userAgent"
        if (expr.trim().toLowerCase() === 'the useragent') {
        return this.userAgent;
        }
put the userAgent
result:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3.1 Safari/605.1.15
I think I already implemented something similar, but I forgot to add it to test page 1.

Code: Select all

put the browsername
returns:
Mozilla/5.0 (X11; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0
Sorry, missed this off the test page (my fault).

If you just want the short version string, you can also do:

Code: Select all

put the browserversion
Returns:
136.0
for example.
User avatar
richmond62
Posts: 5234
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: The basis for an xtalk engine we control

Post by richmond62 »

I really wonder if you should release this 'into the wild' for some testing, or remove the 'we' from 'The basis for an xtalk engine we control'. 8-)
https://richmondmathewson.owlstown.net/
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 we control

Post by tperry2x »

richmond62 wrote: Sat Mar 22, 2025 8:44 am I really wonder if you should release this 'into the wild' for some testing, or remove the 'we' from 'The basis for an xtalk engine we control'. 8-)
:lol: Maybe I'm being a bit too protective of it, sure - but it's for good reason as far as I can tell.
(btw, this forum [phpBB] really isn't geared up for phone use).
User avatar
OpenXTalkPaul
Posts: 2798
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

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

Post by OpenXTalkPaul »

Since last night I had a look at how the webtalk objects are created and decided to test it out by adding an image object to the interpreter.js and objects.js
Screen Shot 2025-03-22 at 10.58.36 AM.png
Screen Shot 2025-03-22 at 10.58.36 AM.png (172.33 KiB) Viewed 4090 times
Notice here we have what would be equivalent to setting 'the text' of image "test", were this one of the OXT Community engines, that is it has its src= atrribute pre-filled in at creation time with Ye Old 1bit paint icon by setting to a Data URI (a base64 encoded png). I really like the whole data URI thing, it allows for having image assets embedded into the page making it a more self-contained 'standalone' document (like PDF, which supports JavaScript too BTW https://www.reddit.com/r/itrunsdoom/com ... ?rdt=52390)

I suppose the equivalent of setting the filename of image "test" would be setting that same src= attribute to a URL as one normally would with traditional HTML.
User avatar
richmond62
Posts: 5234
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

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

Post by richmond62 »

I assume by 'traditional HTML' you mean pre-HTML5, where putting a web-page pre-CSS and so on was really comparatively simple.

I taught myself the basics of HTML by running up a web-page with KompoZer and the opening the end result in BBEdit.

Am I right in thinking web-pages made rhat way should still be rendered properly by current browsers?
https://richmondmathewson.owlstown.net/
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: Sat Mar 22, 2025 3:19 pm Since last night I had a look at how the webtalk objects are created and decided to test it out by adding an image object to the interpreter.js and objects.js
Hi Paul. That looks very impressive.
That's a real nice touch, although I will probably add a coloured graphic to represent an image.

The family medical situation I was dealing with has been kind of resolved for the time being. I won't bore everyone with the details, except to say I have a stubborn father who discharged himself from hospital.

Anyway, the less I dwell on that the better, so I've been throwing myself into this a bit more.

Version 119:
Just a small change. See "extended-functions.js", and my comment:

Code: Select all

// Try to extend immediately
I've modified the timing of the extension mechanism (10 milliseconds), so it tries a lot harder to load the extended functions, and does not give up as readily (whereas it was 10% determined to load this, it's not 80% determined to do so).
This isn't something the user should see - (that's exactly the point of it: it's something that happens as an invisible process in the background). It means the interpreter kind of has a plug-in architecture, to simplify adding extra functions in "extended-functions.js"
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests