How To

Virtual disk

2

Lolzrlk22 2024-03-11 23:16 (Edited)

I am a begginer and i wanted to know if it is possible to load the code from a virtual disk into a program, and run it
example: the virtual disk has a code that executes print "hello world"
and I would like to make the disk code run in another program


nathanielbabiak 2024-03-12 00:55 (Edited)

No, this is not possible. This virtual console does not compile source code into any sort of data format that is accessible by the interpreter.

For example, the instruction PRINT "HELLO WORLD" sits in your (.nx) source code file, but you are unable to write additional lines of code that refer to the... compiled "version" of this instruction.


Lolzrlk22 2024-03-12 02:04

Thank you,dude


was8bit 2024-03-12 03:33

You can use the TOOL mode to edit a data file in the virtual disk…

THEN you can write code for that program that reads that file and executes different commands based on the data it reads…

So, your data file should either use set spacing or some other method that lets your code read and execute the commands correctly…

EXAMPLE DATA:
:PRINT:”HELLO WORLD”

Your code would then identify a command between the two : : and it should identify the text in between the two “ “

So your code would pull
COM$=“PRINT”
DAT$=“HELLO WORLD”

And then your code would execute…
IF COM$=“PRINT” THEN PRINT DAT$


…. Using this complicated method, you CAN effectively accomplish what you wanted, just not easily or directly…


was8bit 2024-03-12 03:41

TOOL mode cannot edit your code, it can only edit virtual FILES

NORMAL mode can only edit your code, and you also copy paste any data from one virtual file into another virtual file….

But technically virtual files simply hold data bits of 0 to F only… “HOW” this data is interpreted depends on if is it being used as a palette file, or a character file, or a background file, or a music file… or if it is a file for your own purposes, you will need to create your own interpreter ….


was8bit 2024-03-12 03:49 (Edited)

Here is an example of a bulk data file I made… it demos how to edit a file in TOOL mode, then how the program can access and use the data in the file…

https://lowresnx.inutilis.com/topic.php?id=94

https://lowresnx.inutilis.com/topic.php?id=93

Also look at my word games (see my home page) where I have used this approach to enter then use a huge word database :)


was8bit 2024-03-12 03:59

Also, you may use what is called PERSIST memory directly from code to store and retrieve data …. Mostly for things like high scores or game status…

But also PERSIST memory is precisely the size of BG 1 and BG 0 data, so if your game uses the background data to save your game state (instead of arrays) then you can simply copy the both background files into or from PERSIST memory

Anything in PERSIST memory remains after you close and exit the game… then open up the game again.. PERSIST data is still saved ;)


Timo 2024-03-12 13:36

The idea of the tool would be writing a whole interpreter though. It might be a way to go for simple commands, but not for a full BASIC program.


was8bit 2024-03-12 14:42

I agree… most things can be handled with arrays, IF THEN, SUB, etc

… but it is sometimes fun to try an idea just to see what might be possible… I have always tried different approaches as a fun challenge :)


Log in to reply.