HP Forums

Full Version: HP BASIC (Series 200/300): Detokenizer
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I received a question from a person who has some floppy disks containing HP BASIC programs; He wonders wether it is possible to read these programs on a modern PC.
The first problem can easily be solved: A program like HPDir or the old LIF Utils can help to copy the files from LIF to FAT (DOS) formatted disks.
But then: The Basic programs normally were not saved in ASCII - Format, but in tokenized PROG format.
So the question is: Is there a de-tokenizer program available ( for free, preferably) that translates HP series 200/300 BASIC (version 5 or 6) programs into simple ASCII text? I faintly remember that I read about such a tool, but where?
If you have a 200/300 system available load the program then use the "SAVE" command to write it out to disk, this saves the program as ASCII text.

Paul.
@ Paul:
Yes, of course, I could do that as I have got working HP 300 series systems; but I am looking for a solution for people who have no (more) access to vintage hardware ( only some old floppy disks).

@ Mike:
Using an emulator is a good idea. I just have read that the emulator for series 200 machines by Olivier De Smet supports (boots) BASIC up to version 5.0. The floppy disks that should be translated probably were used on a (much) more modern 9000/375; I am afraid at least BASIC 6.2 was in use at that time.
Does anyone know of a series 300 emulator, or whether Olivier plans to develop further his emulator? On the real 9836 machine you can use BASIC 6.2 as well.
Maybe BASIC 6.x just hasn't been tested yet on Olivier's emulator. Did anyone try this out meanwhile? The latest information I found about the emulator dates from beginning of 2011. Maybe BASIC 6.2 wasn't easily available for download at that time.
There is a detokenizer for the Integral Technical Basic at
http://insar.stanford.edu/~lharcke/programming/
which could be useful for starting. But one would also need a means to read the LIF formatted floppy disk.

The best way is probably, as already mentioned, to go through a SAVE statement using the real thing or printing to a laptop via a serial interface.

Martin
@ Mike:
I found a download source for Olivier's emulator; just google "Smet 9836 emulator". But I didn't test it yet.
@ Martin: Thanks for the link. I am not sure whether HP-UX Technical BASiC uses the same file formats and BASIC tokens as Workstation BASIC?
The guy who wants his old BASIC programs transformed into ASCII text didn't get back to me. So it seems it's not that important for him. Since I could use SAVE on vintage hardware for that purpose, I won't investigate that any further.
Thank you guys for your hints!
(09-18-2017 03:24 PM)Martin Hepperle Wrote: [ -> ]There is a detokenizer for the Integral Technical Basic at
http://insar.stanford.edu/~lharcke/programming/
which could be useful for starting. But one would also need a means to read the LIF formatted floppy disk.

I am not sure about the integral detokenizer, but the HP-85 and HP-87 are more works in progress. They can identify the tokens, but the arguments are left as an exercise to the reader.

So you'll get something out of the program, but it will not be a listing that you can feed to another BASIC system.

I too tried to fix this, but its a lot of work, and as Martin pointed put, you just feed it to an (emulated) computer and get the listing.

**vp
I am searching for an HP Basic 4.0 for hp 9000/200 detokenizer

The given link is broken

May someone help me?

Thanks
(07-23-2019 07:05 AM)gintilisano Wrote: [ -> ]The given link is broken

It's still available on the Internet Archive. Hope that helps.
(07-23-2019 07:05 AM)gintilisano Wrote: [ -> ]I am searching for an HP Basic 4.0 for hp 9000/200 detokenizer
...
May someone help me?

It depends on what you want to do, but if your need is to get a text listing of a Basic 4 program stored in binary (tokenized) format, the easiest way, as suggested in a post above, is to load the program into Olivier De Smet's emulator and LIST the program. The emulator is not so robust for intensive tasks, but will do the job. You may need to make a disc image, if the target program is on a floppy disc, but it will be much easier than developing a HP Basic 4 detokenizer.

J-F
Solved.

I create a hex dump of the original LIF floppy disk using LIF utilities for dos in a vintage computer, then convert the hex dump to a binary LIF image usinge the Olivier De Smet (Thanks Olivier) Python program. Then I load the diskette in Olivier simulator, use the BASIC SAVE command to store a ASCII program file, I save the LIF image and extract the file with LIF utilities.

The ASCII file must be converted in text format, i use the followin QB64/QB45 code

CLS
DIM h AS STRING * 1


INPUT "file lif: ", a$
INPUT "file txt: ", B$

OPEN a$ FOR RANDOM AS #1 LEN = 1

OPEN B$ FOR OUTPUT AS #2
flag = 0
n = 0
WHILE NOT EOF(1)
n = n + 1
GET #1, n, h
i = ASC(h)
IF flag = 1 AND i >= 48 AND i < 58 THEN
flag = 0
END IF

IF i > 31 AND i < 126 AND flag = 0 THEN
PRINT #2, h;
ELSE
IF i = 0 THEN
PRINT #2, CHR$(13)
flag = 1
n = n + 1
END IF
IF i = 255 THEN
PRINT #2, "<FF>";
END IF
END IF
WEND
CLOSE #1
CLOSE #2

The resulting file is nor perfect, ma the task is done.
(07-30-2019 07:30 AM)gintilisano Wrote: [ -> ]...
Then I load the diskette in Olivier simulator, use the BASIC SAVE command to store a ASCII program file, I save the LIF image and extract the file with LIF utilities.
The ASCII file must be converted in text format, i use the followin QB64/QB45 code
...

Great !

The last step (converting the HP ASCII file into pure text file) could be avoided since Olivier's emulator simulates a printer at address 701.
You could have just done:
PRINTER IS 701; WIDTH OFF ! width off used to avoid line breaks after 80 char.
LIST
and get the text file into the file printer-xxx.txt in the current emulator directory.

J-F
Reference URL's