[comp.sys.cbm] SEQ -> PRG

abp@j.cc.purdue.edu.UUCP (09/07/87)

I have a two BASIC programs that I have transferred from an IBM PC to a
Commodore 64 using Kermit 2.0 and a serial cable.  I saved them as ascii
files on the PC before I transferred them, and they are now safely on a
C64 disk as SEQ files.  Now, I need to know how to convert them to PRG
files.  Is there any way to do this?  Perhaps someone has written a program
to do this.  I know next to nothing about the Commodore, so please assume
that I know nothing.

				Thanks in advance,
				Jeff Wieland
				abp@j.cc.purdue.edu

rufsmith@uokmax.UUCP (09/07/87)

In response to Jeff Wieland's question about SEQ-PRG conversion:

Whew!  Commodore disk protocol is a rarity in that programs do not
generally get saved as ASCII files; thus, to my knowledge, there is
no way to load a program from an ASCII file.  Given time, I could
probably come up with a satisfactory machine language program to
do the trick; maybe not...but that is beside the point, since that
is not what you asked for.  Sorry, but the only thing that comes
to mind is for you to print out the file (if you have a printer)
and type it in by hand.  I should also point out that a program
written on the IBM will very likely not work on the Commodore.

Random
rufsmith@uokmax.UUCP

aeusejxn@csun.UUCP (Joachim Nave) (09/08/87)

In article <669@uokmax.UUCP> rufsmith@uokmax.UUCP (Random of Amber) writes:
>In response to Jeff Wieland's question about SEQ-PRG conversion:
>
>.......  Sorry, but the only thing that comes
>to mind is for you to print out the file (if you have a printer)
>and type it in by hand.  I should also point out that a program
>written on the IBM will very likely not work on the Commodore.
>

NOOOOOOOOO!
Please dont waste your time typing in the prgram again. All you have to 
do is change one byte in the directory from 82 to 81 (hex).
You can edit this sector (12,...(hex)) with FastLoad.  
If you do not know how to do this, you are welcome to send me the disk
(or a copy for that matter) and I will change it for you!

If you want to do so, here is my address:

California State University, Northridge
Joachim Nave c/o Computer Center
18111 Nordhoff St.
Northridge, Ca.91330

It takes only a few seconds to change it!!!
You will have some problems though running IBM basic on the C-64!
It will take some time for you to go through and replace all non-
Commodore commands into their proper commands.
-- 

Joachim Nave, CSU Northridge, Computer Science Department 
UUCP:{sdcrdcf, ihnp4, hplabs, ttidca, psivax, csustan}!csun!aeusejxn
                                                      !csun!titan!eectrjxn

davef@brspyr1.BRS.Com (Dave Fiske) (09/08/87)

In article <5237@j.cc.purdue.edu>, abp@j.cc.purdue.edu (Jeffrey J Wieland) writes:
> I have a two BASIC programs that I have transferred from an IBM PC to a
> Commodore 64 using Kermit 2.0 and a serial cable.  I saved them as ascii
> files on the PC before I transferred them, and they are now safely on a
> C64 disk as SEQ files.  Now, I need to know how to convert them to PRG

There is a way to do it, but it gets involved.

What you need is a "tokenizer" program.  Such programs have been
published in magazines dealing with Commodore computers, and there are
probably some floating around in software libraries of online services
and bulletin boards.

When you type in a Basic statement on your computer keyboard, the Basic
interpreter (which is stored in ROM on your 64) looks up the words you
type in, and, if they are legitimate Basic keywords, uses a one-byte
abbreviation, a "token", to store the keywords.  Non-keywords are
stored in a different way. 

For a program to "run", it must be stored in such a tokenized format,
so that the interpreter will recognize the various commands, and know
what to do.  An ASCII file, even though it consists of Basic
statements, is NOT tokenized, and cannot be run.

To make such a program runnable, it has to be tokenized.  This can be
done in two ways:  write a program that does its own interpreting,
which converts the Basic keywords into the correct tokens, and stores
them in this format; or, write a program that utilizes the built-in
Basic interpreter to tokenize the statements.  The second method is
easier, since, in addition to converting keywords to the appropriate
tokens, there are other non-keyword things (like quoted strings) that
have to be handled.  When you use the interpreter, it takes care of all
this on its own.

The way the Basic interpreter can be used is to use the "dynamic
keyboard" technique to enter the Basic statements as though there were
a person typing them from the keyboard.  The statements are read in,
and Carriage Returns (fed into the keyboard buffer) simulate a person
entering the statements.  One hitch here is that, since the Basic
program you are entering is constantly having new lines added to it,
variables, etc. are constantly being cleared (anytime you alter a Basic
program in memory, this happens).  This messes up trying to read a disk
file, so the file first has to be read into RAM and stored, and this
"image" of the disk file is what gets tokenized.

Well, I hope this points you in the right direction.  If you
absolutely, positively have to convert such a file, I have a tokenizer
program that I wrote for my own use, but it is sort of clunky.

Unless you have really long files it is probably easier to retype them
than to do all the above.

Also, if the Basic programs were from an IBM-PC, chances are they will
utilize some commands that don't exist in the Version 2.0 Basic on your
C-64.  This means you would have to monkey around with them to get them
to work on your machine anyway.  As a general rule, anything other than
a fairly simple program couldn't simply be "ported" over to your C-64,
and anything that is short should just be re-typed on your Commodore.
-- 
As you read this, your eyelids are becoming very heavy.  You can barely
keep your eyes open.  You are getting sleepy, sleepy.  Now you are fast
asleep, you are in a deep restful sleep.  You will obey my every command.
Take out a $5 bill and email it to: ihnp4!philabs!nyfca1!brspyr1!davef

schaefer@ogcvax.UUCP (Barton E. Schaefer) (09/09/87)

In article <uokmax.669> rufsmith@uokmax.UUCP (Random of Amber) writes:
>In response to Jeff Wieland's question about SEQ-PRG conversion:
>
>Whew!  Commodore disk protocol is a rarity in that programs do not
>generally get saved as ASCII files; thus, to my knowledge, there is
>no way to load a program from an ASCII file.  Given time, I could
>probably come up with a satisfactory machine language program to
>do the trick; maybe not...but that is beside the point, since that
>is not what you asked for.  Sorry, but the only thing that comes
>to mind is for you to print out the file (if you have a printer)
>and type it in by hand.

Write a short BASIC program that resides at some huge line numbers (like
9999 and above, or bigger than the last line of the program to be converted)
that:

    1)  Reads a line from the ASCII file
    2)  Prints it to the screen
    3)  Positions the cursor on that line
    4)  Pokes a newline into the input buffer
    5)  Pokes a 1 into the "characters in input buffer" counter
    6)  If the file is not empty, go back to (1)

I've left out a lot of details, like the addresses of things (I don't have them
memorized, sorry) but this will cause the ASCII text to be added to the program
in memory.  Then you just delete the lines above 9999 (you can even automate
*that*) and SAVE the program.

There is a program-combiner in (I believe) _Mapping_the_Commodore_64_ from
COMPUTE! books that uses exactly this technique.  My modem came with a utility
program that also does this, though it does some funny things to hide its work
(so you don't see the program appearing on the screen).  _Mapping_ also gives
the addresses for the input buffer (and everything else).

You could also use SYS to call the kernal tokenizer directly on the ASCII text,
but that's more complicated than I want to discuss here.

>                         I should also point out that a program
>written on the IBM will very likely not work on the Commodore.

True, especially if it uses the graphics calls.  If you have a word processor
or other editor that works on plain text files, use that to edit the ASCII
before running the ASCII-to-BASIC program.  If the file is saved in true
ASCII, you will also need to convert it to PETASCII (the non-standard Commodore
character set).

> Random

Let Merle answer these questions from now on, Random.

-- 
Ghostwheel   			CSNET:	schaefer@Oregon-Grad
				UUCP:	...{tektronix,verdix}!ogcvax!schaefer
"Face it ... computers have revolutionized the workplace."
"Right.  The Ayatollah did the same thing to Iran."		-- J. MacNelly

mwilson@crash.CTS.COM (Marc Wilson) (09/09/87)

In article <741@csun.UUCP> aeusejxn@csun.UUCP (Joachim Nave) writes:
>In article <669@uokmax.UUCP> rufsmith@uokmax.UUCP (Random of Amber) writes:
>>In response to Jeff Wieland's question about SEQ-PRG conversion:
>>
>>.......  Sorry, but the only thing that comes
>>to mind is for you to print out the file (if you have a printer)
>>and type it in by hand.  I should also point out that a program
>>written on the IBM will very likely not work on the Commodore.
>>
>
>NOOOOOOOOO!
>Please dont waste your time typing in the prgram again. All you have to 
>do is change one byte in the directory from 82 to 81 (hex).

     This will do no good at all.  The only change will be in the directory
entry, not in the file itself.  CBM DOS treats SEQ, PRG, and USR files
identically.

     There are several programs in the public domain that accomplish the
task.  Most of them sit up in the $C000 block and mess with the ROM so
that you can modify the program in memory without having BASIC close
your disk files all the time.  There's also a simple way to do it
with an OPEN and two POKEs from the interpreter itself, but I dunno
what it is.  Look in one of the volumes Compute! Books has put out.

>It takes only a few seconds to change it!!!

     Even a few seconds wasted is still a waste worth avoiding.

>Joachim Nave, CSU Northridge, Computer Science Department 
>UUCP:{sdcrdcf, ihnp4, hplabs, ttidca, psivax, csustan}!csun!aeusejxn
>                                                      !csun!titan!eectrjxn
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Marc Wilson
     ARPA: ...!crash!mwilson@nosc.mil
           ...!crash!pnet01!pro-sol!mwilson@nosc.mil
     UUCP: [ cbosgd | hp-sdd!hplabs | sdcsvax | nosc ]!crash!mwilson
     INET: mwilson@crash.CTS.COM
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

waynet@tolerant.UUCP (Wayne Thompson) (09/10/87)

- I have a two BASIC programs that I have transferred from an IBM PC to a
- Commodore 64 using Kermit 2.0 and a serial cable.  I saved them as ascii
- files on the PC before I transferred them, and they are now safely on a
- C64 disk as SEQ files.  Now, I need to know how to convert them to PRG
- files.  Is there any way to do this?  Perhaps someone has written a program
- to do this.  I know next to nothing about the Commodore, so please assume
- that I know nothing.
				Thanks in advance,
				Jeff Wieland
				abp@j.cc.purdue.edu
----------------------------------------------------------------------
CBM basic programs are stored in a tokenized format which also includes links.
You cannot, as someone suggested, change the file type byte in the directory
and expect to load it. There is a very short program which will convert it for
you, however I'll have to dig it up. It opens the SEQ file, sets the default
input file to the the SEQ file instead of the keyboard. This goes through the
basic tokenizer. Give me a couple of days and I'll post it.
--
Which is worse, ignorance or apathy? Who knows, who cares.

Wayne Thompson
..{bene,mordor,nsc,oliveb,pyramid,ucbvax}!tolerant!waynet

Your mission, should you decide to accept it, is to discern who is
responsible for these opinions, the poster or the company he works for.
Good luck!!

kb@umnstat.UUCP (Christopher Bingham) (09/10/87)

In article <741@csun.UUCP>, aeusejxn@csun.UUCP (Joachim Nave) writes:
> In article <669@uokmax.UUCP> rufsmith@uokmax.UUCP (Random of Amber) writes:
> >In response to Jeff Wieland's question about SEQ-PRG conversion:
> >
> >.......  Sorry, but the only thing that comes
> >to mind is for you to print out the file (if you have a printer)
> >and type it in by hand. 
> 
> NOOOOOOOOO!
> Please dont waste your time typing in the prgram again. All you have to 
> do is change one byte in the directory from 82 to 81 (hex).
> You can edit this sector (12,...(hex)) with FastLoad.  
> If you do not know how to do this, you are welcome to send me the disk
> (or a copy for that matter) and I will change it for you!
> 
> Joachim Nave, CSU Northridge, Computer Science Department 
> UUCP:{sdcrdcf, ihnp4, hplabs, ttidca, psivax, csustan}!csun!aeusejxn
>                                                       !csun!titan!eectrjxn
NOOOOOOOOOOOOO!
Changing the directory will not do it.  You have to tokenize the file.
Here is short C64 program that I think was on the net a while ago.  It really
works:
	63997 input"Name of file to tokenize";file$:file$="0:"+file$+",s,r"
	63998 close2:open2,8,2,file$:poke812,73:poke781,2:sys65478:end
	63999 close2:poke812,47:sys65484:end:rem from 11/86 transactor.

Type this in and type "run", giving the name of the sequential file to be
tokenized when asked.  When the disk stops spinning (the red light will
still be on because the file has not been closed), type "goto 63999" .  At
this point the tokenized file will be in memory with the above lines
appended at the end.  Delete the lines and save the file.

			C. Bingham, Applied Statistics, U of Minn.
			St. Paul, MN
			umnstat!kb@umn-cs.uucp

mark@unisec.usi.com (Mark Rinfret) (09/10/87)

I've been sitting back and watching all of this talk about SEQ->PRG and am
surprised that no one has just come out and said that IT HAS BEEN DONE ALREADY!
I have a little PD program named TLOAD which does the job quite nicely.  Nag
me and I'll upload it (in UUENCODED form).  Unfortunately, I'm never at my
64 when I read this stuff, so I usually forget the promises I make during the
day.  Hmmm...seems I'm on the hook for a MAE conversion program too...I'll
really try to get both of these uploaded soon.

Mark

-- 
| Mark R. Rinfret, SofTech, Inc.		mark@unisec.usi.com |
| Guest of UniSecure Systems, Inc., Newport, RI                     |
| UUCP:  {gatech|mirror|cbosgd|uiucdcs|ihnp4}!rayssd!unisec!mark    |
| work: (401)-849-4174	home: (401)-846-7639                        |

mark@unisec.usi.com (Mark Rinfret) (09/10/87)

In article <741@csun.UUCP>, aeusejxn@csun.UUCP (Joachim Nave) writes:
> In article <669@uokmax.UUCP> rufsmith@uokmax.UUCP (Random of Amber) writes:
> >In response to Jeff Wieland's question about SEQ-PRG conversion:
> >
> >.......  Sorry, but the only thing that comes
> >to mind is for you to print out the file (if you have a printer)
> >and type it in by hand.  I should also point out that a program
> >written on the IBM will very likely not work on the Commodore.
> >
> 
> NOOOOOOOOO!
> Please dont waste your time typing in the prgram again. All you have to 
> do is change one byte in the directory from 82 to 81 (hex).
> You can edit this sector (12,...(hex)) with FastLoad.  
> If you do not know how to do this, you are welcome to send me the disk
> (or a copy for that matter) and I will change it for you!

Are you sure about this?  Have you actually tried it?  A SEQ file does NOT
have a structure compatible with the LOAD kernal routine.  LOAD expects to
find a load address, statement numbers (in LO-HI format, not text) statement
links and null statement terminators.  NONE of this information exists in
a pure text file imported from another machine.  I sincerely recommend that
you try out an idea before you strongly recommend it to the unsuspecting
public.  Thanks.

Mark
[Stupid filler]
[to satisfy the]
[stupid old vs. new]
[requirement.]
-- 
| Mark R. Rinfret, SofTech, Inc.		mark@unisec.usi.com |
| Guest of UniSecure Systems, Inc., Newport, RI                     |
| UUCP:  {gatech|mirror|cbosgd|uiucdcs|ihnp4}!rayssd!unisec!mark    |
| work: (401)-849-4174	home: (401)-846-7639                        |

randy@athena.mit.edu (Randall W Winchester) (09/12/87)

In article <5237@j.cc.purdue.edu> abp@j.cc.purdue.edu (Jeffrey J Wieland) writes:
>I have a two BASIC programs that I have transferred from an IBM PC to a
>Commodore 64 using Kermit 2.0 and a serial cable.  I saved them as ascii
>files on the PC before I transferred them, and they are now safely on a
>C64 disk as SEQ files.  Now, I need to know how to convert them to PRG
>files.  Is there any way to do this?  Perhaps someone has written a program
>to do this.  I know next to nothing about the Commodore, so please assume
>that I know nothing.

From the November 1986 issue of The Transactor:

OPEN 2,8,2, "filename" : POKE 781,2 : POKE 812,73 : SYS 65478

This can not only be used to tokenize a BASIC PRoGram LISTed to a
SEQuential file, it will also execute a SEQuential file of BASIC
direct mode commands similar to the SUBMIT command in CP/M.  If you
end the file with CLOSE 2 : POKE 812,47 : SYS 65484 , the system will
be returned to normal after executing the command file.  It can also
be used to merge a program listing with an existing program in memory.
I also used this one-line technique in a utility to write BASIC DATA
statements from raw disk sectors.

On the subject of ASCII conversion, these two one-liners are also from
The Transactor, Volume 5, Issue 4:

ASCII -> CBM

a=asc(a$+chr$(0)):a$=chr$(a+32*(a>96 and a<123)-128*(a>64 and a<91))

This will convert a single character stored in A$.  For CBM to true ASCII:

a=asc(a$+chr$(0)):a$=chr$(a+128*(a>192 and a<220)-32*(a>64 and a<91))

Control characters are the exception.  There isn't much correlation
between ASCII and CBM control characters.  You have to handle them on
a case by case basis.

elg@usl (Eric Lee Green) (09/14/87)

in article <741@csun.UUCP>, aeusejxn@csun.UUCP (Joachim Nave) says:
> 
> In article <669@uokmax.UUCP> rufsmith@uokmax.UUCP (Random of Amber) writes:
>>In response to Jeff Wieland's question about SEQ-PRG conversion:
>>.......  Sorry, but the only thing that comes
>>to mind is for you to print out the file (if you have a printer)
>>and type it in by hand.  I should also point out that a program
>>written on the IBM will very likely not work on the Commodore.
> NOOOOOOOOO!
> Please dont waste your time typing in the prgram again. All you have to 
> do is change one byte in the directory from 82 to 81 (hex).
> You can edit this sector (12,...(hex)) with FastLoad.  
> If you do not know how to do this, you are welcome to send me the disk
> (or a copy for that matter) and I will change it for you!

Nope. It has to be in tokenized form. As mentioned by several others.
Just changing the file type won't work, because the data is in the
wrong format to be executed by Commodore BASIC.  I recently needed to
turn a Merlin program (text file) into a PAL program (which is stored
as a tokenized BASIC program). Took about 15 minutes to whip up a
quick conversion program, using the old
print-it-to-screen-and-stuff-nls-into-keyboard-buffer trick. Wish I
had it handy, but I'm at school now, and it's at home...

--
Eric Green {ihnp4,cbosgd}!killer!elg
           {ut-sally,killer}!usl!elg
           elg@usl.CSNET
-- 
Eric Green {ihnp4,cbosgd}!killer!elg
           {ut-sally,killer}!usl!elg
           elg@usl.CSNET