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 »

Version 120
Added the userAgent (thanks Paul), so you can use:

Code: Select all

put the userAgent -- returns the browser's user agent string
put the browserName -- does the same as above
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 »

Version 121
Added the ability for the user to save their stacks with:

Code: Select all

save stack as "mystack"
This writes the current stack to a JSON file, in this example:
mystack.json
snippet.png
snippet.png (94.46 KiB) Viewed 10103 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 »

Version 122
I've just also added the load function, from the file we saved earlier in version 121.
However, I've not shared this version yet, because I want to make sure I can't confuse the interpreter. (I need to add some more error handling).

The script for loading a stack would be:

Code: Select all

load stack [filename]
The filename can be specified with or without quotes. If the interpreter can't find it (usually due to browser restrictions), it'll prompt the user to choose a file instead.

Before loading, the user is prompted with a confirmation dialog:
confirmation.png
confirmation.png (27.06 KiB) Viewed 10101 times
I tried to make this as clear as possible to avoid any confusion (rather than just a simple yes or no).
If "No, Cancel" is selected, the load process is cancelled and nothing should be cleared from the current stack.

Assuming we chose "Yes, load", when a JSON file is selected (hopefully one we made earlier), the interpreter reads and tries to make sense of the JSON data and validates its structure.
All existing objects are cleared from the card, all event listeners are properly removed to prevent memory leaks.

Each object from the saved stack is recreated with the same: type (button, field, etc.), name, position and size, script content, any custom properties, any field content (for field objects if applicable)

I've also added some error handling when parsing the JSON structure. It should result in detailed error messages being displayed to the user. This is where I'm up to though, as I want to add a lot more error handling in before I share this version. Nearly there with it though. :D
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 »

Stack File loading! Great!
I'm having to deal with suborn octogenarian parents that wonder off too, so I totally get that as well! :)

I like that you have 'the short form of'.
browserName I would think would return something like "Safari" but the full userAgent string is more useful in detecting which browser & version a script is running in (which should only even be needed in specific situations were browsers implement an API differently), since it has additional info like the version, host OS, browser engine name, etc.

I'm not sure what you mean about implementing an image in some different way because images already were implemented in HTML 1.0? Do you mean implement an image container object, so that it can be styled with borderColor, drop shadows and such? That makes sense I guess, because an image 'control' is NOT an image, it's a image view-prt, a container for an image.

@Richmond
What I meant by 'traditional HTML' in that context was any time pre dataURI support in all major browsers.
According to Google AI:
Data URIs, URLs prefixed with "data:", which allow embedding small files inline in documents, have been supported by major browsers since at least 2009.
That says 'embedding small files' but I'm not sure if there's a size limit or what that limit might be so I checked:
Browsers are not required to support any particular maximum length of data. Chromium and Firefox limit data URLs to 512MB, and Safari (WebKit) limits them to 2048MB. Note that Firefox 97 increased the limit from 256KB to 32MB, and Firefox 136 increased it to 512MB.
Personally I would not call a file that is a half a gig in size a 'small' file, let alone a two-gig file! :lol:
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: Sun Mar 23, 2025 1:29 pm I'm not sure what you mean about implementing an image in some different way because images already were implemented in HTML 1.0? Do you mean implement an image container object, so that it can be styled with borderColor, drop shadows and such? That makes sense I guess, because an image 'control' is NOT an image, it's a image view-prt, a container for an image.
Yes, exactly that. The image object / control is what I mean. I haven't implemented any effects yet, such as drop shadows and that kind of malarkey. That's on the to-do-list too, eventually.
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 »

Sorry: that got a little full-on. :|

You know how you are supposed to be able to use:

Code: Select all

start using font file "C:/myFontFolder/myCustomFont.ttf"
and...

Code: Select all

stop using font file "C:/myFontFolder/myCustomFont.ttf"
I'm thinking of implementing the similar function:

Code: Select all

start using font [fontname]
and

Code: Select all

stop using font [fontname]
Here's a simplistic demo of how it could work:
font-loading-test.png
font-loading-test.png (11.99 KiB) Viewed 9925 times
font-loading-test.zip
(41.79 KiB) Downloaded 141 times
For this demo, you can change the name of the font you want it to load on line 40:

Code: Select all

loadedFont = new FontFace("CustomFont", "url('angelina.ttf')");
(replacing angelina.ttf with whatever you want).

In the proper version, when I build this functionality into the interpreter, you'll of course just be able to type:
start using font "angelina.ttf" -- I'm going to reference this by filename, since it's easier.
User avatar
richmond62
Posts: 5233
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

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

Post by richmond62 »

Screenshot 2025-03-23 at 20.45.47.png
Screenshot 2025-03-23 at 20.45.47.png (14.3 KiB) Viewed 9822 times
-
Um, well:

Code: Select all

start using font file "C:/myFontFolder/myCustomFont.ttf"
is NOT what you have duplicated, what you have duplicated is this sort of thing:

Code: Select all

set the textFont of fld "xxx" to "myCustomFont.ttf"
and

Code: Select all

set the textFont of fld "xxx" to empty
Not that there is anything intrinsically wrong with that.
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 »

I'm not entirely sure what you mean. The "start using font" function is intended to load a font into memory and use within a stack, that isn't installed in your normal font folder that the system uses.
In that respect, that's exactly what that javascript is doing.
You can load that custom font (angelina.ttf) into the webpage without it being installed as a font available to other programs. That's the entire point of that function, otherwise you'd just:

Code: Select all

set the textfont of field "font" to "Angelina Regular"
for example.

You could absolutely do that after the font has been loaded in with "start using..." - then use the "set the textfont..." script - but the font is not installed in the system at any point doing that. That's the entire point: so the stack creator adding custom fonts to their stack does not have to ask their end users to install fonts.
User avatar
richmond62
Posts: 5233
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

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

Post by richmond62 »

Screenshot 2025-03-23 at 21.12.36.png
Screenshot 2025-03-23 at 21.12.36.png (21.26 KiB) Viewed 9814 times
-
That would be slightly nearer . . .

HOWEVER, my HTML, while it can bung in a button, is not good enough for me to make that a drop-down menu listing all the installed fonts on my system.

Ooer:
-
Screenshot 2025-03-23 at 21.20.22.png
Screenshot 2025-03-23 at 21.20.22.png (30.26 KiB) Viewed 9809 times
Attachments
font-test.html.zip
Utter Rubbish . . .
(1.58 KiB) Downloaded 136 times
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 »

I don't think I've explained what I meant very well. I've rephrased it a bit, so please go back a couple of posts as I've tried to clarify it.
User avatar
richmond62
Posts: 5233
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, "many a slip twixt cup and lip", or between what you have written and what my addled brain has made of what you have written. 8-)

Notwithstanding that, a drop-down menu to select fonts as one might do in the Properties Palette of OXT to apply to a field, a button, or another object, might be a good thing.
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 »

richmond62 wrote: Sun Mar 23, 2025 7:25 pm Notwithstanding that, a drop-down menu to select fonts as one might do in the Properties Palette of OXT to apply to a field, a button, or another object, might be a good thing.
Ah, okay - yes, that's a different thing altogether. This is only a subset of what you might have installed on your system. You kind of have to test for fonts being available in the browser, and loop through a list. (see line 26 in the javascript). This is an old method, but one I had kicking around from a previous experiment - dug out of the archive :D
list-fonts-btn.png
list-fonts-btn.png (31.51 KiB) Viewed 12277 times
font-selector.zip
(1.58 KiB) Downloaded 65 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 »

Version 123
I've added the ByteOffset function, and added a few test cases to support it:

ByteOffset function - (Find position of 'c' in 'abcde')

Code: Select all

put byteOffset("c", "abcde") into tResult
put tResult -- returns 3
ByteOffset function - with skip parameter (Find position of 'b' in 'abacadabra' starting after 2 characters)

Code: Select all

put byteOffset("b", "abacadabra", 2) into tResult
put tResult -- returns 6
ByteOffset function - substring in string (Find position of 'bark' in 'embarking')

Code: Select all

put byteOffset("bark", "embarking") into tResult
put tResult -- returns 3
ByteOffset function - not found (Character not found in string)

Code: Select all

put byteOffset("z", "abcde") into tResult
put tResult -- returns 0 as character not found in string
ByteOffset function - negative skip count

Code: Select all

put byteOffset("c", "abcde", -1) into tResult
put tResult -- returns expected error: byteOffset: skip count must be non-negative
Attachments
documentation.pdf
(185.93 KiB) Downloaded 142 times
User avatar
richmond62
Posts: 5233
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

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

Post by richmond62 »

What would be good, be it possible, would be the ability to use a WOFF font on one's system, and then some how attach it to the HTML document.
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 »

richmond62 wrote: Mon Mar 24, 2025 7:50 am What would be good, be it possible, would be the ability to use a WOFF font on one's system, and then some how attach it to the HTML document.
You can do exactly that with my script I posted earlier. Just change the ttf reference to the name of your WOFF / WOFF2 font.
example.png
example.png (15.05 KiB) Viewed 12040 times
change.png
change.png (13.85 KiB) Viewed 12040 times
Example with a woff font (free) as edited in the example above:
Attachments
font-loading-test-b.7z
(26.27 KiB) Downloaded 144 times
User avatar
richmond62
Posts: 5233
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 was wondering as my late friend Brahmanathaswami was using a WOFF version of my Devawriter.ttf font with webpages exported from my Devawriter Pro.

Unfortunately as he has 'moved into inner worlds' (died) I cannot find out how he did that.
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 »

richmond62 wrote: Mon Mar 24, 2025 8:24 am a WOFF version of my Devawriter.ttf font with webpages exported from my Devawriter Pro.
Sounds like he might have just used an online font converter, something like anyconv or cloudconvert to convert the TTF to WOFF, then use that in a webpage.
After all, I did the same kind of thing back when I made my webpage. (which just uses "Raleway-Regular.woff")
User avatar
richmond62
Posts: 5233
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

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

Post by richmond62 »

No, he didn't: I sent him a WOFF and a WOFF2 version that I had hived off.
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 5233
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

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

Post by richmond62 »

A 'dirty' question that bubbled up in my brain:

Is the web-xTalk thing JUST an html interpreter floating in a web-page?
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 »

richmond62 wrote: Mon Mar 24, 2025 9:30 am No, he didn't: I sent him a WOFF and a WOFF2 version that I had hived off.
Well, there you are then. He probably just set that in the CSS.
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests