[comp.sys.apple2] Applesoft BASIC

bb0@beach.cis.ufl.edu (Bowie Bailey) (08/18/90)

I have several rather large programs written in Applesoft BASIC.  I now want
to make some changes, but I find these files hard to work with in the BASIC
environment.  Is there a way to translate the BASIC files to text files?
Getting them back is simple enough, but these are 10-15 page programs and I'm
NOT going to retype them!
Any help is greatly appreciated!

-Bowie           bb0@beach.cis.ufl.edu
                         or
               garm%pine.decnet@oak.circa.ufl.edu

toddpw@tybalt.caltech.edu (Todd P. Whitesel) (08/18/90)

bb0@beach.cis.ufl.edu (Bowie Bailey) writes:

>I have several rather large programs written in Applesoft BASIC.  I now want
>to make some changes, but I find these files hard to work with in the BASIC
>environment.  Is there a way to translate the BASIC files to text files?
>Getting them back is simple enough, but these are 10-15 page programs and I'm
>NOT going to retype them!
>Any help is greatly appreciated!

0 d$=chr$(4):f$="program.txt":?d$"open"f$:?d$"write"f$:list1,:?d$"close"f$:end

and type RUN.

Todd Whitesel
toddpw @ tybalt.caltech.edu

mattd@Apple.COM (Matt Deatherage) (08/18/90)

In article <1990Aug17.225331.1747@laguna.ccsf.caltech.edu> toddpw@tybalt.caltech.edu (Todd P. Whitesel) writes:
>0 d$=chr$(4):f$="program.txt":?d$"open"f$:?d$"write"f$:list1,:?d$"close"f$:end
>
>and type RUN.
>
>Todd Whitesel
>toddpw @ tybalt.caltech.edu

Uh...somewhere before the LIST command you should add POKE 33,33 to force
AppleSoft to turn off it's internal formatting.  Otherwise you'll get a lot of
partial lines which will really be a pain in the patoot.

You (the original poster, not Todd) should also investigate Beagle Bros. product
Program Writer, which makes all of this unnecessary.

-- 
============================================================================
Matt Deatherage, Apple Computer, Inc. | "The opinions represented here are
Developer Technical Support, Apple II |  not necessarily those of Apple
Group.  Personal mail only, please.   |  Computer, Inc.  Remember that."
============================================================================

toddpw@tybalt.caltech.edu (Todd P. Whitesel) (08/18/90)

mattd@Apple.COM (Matt Deatherage) writes:

>Uh...somewhere before the LIST command you should add POKE 33,33 to force
>AppleSoft to turn off it's internal formatting.  Otherwise you'll get a lot of
>partial lines which will really be a pain in the patoot.

Try it and see. The WRITE turns off screen output, and Applesoft uses the
cursor position to tell it when to wrap -- so you do in fact get what you want,
an EXEC'able text file that can easily be run into Appleworks.

Todd Whitesel
toddpw @ tybalt.caltech.edu

mattd@Apple.COM (Matt Deatherage) (08/18/90)

In article <1990Aug18.012334.4055@laguna.ccsf.caltech.edu> toddpw@tybalt.caltech.edu (Todd P. Whitesel) writes:
>Try it and see. The WRITE turns off screen output, and Applesoft uses the
>cursor position to tell it when to wrap -- so you do in fact get what you want,
>an EXEC'able text file that can easily be run into Appleworks.
>
>Todd Whitesel
>toddpw @ tybalt.caltech.edu

The behavior of WRITE in this fashion is not guaranteed.  Admitted it's a)
true as you write it and b) not likely to change, there's also c) the fact that
lots of people read this group and file such tidbits for later use, and d)
without the POKE 33,33 the technique could fail in future BASIC.SYSTEM releases
and will not work under DOS 3.3.

I'm not used to giving answers that aren't guaranteed.

-- 
============================================================================
Matt Deatherage, Apple Computer, Inc. | "The opinions represented here are
Developer Technical Support, Apple II |  not necessarily those of Apple
Group.  Personal mail only, please.   |  Computer, Inc.  Remember that."
============================================================================

zane@ddsw1.MCS.COM (Sameer Parekh) (08/19/90)

In article <24148@uflorida.cis.ufl.EDU> bb0@beach.cis.ufl.edu () writes:
>I have several rather large programs written in Applesoft BASIC.  I now want
>to make some changes, but I find these files hard to work with in the BASIC
>environment.  Is there a way to translate the BASIC files to text files?
>Getting them back is simple enough, but these are 10-15 page programs and I'm
>NOT going to retype them!
>Any help is greatly appreciated!
>
>-Bowie           bb0@beach.cis.ufl.edu
>                         or
>               garm%pine.decnet@oak.circa.ufl.edu

What I would do is change line 0:
0 GOTO [LINE AFTER ALL OTHER LINES]

Then put in the following program.
(At that LINE, I will call it 10000)
10000 ?CHR$(4);"OPEN ";FILENAME$
10100 ?CHR$(4);"WRITE ";FILENAME$
10200 LIST 1-[LAST LINE IN PROGRAM]
10300 ?CHR$(4);"CLOSE ";FILENAME$
10400 END

Be sure you have FILENAME$ equal to a valid filename, (Don't use a variable,
just put something in.) Then you will have a text file which you can import
into AppleWorks, Proterm, or others.

-- 
Sameer Parekh           |  Disclaimer: I do not work for anyone.    
Libertyville IL 60048   |        ()_____________ ()
(708)-362-9659          |         /             \        
zane@ddsw1.MCS.COM      |        ~~~~/~~~~~~~\~~~~

dlyons@Apple.COM (David A. Lyons) (08/19/90)

History:  Todd Whitesel posted a way to capture an Applesoft listing into
a text file, Matt recommended adding a POKE 33,33 to insure there are no
extra carriage returns, Todd replies you don't need it, and Matt says:

>[...] without the POKE 33,33 the technique could fail in future BASIC.SYSTEM
>releases and will not work under DOS 3.3.

My $0.02 (that's hex for 1/128):

POKE 33,x sets the text window width to x.  Applesoft inserts a carriage
return at the first convenient spot past column 33, or at least past what
it *thinks* is column 33 based on CH (cursor horizontal) on zero page.

(80-column firmware tricks Applesoft in appropriate ways, so that you get
the same effect 7 columns from the right edge of the screen.)

The wrapping happens only when the cursor is past column 33, so there is
no problem under DOS 3.3 *if* you have "MON O" mode turned off (it's off
by default), so that output being sent to a file does *not* get echoed to
the screen.

BASIC.SYSTEM has no way to make file output echo to the screen, and if
one were added it would have to default to being off.  So I don't see
a problem there either.
-- 
David A. Lyons, Apple Computer, Inc.      |   DAL Systems
Apple II Developer Technical Support      |   P.O. Box 875
America Online: Dave Lyons                |   Cupertino, CA 95015-0875
GEnie: D.LYONS2 or DAVE.LYONS         CompuServe: 72177,3233
Internet/BITNET:  dlyons@apple.com    UUCP:  ...!ames!apple!dlyons
   
My opinions are my own, not Apple's.

jb10320@uxa.cso.uiuc.edu (Desdinova) (08/20/90)

So far, everyone has shown how to dump an AppleSoft program to a text file
for editing.  Such a tactic has been unnecessary since the world's greatest
AppleSloth tool, "Program Writer", was released.  Beagle Brothers I believe 
handles this wonderful tool now.
Using it is simple- type "&&" and you and your program are transported from
the nasty "]" prompt to a full-screen AppleWorks-work-alike editor.

No AppleSloth programmer should be without it.

--
Jawaid Bazyar               | This message was posted to thousands of machines
Junior/Computer Engineering | throughout the entire civilized world. It cost
jb10320@uxa.cso.uiuc.edu    | the net hundreds, maybe thousands of dollars,
                            | to send everywhere.

livia@blake.acs.washington.edu (Elisabeth Perrin) (08/24/90)

Sometime, somewhere, jb10320@uxa.cso.uiuc.edu (Desdinova) writes:

>So far, everyone has shown how to dump an AppleSoft program to a text file
>for editing.  Such a tactic has been unnecessary since the world's greatest
>AppleSloth tool, "Program Writer", was released.  Beagle Brothers I believe 
>handles this wonderful tool now.

I've programmed in Applesoft BASIC since 1985 or so.  Since then, I've written
dozens and dozens of programs, highlighted by VinyaMacil, a 3rd generation
ModemWorks-based bulletin board system.  My board, the Broken Blade (see the
Organization line) has run VM publicly since the beginning of this year;
earlier versions of VM (known as MiLo) have been in use for over three years.

Up until a couple of weeks ago, I edited all of my Applesoft BASIC programs
with Program Writer, an excellent full-screen editor for Applesoft.

Not any more.

Having recently received my copy of MD-BASIC in the mail, I'm still reeling
from the power that this package gives Applesoft BASIC programmers.

In short, MD-BASIC allows you to write your Applesoft programs in a
professional environment, giving you the capabilities of many high level
languages (C, Pascal, Modula-2...).  Programs are text files, editable with
your favorite text editor (on my IIe, you can't beat AppleWriter).
Document all you want, it won't show up in the object file.  Forget about
line numbers, MD-BASIC allows the use of labels.  True IF-THEN-ELSE-ENDIF
constructs are supported, along with other looping methods (DO-LOOP and
REPEAT-UNTIL come to mind...oh, don't forget WHILE-WEND).  Name your variables
anything you want, even if the first two characters are the same.  Define
constants and macros, so you cann call subroutines WITH PARAMETERS!  Include
other MD-BASIC source files into your current one, such as header files and
subroutine libraries (the disk is stuffed with samples of these).  There are
also conditional branching commands for the compiler, so you can control which
parts of your source files are compiled.

Oh, yeah, what does MD-BASIC do with these source files?  It doesn't truly
compile them, in the strictest sense of converting them to 6502 instructions;
rather, it optimizes them: numbers your executable code by ones, renames your
variables, starting at A, and going to ZZ, converts your labels, branching,
and looping constructs into Applesoft code, and compacts all of this into the
least amount of space, by using the full line length allowed by Applesoft.  The
resulting BAS-type files are gobbledy-gook, but then again, most Applesoft
programs look like that.  Don't worry about it, because you've got real source
files to edit!

My ONLY complaint about the package, is that when I sent away for it, the flyer
I received made no mention of the package requiring the use of a GS.  As it
turns out, the compiler and decompiler (oh, did I tell you that you can
convert your current Applesoft programs to MD-BASIC format?) are GS/OS files.
So, I had to ride over to my helpful Apple dealer, and borrow their GS for a
half an hour while I ran my BAS files through the decompiler--each program,
ranging in size from a few k to about 15k, was decompiled in a couple of
seconds.  I copied the resultant TXT files to a 3.5" floppy, and am now in the
process of editing them on my IIe at home.

MD-BASIC gives Applesoft BASIC a shot in the arm, and even makes programming
in the language *fun* again!  If that isn't saying a lot about MD-BASIC, I
don't know what is.

If you do ANY kind of serious programming in Applesoft, buy MD-BASIC today.
It's $50, and you can order it from the Morgan Davis Group at their address.

(No, I'm not being paid for this testimonial; I'm just a very satisfied user
of ModemWorks, and now MD-BASIC.)

One more side note, on ModemWorks: I was surprised to find a new version of
Amperworks on the MD-BASIC disk, one that supported an &MLI command to easily
interface into the MLI from BASIC.  Can someone give me the latest scoop on
what the latest version of ModemWorks is?  Last I heard, 2.0c was it.  Have
those external file-transfer drivers been written yet?

>Jawaid Bazyar               | This message was posted to thousands of machines
>Junior/Computer Engineering | throughout the entire civilized world. It cost
>jb10320@uxa.cso.uiuc.edu    | the net hundreds, maybe thousands of dollars,
>                            | to send everywhere.

--Mike Owen, through the use of Liz Perrin's account, at

livia@blake.acs.washington.edu