Author Topic: "PromenHal9000" + interpreter path question  (Read 4125 times)

0 Members and 1 Guest are viewing this topic.

Frankolinox

  • Guest
"PromenHal9000" + interpreter path question
« on: April 06, 2014, 10:27:41 AM »
... lalala :)
« Last Edit: October 01, 2014, 08:14:46 AM by Frankolinox »

Charles Pegge

  • Guest
Re: interpreter path question
« Reply #1 on: April 07, 2014, 12:57:55 AM »
Hi Frank,

I agree that paths are not as simple as they look. When compiling, the current folder/directory should be the one containing your source files.

Inc files can be specified in a folder relative to the source file, or relative to the compiler/Oxygen.dll folder. Oxygen uses '$' for this purpose: includepath "$/inc/".

Charles Pegge

  • Guest
Re: interpreter path question
« Reply #2 on: April 15, 2014, 01:09:01 AM »
Hi Frank,

In OxIde:

The current directory is the source code folder.

o2dir is the full pathname to be used with gxo2.exe.
It is always assumed that Oxygen.dll is in the same folder as gxo2.exe.

f is the full name of the source file, (including its path)
It must be saved before compiling.

Exec o2dir+"\gxo2.exe "+f

Code for exec:

  function Exec(string c)
  =======================
  STARTUPINFO infs
  PROCESS_INFORMATION infp
  CreateProcess null,c,0,0,0,0,0,0,@infs,@infp
  CloseHandle infp.hProcess
  CloseHandle infp.hThread
  end function



One slight complication:

For compiled binaries, Oxygen inserts additional code into the source, and then saves it to a temporary file in the o2dir  called "_.o2bas" thus
f=o2dir+"\_.o2bas"

Charles Pegge

  • Guest
Re: interpreter path question
« Reply #3 on: May 02, 2014, 06:30:12 AM »
Hi Frank,

You can use CreateProcess or Shell Execute, as you have done. The latter is easier to setup. I have a very simple example with header info here: examples/system/ShellExecute.o2bas

Code: [Select]
'http://msdn.microsoft.com/en-us/library/windows/desktop/bb762153(v=vs.85).aspx

/*
HINSTANCE ShellExecute(
  __in_opt  HWND hwnd,
  __in_opt  LPCTSTR lpOperation,
  __in      LPCTSTR lpFile,
  __in_opt  LPCTSTR lpParameters,
  __in_opt  LPCTSTR lpDirectory,
  __in      INT nShowCmd
);


operation:
explore
find
open
print
NULL

ShowCmd:
SW_HIDE (0)
SW_MAXIMIZE (3)
SW_MINIMIZE (6)
SW_RESTORE (9)
SW_SHOW (5)
SW_SHOWDEFAULT (10)
SW_SHOWMAXIMIZED (3)
SW_SHOWMINIMIZED (2)
SW_SHOWMINNOACTIVE (7)
SW_SHOWNA (8)
SW_SHOWNOACTIVATE (4)
SW_SHOWNORMAL (1)

*/

! ShellExecute alias "ShellExecuteA" lib "Shell32.dll" _
(sys Hwnd, string operation,file,parameters,directory,sys ShowCmd) as sys

ShellExecute null,"open","..\..\gxo2.exe","helo.o2bas",null,0

Charles Pegge

  • Guest
Re: interpreter path question
« Reply #4 on: May 13, 2014, 02:29:32 AM »
Hi Frank,

You can get your compiler to add  the RTL instructions to the beginning of the source string before compiling it. This is the easiest way.

If you are using one of the standard compilers, then it is slightly more complicated. You need to create a temporary source file including the RTL, save it, then compile the adapted code. Oxide uses this technique.

Using chr(12) between the pre-source and the main source ensures that the line counter only starts counting lines in the main source code. (vital for error reporting!)

from oxide

    case 1005 'F5
      if fi=""
        SendMessage hwnd,WM_COMMAND,1009,0
      else
        s=GetText hw
        if len(s) then
          putfile fi,s
          '
          f=fi
          string m,md
          m="!"
          '
          if mo and 2
            'CREATE INDEPENDENT BINARY
            '
            if cdll then
              md="$ DLL"+cr+"$filename "+qu+o2dir+"\_.dll"+qu+cr
            else
              md="$filename "+qu+o2dir+"\_.exe"+qu+cr
            end if
            if mo and 1
              t="inc/RTL64.inc" 'CTRL-SHIFT-F5
            else
              t="inc/RTL32.inc" 'CTRL-F5
            end if
            s=md+"include "+qu+o2dir+"\"+t+qu+cr+chr(12)+s
            f=o2dir+"\_.o2bas"
            putfile f,s
            m=""

          elseif mo=1
            'f="-c "+f 'SHIFT-F5 CREATE DEPENDENT BINARY
            if cdll
              md="_.dll"
            else
              md="_.exe"
            end if
            s="#file "+qu+o2dir+"\"+md+qu+cr+chr(12)+s
            f=o2dir+"\_.o2bas"
            putfile f,s
            m=""
          end if
          'Exec o2dir+"\co2.exe",o2dir+"\co2.exe "+m+f
          Exec o2dir+"\gxo2.exe "+f
        end if
      end if