mmiscool
Full Member
Send me a message if you want to help with a WEB OS project
Posts: 106
|
Post by mmiscool on Sept 8, 2012 20:22:29 GMT -5
Hello,
If I run a program like
run "upload thing", #upthing
render #upthing
wait
and use the upload command in the program called "uplad thing" it will not work and will crash rb.
Jut figured I would let you know.
|
|
|
Post by StefanPendl on Sept 9, 2012 4:19:08 GMT -5
If I remember correctly, this has already been reported, but thanks for the reminder.
|
|
|
Post by meerkat on Sept 9, 2012 10:14:04 GMT -5
Since the Upload does not work in the program that was run, the trick is to run the code in the main program. You can pass data in the UserInfo$. You can hide a button in the main program that you do not see, but the RUNNED programs can get to it. This makes it possible to run code in the main RUNNITG program. You basically click a hidden, or visible if you like, [button] in the main program from your RUNNED program. Plus you only have one set of code to do uploads in all your RUNNED programs. I also use this method for code that is repeated in many RUNNED programs so I only have one set of code for the system.
It works for me. Something similar to this should work:
'==================================== 'in the main program
CSSClass ".hide", "{visibility: hidden; height:0px; bprder:none}"
button #upload, "Upload" ,[doUpload] #upload cssclass("hide") #upload setid("upload")
incdir$ = DefaultDir$ + "\projects\your_project\" prog$ = "yourProgram.bas run incdir$;prog$,#include render #include
wait
' ----------------------------------------- ' Do Upload ' ----------------------------------------- [doUpload] uploadId$ = word$(UserInfo$,1,"|") photoWide$ = word$(UserInfo$,2,"|") photoHigh$ = word$(UserInfo$,2,"|") photoWide = val(photoWide$) photoHigh = val(photoHigh$)
upload ""; uploadId$
f$ = photoDir$;uploadId$ files #f, f$ if #f HASANSWER() then errNum = errNum + 1 errMsg$(errNum) = "Photo: ";uploadId$;" is already in photo directory" gosub [doMsg] wait end if
' ------------------------------------- ' load photo to photo directory ' ------------------------------------- OPEN uploadId$ FOR binary AS #f filedata$ = input$(#f, LOF(#f)) CLOSE #f
OPEN f$ FOR binary AS #f PRINT #f, filedata$ CLOSE #f
loadgraphic #g, f$ photoHigh = #g height() photoWide = #g width() photoHigh$ = str$(photoHigh) photoWide$ = str$(photoWide) #g discard()
photoId$ = uploadId$
w = (photoWide / photoHigh) * 200 ' This puts the photoId, width etc back into <input values in the RUNNED program html "<script> document.getElementById('photoId').value = '";photoId$;"';</script>" html "<script> document.getElementById('photoWide').value = '";photoWide$;"';</script>" html "<script> document.getElementById('photoHigh').value = '";photoHigh$;"';</script>" html "<script> document.getElementById('photo').innerHTML = '" html "<IMG SRC=";photoPath$;photoId$;" width=";w;">" html "';</script>" wait
'================================= ' in the runned program
button #upld, "Upload Maintenance",[doUpload] #upld setid("upldMe") html "<script>document.getElementById('upldMe').name = document.getElementById('upload').name;</script>"
|
|