A quick snippet to select a file and read in every record. I'm using this to generate a file of ids and their descriptions. Doing this in BASIC would be quite easy as well, it would actually be identical for the most part but I can't catch the output as easily as just running the script with stout pointed to a file.
const mv = require("pick-mv");
const Universe = require("pick-universe");
const uv = new Universe("localhost", "username", "password", "/path/to/account");
uv.StartSession();
const INV = uv.Open("INVENTORY-FILE");
uv.Select(INV);
while (true) {
let id = uv.ReadNext();
if (id === null) break;
let record = mv.MVMatrix(uv.Read(id, INV));
console.log(id, record[[1]]);
}
uv.EndAllSessions();
The core code in BASIC, line wise, they end up very similar but performance wise, huge difference. I had to run the javascript version for 2 minutes versus the BASIC version that ran in a few seconds.
OPEN "INVENTORY-FILE" TO INV ELSE STOP
SELECT INV
LOOP
READNEXT ID ELSE ID = ''
WHILE ID # '' DO
READ RECORD FROM INV, ID ELSE RECORD = ''
REPEAT
It would be worth generating a vim snippet to automatically get hints for the functions. I also need to profile if it's worth doing this readnext in javascript or if its better to do it in C and then do the MVMatrix in javascript land.