Home   Archive   Permalink



PASSING PARAMETERS FROM ONE SCRIPT TO ANOTHER

How do I pass a parameter from one script to another script ?
    
e.g if I have script1.r and script2.r
    
and I want to pass a parameter "hello" from within script1.r to script2.r
    
e.g in script1.r I try something like this
    
do %script2.r "Hello"
    
    
then in script2.r how do i retrieve the parameter "Hello"
    
I tried, the system/script/args in script2.r it did not work.
    
I tried the system/options/args in script2.r too it did not work.


posted by:   PASS PARAMETERS       18-Oct-2017/21:23-7:00



You can try:
    
do/args %script2.r "Hello"
    
Then check system/script/args in %script2.r

posted by:   Chris       19-Oct-2017/1:08:34-7:00



You can also save values to a third file:
    
write %data "Hello"
write %script2.r "R E B O L [] print read %data halt"
launch %script2.r
    
Or if you need to pass data to a second script in real time, send it over a network connection:
    
write %script2.r {R E B O L []    
port: open/lines tcp://localhost:55555
insert port ask "Send: "}
launch %script2.r
port: first wait open/lines tcp://:55555
print join "Received: "first wait port
    
Additionally, you can write data directly into a dynamically created script, and then execute that script some time later:
    
x: "Hello"
write %script2.r rejoin [{R E B O L [] print "} x {" halt}]
launch %script2.r

posted by:   Nick       19-Oct-2017/8:09:23-7:00



(remove the spaces in the REBOL header in each of the examples above)

posted by:   Nick       19-Oct-2017/8:18:31-7:00



BTW, you can also use 'call to run command line arguments:
    
call/show "rebol -h"

posted by:   Nick       19-Oct-2017/10:05:10-7:00



thank you Nick for the different ways of passing info between scripts.

posted by:   PASS PARAMETERS       22-Oct-2017/10:26:21-7:00



If you use Windows, you could use the clipboard if you don't suddenly use it for something else and cause a conflict:
    
R E B O L []
    
write %passtest2.r {R E B O L []
PASSED-TEXT: read clipboard://
print ["passtest2 has received " PASSED-TEXT]
halt
}
    
write clipboard:// "Hello"
print "Calling passtest2.r"
launch %passtest2.r
print "passtest2.r has been called"
halt
    


posted by:   Steven White       23-Oct-2017/13:15:44-7:00



Name:


Message:


Type the reverse of this captcha text: "i n - t n o m - n"



Home