[comp.sys.apple] Appearance of control characters during string manipulations

GA.NES@ISUMVS.BITNET (SCHUESSLER) (02/22/88)

HELP!! I'm having a terrible problem with my Apple IIe.  I wrote a simple
program to convert binary files into a text files containing the hex digits,
when I discovered that in lines 42-47 of some files, there was nothing but a
long series of control characters.  There was no pattern to which files it
occurred in, but always within that line range.  There were some mysterious
power problems earlier today, but when I ran the program on someone else's IIe,
I got somewhat the same result.  I've come to the conclusion that it must be the
program.  My algorithm loads each binary file, PEEKS out the values, and
converts the integer values into numbers between 0-15, and with a series of IF
statements converts to char values from '0'...'F'.  I convert three files, and
attempt to put the nth line of each file together in one string var.  Each line
of any file is only 22 characters long, so there's plenty of room to put three
files next to each other.  The error occurs after it has done 52*22*3
concatenations of chars, and 42 concatenations of strings 22 chars long.  It
couldn't be just a hidden control char .......?

     Thanks in advance,

            Niko Schuessler

kc24+@ANDREW.CMU.EDU (Keith Alexander Chapman) (02/22/88)

It's vaguely possible that the problem is related to using up all the free
memory.  As you may or may not know, string manipulations waste
space incredibly.  To help limit this, Applesoft (which I assume
you're using) has the function FRE(arg) which not only returns the
number of bytes available for more variables, etc., but also cleans
up the garbage that string manipulation can cause.  If you insert a line
like
  120 GARBAGE = FRE(0)
somewhere in the loop that works with the strings, the garbage will
be periodically cleaned and not cause any problems.  I don't know how
the problem could have been caused by this, since you usually just
get an error message about having run out of free memory, but with
Applesoft, you never can tell.

Prometheus