Calling Other Scripts From A Main Script

Find quick help here to get you started with Hollywood
Post Reply
oceanarts
Posts: 111
Joined: Mon May 27, 2024 10:42 pm

Calling Other Scripts From A Main Script

Post by oceanarts »

It seems to me that it should be possible to call a separate "subscript" from a main script, let it run in its entirety and then return control to the main script.
I've tried the @INCLUDE pre-processor, but it seems, according to the docs, I can only reference individual functions using this.

Is this correct, or am I misunderstanding its use?
Development System : Imac G5, MorphOs 3.19
plouf
Posts: 666
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: Calling Other Scripts From A Main Script

Post by plouf »

yes you cant make functions in hws only way

but whats the reason to "Call a script" ?
Christos
oceanarts
Posts: 111
Joined: Mon May 27, 2024 10:42 pm

Re: Calling Other Scripts From A Main Script

Post by oceanarts »

I'm sorry if my wording is causing confusion.

The thing is I've written a mini-game which is supposed to be part of a larger project. It's in its own script and it would just be easier if there was a way to run it from the main program and have it return once it's finished or otherwise exited.
Development System : Imac G5, MorphOs 3.19
plouf
Posts: 666
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: Calling Other Scripts From A Main Script

Post by plouf »

if you make this "Script" a big function, and you call this function from main script , will do do just that don;t it ?!
Christos
User avatar
emeck
Posts: 191
Joined: Fri Apr 03, 2015 3:17 pm

Re: Calling Other Scripts From A Main Script

Post by emeck »

@oceanarts

Try with Execute() or Run(). Run/execute Hollywood and pass the script as an argument. Haven't tried it myself but it should work.

Regards
PowerBook 5.8 MorphOS 3.18
Mac Mini MorphOS 3.18
oceanarts
Posts: 111
Joined: Mon May 27, 2024 10:42 pm

Re: Calling Other Scripts From A Main Script

Post by oceanarts »

Thanks for the tips. It didn't occur to me I could encase the whole thing in one big function.
Development System : Imac G5, MorphOs 3.19
zylesea
Posts: 231
Joined: Tue Feb 16, 2010 12:50 am
Location: Westfalen/Germany
Contact:

Re: Calling Other Scripts From A Main Script

Post by zylesea »

I suggest to use the Run() command if you want to keep your daughter script also as a stand alone program.
You shoud set up a message port in your daughter script and an EventHandler:

CreatePort("daughter_script_MSGPORT") ;Message port for Interprocess communication
InstallEventHandler({OnUserMessage = p_EventFunc})

In your main script you need to check whether the script exists, if so launch it by Run()

If Exists ("drawer/daughter_script") Then Run ("drawer/daughter_script")

With the message port you can pass on some control items (like defined in your event function to your daughter program from the main program.

For example to iconify or deiconify the dauhter program you can do the following:

in main programm:
SendMessage("daughter_script_MSGPORT", "ICONIFY")
or
SendMessage("daughter_script_MSGPORT", "DE_ICONIFY")

The daughter program needs in its event functions a chapter like this:

Case "OnUserMessage":
Switch msg.command
Case "ICONIFY"
HideDisplay()
Case "DE_ICONIFY"
ShowDisplay()
EndSwitch

Works nice for me.
Post Reply