RosettaCodeData/Task/Metaprogramming/Run-BASIC/metaprogramming.basic

33 lines
1.5 KiB
Plaintext

' ---------------------------------------------------
' create a file to be run
' RB can run the entire program
' or execute a function withing the RUNNED program
' ---------------------------------------------------
open "runned.bas" for output as #f ' open runned.bas as output
print #f, "text$ = ""I'm rinning the complete program. ' print this program to the output
Or you can run a function.
The program or function within the RUNNED program
can execute all Run BASIC commands."""
print #f, "
x = displayText(text$)"
print #f, " ' besides RUNNING the entireprogram
Function displayText(text$) ' we will execute this function only
print text$ '
end function"
' ----------------------------------------
' Execute the entire RUNNED program
' ----------------------------------------
RUN "runned.bas",#handle ' setup run command to execute runned.bas and give it a handle
render #handle ' render the handle will execute the program
' ----------------------------------------
' Execute a function in the RUNNED program
' ----------------------------------------
RUN "runned.bas",#handle ' setup run command to execute runned.bas and give it a handle
#handle displayText("Welcome!") ' only execute the function withing the runned program
render #handle ' render the handle will execute the program