Oxygen Basic
Programming => Bugs & Feature Requests => Topic started by: Mike Lobanovsky 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?)
-
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
-
Charles,
Thanks again for your unparalleled co-operation for my needs. The reward will come in a minute in the Lisp in Basic thread. :)
-
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?
-
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.
-
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
.
-
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?
-
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.
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.
.
-
OxyLISP stopped working with your new Console.inc and gxo2.exe hangs in memory. :(
-
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.
.
-
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)
.
-
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.
.
-
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...)
.
-
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.
.
-
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.
-
That wasn't the original ("old") gxo2 in both cases, Charles. The latest ("old") gxo2 that you sent me wasn't able to read past the o2bas script name. The gxo2 message box (unthemed BTW) signaled "file oxylisp.o2bas -m is empty or not found" under both 32 and 64 bits. So it's the new gxo2 that can't dump asm under my XP Sp3 or Win 7 (yes, it's 64-bit 7 that I'm running) for whatever reason. The t.txt files were empty in both cases. :-\
-
Mike,
The next time you are on a 64bit platform, could you pls try this OxCommand. I think the previous crashed due to garbage on the upper 32 bits of the returned CharsRead param in ReadConsole. This should be read as a 32 bit (long) value. So I have changed all the relevant prototypes in console.inc.
.
-
Charles,
Console.inc works for me but the new exe behaves exactly like the old one. It keeps crashing on Enter if the topmost (initial) line is empty. All other returns, empty or otherwise, are treated correctly.
If you need some more specific tests from me, please don't hesitate to say so.
-
Thanks Mike,
Here is another one to crash test:
.
-
You did it, Charles! :)