Post by meerkat on May 12, 2021 6:28:00 GMT -5
As you are finding out, there are lots of ways to pass information. You just need to pick the one that works best for you.
For me, I have some really complex programs with lots of data that is updated into the DB with each program. Therefore I basically only need to know who the user is, and maybe a few other things.
What that in mind, I tried your programs and your programs work with a couple of changes I made.
I placed the programs in a Run Basic project called "ad" and published it..
I placed prog1.bas in the ad project and saved it as ad.bas so that you can run ad directly...
Here are your programs with only a couple of minor changes. I tested them and they worked
ad.bas referred to as prog1.bas
---------------------------------
prog2.bas
this is saved in run basic ad project
For me, I have some really complex programs with lots of data that is updated into the DB with each program. Therefore I basically only need to know who the user is, and maybe a few other things.
What that in mind, I tried your programs and your programs work with a couple of changes I made.
I placed the programs in a Run Basic project called "ad" and published it..
I placed prog1.bas in the ad project and saved it as ad.bas so that you can run ad directly...
Here are your programs with only a couple of minor changes. I tested them and they worked
ad.bas referred to as prog1.bas
' Uncomment this css if you wanna hide the return button
'CSSClass ".hide", "{visibility: hidden; height:0px; bprder:none}"
' program1
print
print "Enter User Name: ";
textbox #username, ""
print
print "Enter Password: ";
passwordbox #password, ""
print
print
link #doAction, "Continue", [doAction]
#username setfocus()
wait
' returns here from prog2
[main]
print "------------------------------------------------------------------------"
print "Hello from prog 1"
print "-----------------"
userName$ = word$(UserInfo$,1,"|")
passWord$ = word$(UserInfo$,2,"|")
pass$ = word$(UserInfo$,3,"|")
print "Returned from prog2:";userName$;chr$(9);passWord$;chr$(9);"-- pass -->";pass$
' do something
wait
[doAction]
userName$ = #username contents$()
passWord$ = #password contents$()
sessionID$ = "my_md5_hash"
'open sessionID$; ".txt" for output as #txt
'#txt "userName="; userName$
'#txt "passWord="; passWord$
'close #txt
'html "</br></br><a href='?app=program2&sid="; sessionID$; "' target='_blank'>Next</a>"
' ----------------------------
' Do prog 2
' -----------------------------
[doProg2]
prog$ = "prog2.bas"
runProgData$ = "Anything you want to pass to program 2"
goto [doRun]
' -------------------------------------------
' Run program
' -------------------------------------------
[doRun]
runAction$ = "maint" ' a way to tell it what you want it to do
cls
runProg$ = "menu" ' who is running it
' ---- pass user number and name and what maint they can do, who ran it, and data to pass
UserInfo$ = userName$;" |";passWord$;" | hello program 2"
button #rtna, "Go back to prog1 (ad.bas)" ,[main]
#rtna cssclass("hide") ' hide the [exit app] button
#rtna setid("exitApp")
incdir$ = DefaultDir$ + "\projects\ad_project\" ' program to include is at RP ad_project
run incdir$;prog$,#include
render #include
wait
end
---------------------------------
prog2.bas
this is saved in run basic ad project
' program2
print
print "Hello from prog 2"
print "-----------------"
print "UrlKeys$: "; UrlKeys$
print "UserInfo$: "; UserInfo$
userName$ = word$(UserInfo$,1,"|")
passWord$ = word$(UserInfo$,2,"|")
pass$ = word$(UserInfo$,3,"|")
print " FROM ad.bas "
print "userName$";userName$
print "passWord$";passWord$
print "pass$";pass$
pass$ = "hello prog 1" ' pass back to program 1
UserInfo$ = userName$;"|";passWord$;"|";pass
wait
i = 1
while word$(UrlKeys$, i, "&") <> ""
urlKey$ = word$(UrlKeys$, i, "&")
option$ = word$(urlKey$, 1, "=")
value$ = word$(urlKey$, 2, "=")
if option$ = "sid" then
sessionID$ = value$
end if
i = i + 1
wend
print
print "sessionID$: "; sessionID$
open sessionID$; ".txt" for input as #txt
while not(eof(#txt))
line input #txt, theLine$
option$ = word$(theLine$, 1, "=")
value$ = word$(theLine$, 2, "=")
select case option$
case "userName"
userName$ = value$
case "passWord"
passWord$ = value$
end select
wend
close #txt
print
print "userName$: "; userName$
print "passWord$: "; passWord$
end