Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:17 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2: Program access to commands: MEMORY, LIST COMMANDS, etc

Author Message
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 09:51pm 20 Dec 2020
Copy link to clipboard 
Print this post

Is there a way for a running program to access the output of commands such as "MEMORY" or "LIST FUNCTIONS" and similar? Could it become so?

It's not immediately obvious how that would work though. For example, "MEMORY" outputs 8 lines of information. a$ = MEMORY kind of makes sense, but of course doesn't work. a$ = LIST COMMANDS could never work because the output is more than 255 characters.

One possibility might be MEMORY, #nbr, where nbr is an open file. This could apply to any command that outputs text, sending the output to a file on disk instead of the screen.
Visit Vegipete's *Mite Library for cool programs.
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 10:19pm 20 Dec 2020
Copy link to clipboard 
Print this post

A possible syntax:

LONGSTRING APPEND ls%(), EXECUTE MEMORY
LONGSTRING APPEND ls%(), EXECUTE LIST COMMANDS
LONGSTRING APPEND ls%(), EXECUTE PRINT somethingcomplex

Whatever output results from the EXECUTE goes into the long string.


~
Edited 2020-12-21 08:23 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1114
Posted: 12:47am 21 Dec 2020
Copy link to clipboard 
Print this post

@lizby

I too would love to have the ability to "pipe" the output that goes to the console to a file (or longstring). The functionality to output commands to a file already exist with commands like PRINT #1,"something".

Thus adding the functionality to EXECECUTE could take the form

OPEN filename FOR output AS #1
 EXECUTE #1,"some command"      ' such as MEMORY, FILES etc
CLOSE #1

Thus any output that would normally go to the console could be captured to file.

Doug.
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 06:47pm 21 Dec 2020
Copy link to clipboard 
Print this post

Well, I think I've found an idiotic method of doing this!

It uses OCR, sort of.
Fortunately, MEMORY, LIST, LIST FUNCTIONS, etc respect the settings of both PAGE WRITE and FONT.
The following program uses a custom font that is the binary representation of the ascii code. Then it is a simple matter of PEEKing 8 bytes in the appropriate page to recover the character that was 'printed' there.

The following example does not use page write, mainly so you can see what it did. Also, the output is limited to the page height, so 600ish lines in MODE 1, but mode 9 or a tall FRAMEBUFFER would allow more.

mode 1,8
cls
font 10

'========================================
' Put your command to capture output here
'list functions
memory
'========================================

font 1
print @(0,200)

memloc% = MM.INFO(PAGE ADDRESS 0)
x% = 0
y% = 0
zero = 0
print "line #1: ";
do
 b = 0
 ' examine 8 pixels to rebuild ascii
 for i = 1 to 8
   b = b * 2 + (peek(byte memloc% + 800 * y% + x%) <> 0)
   x% = x% + 1
 next i
 if b = 0 then  ' end of line?
   x% = 0
   y% = y% + 1
   zero = zero + 1
   print
   print "line #" str$(y%+1) ": ";
 else
   print chr$(b);
   zero = 0
 endif
loop until zero = 4  ' done when 3+ blank lines found

'========================================
' BinaryOCR.fnt  by vegipete
' 8 pixels wide by 1 pixel high
' CHR$( 32) = 00100000
'       to
' CHR$(127) = 01111111
'
DefineFont #10
 60200108
 23222120 27262524 2B2A2928 2F2E2D2C 33323130 37363534 3B3A3938 3F3E3D3C
 43424140 47464544 4B4A4948 4F4E4D4C 53525150 57565554 5B5A5958 5F5E5D5C
 63626160 67666564 6B6A6968 6F6E6D6C 73727170 77767574 7B7A7978 7F7E7D7C
End DefineFont


Visit Vegipete's *Mite Library for cool programs.
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1427
Posted: 07:16pm 21 Dec 2020
Copy link to clipboard 
Print this post

  vegipete said  Well, I think I've found an idiotic method of doing this!

It uses OCR, sort of.
Fortunately, MEMORY, LIST, LIST FUNCTIONS, etc respect the settings of both PAGE WRITE and FONT.
The following program uses a custom font that is the binary representation of the ascii code. Then it is a simple matter of PEEKing 8 bytes in the appropriate page to recover the character that was 'printed' there.


That's idiotic. And pretty clever. This is the type of thing that programmers did in the 80s just because it was the only possible way for them to get what they need.

I doubt I ever would have thought of this.
Edited 2020-12-22 05:17 by CircuitGizmos
Micromites and Maximites! - Beginning Maximite
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 07:36pm 21 Dec 2020
Copy link to clipboard 
Print this post

Absolutely mad @vegipete, well done      

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 442
Posted: 07:42pm 21 Dec 2020
Copy link to clipboard 
Print this post

  CircuitGizmos said  
  vegipete said  Well, I think I've found an idiotic method of doing this!

It uses OCR, sort of.
Fortunately, MEMORY, LIST, LIST FUNCTIONS, etc respect the settings of both PAGE WRITE and FONT.
The following program uses a custom font that is the binary representation of the ascii code. Then it is a simple matter of PEEKing 8 bytes in the appropriate page to recover the character that was 'printed' there.


That's idiotic. And pretty clever. This is the type of thing that programmers did in the 80s just because it was the only possible way for them to get what they need.

I doubt I ever would have thought of this.


We called it screen scraping. I used to take screen print files from one system and produce MS-Access reports for our accounting department. It was simple but tedious work to get all the reports off the screens but it was the only way to interface our mainframe with our PCs.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025