BB___RUN

=RUN= toc

Description
> Executes any executable program or script from within a JustBASIC program. The JB program will continue to run. The full path must be included if the program to run is not within the current directory, except standard Windows programs that are included with all Windows installations, (e.g. notepad.exe; calc.exe, etc.), do not require a path. An optional "//mode//" can be used //(you better check if it works with your program, Help says it works with "Windows program", but it looks working with QBasic.EXE, FTP.EXE, ...)//.

Syntax

 * 1) run //"programname"//
 * 2) run //"programname", mode//
 * 3) run //"programname [path\]filetorun"//
 * 4) run //"programname [path\]filetorun", mode//

> Program Window Modes > HIDE (//activates the application, but hides it from the user//) > SHOWNORMAL (//**this is the default** - activates and shows the application//) > SHOWMINIMIZED (//activates the application, but minimizes it to the taskbar//) > SHOWMAXIMIZED (//activates the application in a full screen window//) > SHOWNOACTIVE (//shows a window in its most recent size and position without activating it//) > SHOW (//activates an application and shows it in its current size and position//) > MINIMIZE (//minimizes a window and activates the next window in the Z order//) > SHOWMINNOACTIVE (//minimizes an application, leaving the current active window active//) > SHOWNA (//displays the window in its current state. the active window remains active//) > RESTORE (//activates the application and displays the window//)

Hints
> Be aware that hidden program might be left working even after JB program terminates. The only way to terminate hidden program is via Task Manager.

> If you are going to run other program not hiding it and keep input focus in your application, use //NOACTIVE// variants.

Run *.tkn file
code format="lb" ' Running FreeForm-J from current directory run "fformj060906.tkn" ' Running with full path. Must include the runtime engine in the application path. run "c:\Just BASIC v1.01\jbrun101.exe c:\Just BASIC v1.01\fformj060906.tkn"

' The mode parameter does not work with this program. code

Synchronous vs asynchronous
As was stated, "The JB program will continue to run". More precisely, then running EXE program, (or BAT file), JB continue to line following RUN statement instantly, without waiting for RUN'd program to finish. (actually JB has no means to tell if it finished). This is, EXE program runs asynchronously. If you run another JB program via runtime code format="lb" run "jbrun101.exe myProg.tkn" code , your code will continue instantly along with running myProg.tkn. if you run TKN without mentioning runtime engine code format="lb" run "myProg.tkn" code , your code will *HALT* and *WAIT* till code in myProg.tkn finishes. This is, TKN program runs synchronously. Probably this way, it uses same engine as your main (caller) program.
 * BUT**
 * //this is not documented - experiment first.//**

Example
code format="lb" ' Run a Windows program run "calc.exe"

' Run Windows program minimized run "calc.exe", MINIMIZE

' Run text editor with text file opened run "notepad.exe C:\Just BASIC v1.01\TUTORIAL\LETTER.TXT" ' Sometimes, you may have to separate the application from the file to open ' and add double quotes (") when spaces are included in a file-spec. This example   ' shows the method.    run "notepad.exe "; CHR$(34); "C:\Just BASIC v1.01\TUTORIAL\LETTER.TXT"; CHR$(34) code

Run URL in default browser: (checked on XP, please check on higher versions of Windows) code format="lb" url$ = "http://justbasic.conforums.com/index.cgi?board=code" run "rundll32.exe url.dll,FileProtocolHandler ";url$ code

Actually it runs documents with it's default associated program, too! code format="lb" url$ = "c:\myWordFiles\myDocument01.doc" '-- if only this path \ file exists run "rundll32.exe url.dll,FileProtocolHandler ";url$ 'this line will try to open it in default program (likely MS Word) code

Useful Functions
code format="lb" Place a useful function using this command here code