BBC BASIC
« PROCexecute »

Welcome Guest. Please Login or Register.
Mar 31st, 2018, 10:43pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Cross-platform BBC BASIC (Windows, Linux x86, Mac OS-X, Android, iOS, Raspberry Pi)
BBC BASIC Resources
BBC BASIC Help Documentation
BBC BASIC for Windows Home Page
BBC BASIC Programmers' Reference
BBC BASIC Beginners' Tutorial
BBC BASIC for SDL 2.0 Home Page
BBC BASIC Discussion Group

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


member is offline

Avatar




PM


Posts: 157
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: 803
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 »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls