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?
Calling Other Scripts From A Main Script
Calling Other Scripts From A Main Script
Development System : Imac G5, MorphOs 3.19
Re: Calling Other Scripts From A Main Script
yes you cant make functions in hws only way
but whats the reason to "Call a script" ?
but whats the reason to "Call a script" ?
Christos
Re: Calling Other Scripts From A Main Script
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.
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
Re: Calling Other Scripts From A Main Script
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
Re: Calling Other Scripts From A Main Script
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
Re: Calling Other Scripts From A Main Script
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.
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.