wryhode 2025-07-27 21:54 (Edited)
Here's a (poorly written) preprocessor written in Python to shoehorn functions into LowRes NX, as mentioned by Pablo in this post.
This is my first exercise in writing a language processing thingy and it probably shows. The code is uncommented and kinda hard to read. The most important lines are FILE_INPUT = ... and ' FILE_OUTPUT = ...
which are the input and output paths. I didnt bother making it take arguments so you'll have to change that yourself.
You must define your functions before they are used in the program.
A function is defined by FUNCTION {NAME}({Comma separated argument list})
and is ended with END FUNCTION
.
Arguments can be both strings and numbers, and a function can return both types as well. Returns are done with RETURN {Value or expression}
. Return type is detected automatically, but it might be wrong.
Functions can be called everywhere a normal expression can be used, but functions cant be used as arguments for other functions.
The example program:
FUNCTION ADDNUMBERS(A, B)
RETURN A + B
END FUNCTION
PRINT ADDNUMBERS(2, 2)
Should yield:
R = 0
RS$ = ""
SUB ADDNUMBERS(R, A, B)
R = A + B
END SUB
CALL ADDNUMBERS(R, 2, 2)
PRINT R
wryhode 2025-07-27 21:57
Program download link. This goes to a MEGA.nz folder. It contains the python file, a test program and its output.
Pablo 2025-07-29 08:39 (Edited)
Inspiring work, what is the license for it?
Edit: Functions returning strings aren't working for me, using python 3.11. I got this output from your test program, lines 36 and 39 are missing the argument to PRINT:
wryhode 2025-07-29 09:13 (Edited)
Its as public domain as you can get. Not something im proud of anyways lol.. and yeah i know about that, sorry, i tried fixing it but its too cluttered and i couldnt bother sorry
This whole program is a little cursed.. Id probably do it differently now. We'll see if theres ever a new version.
Pablo 2025-07-29 19:40
Thanks i'll use it as is, it's a very cool thing for lowresnx :)