Beginner Question #1: FrontScripts

All flavors welcome.
Forum rules
Be kind.
Post Reply
User avatar
richmond62
Posts: 4594
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Beginner Question #1: FrontScripts

Post by richmond62 »

[And I'll apologise in advance, having worked with HC, MC, LC, and OXT for 32 years]

WHAT is a frontScript?

WHAT might be the purpose of a frontScript?

WHERE do you put a fontScript?
https://richmondmathewson.owlstown.net/
User avatar
tperry2x
Posts: 3049
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: Beginner Question #1: FrontScripts

Post by tperry2x »

A frontscript can be any object with an ID - for example, if you type "put the frontscripts", you'll get a list:
frontscripts.png
frontscripts.png (8.64 KiB) Viewed 711 times
Frontscripts are scripts that will be checked and processed before anything else. So, for example if something in the frontscripts has an "on opencard" handler (and has pass opencard), then the opencard message moves down the chain of things listed in the frontscripts until it gets to your card and checks the opencard message there.

In essence, it's a list of priority in which things are processed. That's the purpose of it, to allow things to move along the message path (the order in which messages are dealt with).

As far as putting a frontScript, you don't really put it anywhere as it's already part of your stack.
You might wonder how you bring your script to the top of that list of the frontscripts. (so that it executes before anything else).

If you had a card script, you could do:

Code: Select all

insert the script of this card into front
then if you run "put the frontscripts", you'll see your card is at the top of the list (top of the message path), which means this will be checked first.

Does that make sense?
User avatar
richmond62
Posts: 4594
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Beginner Question #1: FrontScripts

Post by richmond62 »

OK: So, nothing special really.

This:

Code: Select all

on preOpenStack
  set this stack to the screenLoc
  end preOpenStack
is a frontScript (I assume).

Just that I have never called it that. 8-)
https://richmondmathewson.owlstown.net/
User avatar
tperry2x
Posts: 3049
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: Beginner Question #1: FrontScripts

Post by tperry2x »

No, as it's not inserting itself into the frontscripts - that's just a handler that is run by the engine before a stack is opened.
That's hard-coded to be checked on opening a stack, whereas inserting something into the frontscripts makes the list of things to check customisable.

You are going to ask me what the backscripts are now, I can feel it :lol:
The backscripts are the inverse of this - things in the backscripts execute AFTER the items in the frontscripts. AND after things that you've not added to the frontscripts. Say for example mouseup on a button. The frontscripts are checked first and their code run through, one item at a time. Then after those are all processed, the script in your button is run, then after that's done - all the things in the backscripts are checked one at a time and run through too.

You could think of it like pendingmessages, except you aren't having to continuously send [message] to [object] in [number] [milliseconds,seconds etc]
Things placed in the frontscripts and the backscripts remain being checked in the order shown by:

Code: Select all

put the frontscripts
and

Code: Select all

put the backscripts
(you'll probably be surprised by the amount of things going on behind the scenes, particularly in the backscripts)

So, if you wanted to remove something from the backscripts (and keeping the example of a card script) - you can also do:

Code: Select all

remove the script of this card from back
This is a handy method for loading user-plugins on-the-fly, without having to restart the IDE to see changes. It's what I was going to use if I ever made a customisable xTalk-language user plugins directory. My idea at one point was to use this method to allow users to create their own plugins in the tools palette, like actions / macros in photoshop for example. However I've shelved that idea as I'm focussed on trying to get the engines to at least compile at the moment. I'm trying to do one thing at a time, as otherwise there's too many to-do lists which become unmanageable.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests