User Tools

Site Tools


discovering_20how_20a_20program_20was_20run

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
discovering_20how_20a_20program_20was_20run [2018/03/31 13:19] – external edit 127.0.0.1discovering_20how_20a_20program_20was_20run [2024/01/05 00:22] (current) – external edit 127.0.0.1
Line 7: Line 7:
   * Running a compiled program   * Running a compiled program
 \\  To determine the environment a program is running in use code similar to the following:\\  \\  To determine the environment a program is running in use code similar to the following:\\ 
 +<code bb4w>
         SYS "GetCommandLine" TO cmd%         SYS "GetCommandLine" TO cmd%
         CASE TRUE OF         CASE TRUE OF
Line 13: Line 14:
           OTHERWISE:PRINT "Program is compiled"           OTHERWISE:PRINT "Program is compiled"
         ENDCASE         ENDCASE
 +</code>
 Here we read a pointer to the command line arguments used to start the program and **PRINT** a different response for each possible case. It is not possible to use the special variable **@cmd$** as this contains insufficient information.\\ \\  Refactoring this code into a function is simple:\\  Here we read a pointer to the command line arguments used to start the program and **PRINT** a different response for each possible case. It is not possible to use the special variable **@cmd$** as this contains insufficient information.\\ \\  Refactoring this code into a function is simple:\\ 
 +<code bb4w>
         DEF FN_GetRunEnvironment         DEF FN_GetRunEnvironment
         LOCAL cmd%, ret%         LOCAL cmd%, ret%
Line 23: Line 26:
         ENDCASE         ENDCASE
         =ret%         =ret%
 +</code>
 Here we create a function named **FN_GetRunEnvironment** which returns one of three possible values:\\ \\  Here we create a function named **FN_GetRunEnvironment** which returns one of three possible values:\\ \\ 
  
Line 31: Line 35:
 ---- ----
 \\ //by Richard Russell, November 2010//\\ \\  If you want to know whether a program is compiled or not, you can use this simple test:\\  \\ //by Richard Russell, November 2010//\\ \\  If you want to know whether a program is compiled or not, you can use this simple test:\\ 
 +<code bb4w>
         IF INSTR(@lib$,@tmp$) THEN PRINT "Program is compiled"         IF INSTR(@lib$,@tmp$) THEN PRINT "Program is compiled"
 +</code>
discovering_20how_20a_20program_20was_20run.1522502355.txt.gz · Last modified: 2024/01/05 00:18 (external edit)