BBC BASIC
« PROCexecute »

Welcome Guest. Please Login or Register.
Oct 24th, 2017, 11:04am


Cross-platform BBC BASIC (Win32, Linux x86, Android, Mac OS-X, Raspberry Pi)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: PROCexecute  (Read 60 times)
michael
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 101
question PROCexecute
« Thread started on: Sep 24th, 2017, 5:03pm »

Suppose I have my renderer program in the same directory as the editor. How exactly does this procedure work?

All I am looking for is an example of using it to execute the second program. Obviously, I haven't got it right.

Code:
 
REM PROGRAM starts
PROCexecute("RENDER.BBC", "")

END
DEF PROCexecute(bbcfile$, flag$)
      ON ERROR LOCAL IF FALSE THEN
        IF BB4W% THEN
          OSCLI "RUN """ + @lib$ + "..\bbcwrun6.exe"" """ + bbcfile$ + """;"
        ELSE
          CASE @platform% AND &FF OF
            WHEN 0:
              SYS "WinExec", """" + @lib$ + "..\bbcsdl"" """ + bbcfile$ + """ " + flag$, 1
            OTHERWISE:
              OSCLI "RUN """ + @lib$ + "../bbcsdl"" """ + bbcfile$ + """ " + flag$ + ";"
          ENDCASE
        ENDIF
      ENDIF : RESTORE ERROR
      ENDPROC  
« Last Edit: Sep 24th, 2017, 5:04pm by michael » User IP Logged

I like reinventing the wheel, but for now I will work on tools for D3D
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 605
question Re: PROCexecute
« Reply #1 on: Sep 24th, 2017, 7:22pm »

on Sep 24th, 2017, 5:03pm, michael wrote:
All I am looking for is an example of using it to execute the second program. Obviously, I haven't got it right.

The main problem with your code is that you don't pass a fully-qualified path name. Specifying the program to be run as simply "RENDER.BBC" is asking for trouble: in Windows and Linux it may work, but only if the 'current directory' is set correctly (and remember that the 'current directory' is not necessarily the same as the directory containing your program). In Android it will not work at all because there is no such thing as the current directory!

Therefore it is very important to pass an 'absolute' path and file name. Usually that is easy because BB4W and BBCSDL provide the system variables @tmp$, @lib$, @dir$ and @usr$ and often one of those will be the directory you want. Even if it isn't, the required directory will sometimes be in a place that can be reached relative to one of those. However, a word of caution: the OSCLI statement has a limited string length so there is a danger of exceeding that if your file path is deeply nested.

Also, be careful with case-sensitivity - ideally test your code in Linux and/or Android in which filenames are case-sensitive. With those issues tackled the code you listed should work correctly (you've not shown the code that sets the global Boolean BB4W% but of course that must be initialised somewhere, or replaced by the equivalent INKEY).

Richard.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Donate $6.99 for 50,000 Ad-Free Pageviews!


This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls