Author Topic: Better Gxo2.exe Command Line Pls  (Read 3869 times)

0 Members and 1 Guest are viewing this topic.

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1871
Better Gxo2.exe Command Line Pls
« on: September 20, 2014, 08:47:51 AM »
Hi Charles,

Current gxo2.exe seems incapable of forwarding command line parameters to the O2 scripts that it is supposed to run in a JIT compilation mode. It tends to regard everything that follows its own name in the command line as the name of an O2 script.

Thus

gxo2.exe c:\oxylisp\oxylisp.o2bas -v -t -p robscode.scm

is parsed into gxo2.exe which is OK and "c:\oxylisp\oxylisp.o2bas -v -t -p robscode.scm" which is KO because there's no such file as "c:\oxylisp\oxylisp.o2bas -v -t -p robscode.scm" for gxo2.exe to run.

In my humble opinion, gxo2.exe should be augmented with a decent command line parser that would be able to isolate oxylisp.o2bas (enquoted or not, fully qualified pathname or otherwise) and launch it for execution letting the script enjoy its own command line parameters split with its own command line parser.


Would that be feasible, do you think? :)

Thanks!


(Post scriptum: Can we also have genuine console mode exe compilation, please?)
« Last Edit: September 22, 2014, 06:20:48 AM by Mike Lobanovsky »
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3837
    • Oxygen Basic
Re: Better Gxo2.exe Command Line Pls
« Reply #1 on: September 20, 2014, 11:59:19 AM »
Hi Mike,

Updated compilers to ignore text following the filename, on the command-line. So you can now add additional commands without confusing the compiler parser.

exo2 is for compiling in the console. gxo2 does not use the console, and is good for launching scripts directly jit from their icons (by file association 'o2bas'). I am still a Notepad addict :)

source for these compilers: projectsA\Compilers\Exo2FB
« Last Edit: September 21, 2014, 09:43:59 PM by Charles Pegge »

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1871
Re: Better Gxo2.exe Command Line Pls
« Reply #2 on: September 20, 2014, 01:33:00 PM »
Charles,

Thanks again for your unparalleled co-operation for my needs. The reward will come in a minute in the Lisp in Basic thread. :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1871
Re: [SOLVED] Better Gxo2.exe Command Line Pls
« Reply #3 on: September 20, 2014, 02:32:45 PM »
As an afterthought, why a separate console compiler if just one byte in the entire program (in its PE header, to be pecise) is all you have to change to turn your GUI program into a CUI program? Why not just "compile" (or patch, for that matter) this very byte conditionally in response to, say, a #COMPILE GUI|CUI directive in the script?
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3837
    • Oxygen Basic
Re: [SOLVED] Better Gxo2.exe Command Line Pls
« Reply #4 on: September 20, 2014, 09:11:27 PM »

Thanks Mike,

One reason for having a separate console compiler, even for a GUI program, is for capturing assembler and machine code listings etc. to stdout instead of the messagebox. I suppose it could be done with a compiler switch.

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3837
    • Oxygen Basic
Re: [SOLVED] Better Gxo2.exe Command Line Pls
« Reply #5 on: September 21, 2014, 09:55:31 PM »
Cracked it!

gxo2 is now a dual-use compiler. Use the -m switch to output to stdout (console), instead of the message box.


Example:

store assembler listing of t.o2bas to t.txt

gxo2 -m -a t.o2bas > t.txt

.

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1871
Re: [SOLVED] Better Gxo2.exe Command Line Pls
« Reply #6 on: September 21, 2014, 11:53:43 PM »
Great! :D

And see how tiny it is -- 7KB smaller than before! It should be tied up with a pink ribbon and upxed to the GNU JIT guys for reference in their future work.

Can I delete exo2.exe safely from the O2 installation now?
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3837
    • Oxygen Basic
Re: [SOLVED] Better Gxo2.exe Command Line Pls
« Reply #7 on: September 22, 2014, 01:45:13 AM »
Yes, exo2.exe will no longer be included in OxygenBasic.zip, but the source code will remain available in ProjectsA/Compilers/Exo2Fb.

One improvement I am also making to console.inc, is to enable attachment to a parent process console if STDOUT exists. Otherwise a new console is allocated as before.

Code: [Select]
  sys ConsOut,ConsIn,ConsErr

  ConsOut = GetStdHandle STD_OUTPUT_HANDLE
  ConsIn = GetStdHandle STD_INPUT_HANDLE
  '
  if ConsOut then
    AttachConsole -1 'attach to console of parent process
  else
    AllocConsole
    ConsOut = GetStdHandle STD_OUTPUT_HANDLE
    ConsIn = GetStdHandle STD_INPUT_HANDLE
  end if

To accept redirected inputs and outputs,  ReadFile and WriteFile are used instead of ReadConsole and WriteConsole.



.

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1871
Re: [SOLVED] Better Gxo2.exe Command Line Pls
« Reply #8 on: September 22, 2014, 01:54:19 AM »
OxyLISP stopped working with your new Console.inc and gxo2.exe hangs in memory. :(
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3837
    • Oxygen Basic
Re: [SOLVED] Better Gxo2.exe Command Line Pls
« Reply #9 on: September 22, 2014, 04:08:47 AM »
Mike,

This attachment is a 64bit command console made with the new console.inc

Could you please try it on your system, and see if it works. I hope we do not have a platform issue.

.

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1871
Re: [SOLVED] Better Gxo2.exe Command Line Pls
« Reply #10 on: September 22, 2014, 06:02:24 AM »
Don't know what the program should do but my observations are as follows:

Instance 1: launched by double click; crashes on pressing Enter immediately when loaded.

Instance 2: launched by double click; accepts keyboard input other than immediate Enter, advances to new line OK on Enter after a few other keypresses; stays in memory until closed with [X].

Instance 3: launched from Admin console; shares console OK but breaks back to shell immediately on pressing Enter when loaded.

Instance 4: launched from Admin console; shares console, accepts input other than Enter, breaks back to shell on pressing Enter after a few other keypresses.


(P.S. Going back to 32 bits now)

.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3837
    • Oxygen Basic
Re: Better Gxo2.exe Command Line Pls
« Reply #11 on: September 22, 2014, 11:02:18 AM »
Thanks Mike,

Reverting to the original console.inc with some metacoding, I have two more specimens.

They do not attempt to attach to any parent console. No more crashes I hope!

What happens when you use them  to execute this command?

gxo2 -m>t.txt

If you are in a 32bit environment, pls ignore the 64bit one.

.

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1871
Re: Better Gxo2.exe Command Line Pls
« Reply #12 on: September 22, 2014, 11:36:47 AM »
1. This new Console.inc seems to work for OxyLISP as expected.

2. The 32-bit console seems to run without crashes, executes shell commands, launches OxyLISP for execution, but the resultant t.txt is empty.

Now going 64 bits to test the other exe. (haven't much else to do with inoperative floats, hehe...)

.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1871
Re: Better Gxo2.exe Command Line Pls
« Reply #13 on: September 22, 2014, 12:23:25 PM »
Reporting from 64 bits...

Instance 1: when launched by double click or as Admin, console crashes at an attempt to hit Enter on the first empty line.

Instance 2: when launched by double click or as Admin and Enter is not hit initially, executes shell commands as expected, launches oxylisp.o2bas for execution, but the t.txt file remains empty as it did under 32 bits.

So the only difference with 32 bits that I'm seeing so far is the crash that occurs when the console has just opened and Enter is hit on its initially empty first line.

.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3837
    • Oxygen Basic
Re: Better Gxo2.exe Command Line Pls
« Reply #14 on: September 22, 2014, 01:24:46 PM »
Thank you Mike,

The 64bit console never crashes on my vista system. Are you on Windows 7? -  I'm puzzled that this occurs on the first empty return.

The new gxo2 should direct the console stdout into the t.txt file. The original gxo2 cannot do it, and cannot output to the console.