6

I have an old .BAS file that I'm trying to view and for which I'm running into some problems. Searching online seems to indicate that I should be able to just open it in NOTEPAD.EXE or similar, but doing so gives me gibberish, like this:

þ*©¿TÜ…7[/C̸yõ»€¹Ù<Ñ~Æ-$Ì™}³nFuJ,ÖYòÎg)ʇŒ~НDËðïþSnhœJN
‰=É™2+df”c).vX»[šû'Û9¹8%ñx5m#8úV4ÊBº)Eª;Iú¹ó‹|àÆ„72@ާi§Ë @îÑ?
í‘ú™ÞMÖæÕjYе‘_¢y<…7i$°Ò.ÃÅR×ÒTÒç_yÄÐ
}+d&jQ *YòÎg)ʇŒ~НDË?úŽ©Ž5\šm€S{ÔÍo—#ìôÔ”ÜÍѱ]ʵ¬0wêÂLª¡öm@Å„Ws雦 X
Ô¶æ¯÷¦É®jÛ ¼§
”n ŸëÆf¿´ó½4ÂäÌ3§Œ®

I know the file is sound, because I can open it in GW-BASIC. However, list does not seem to work to view the file, and trying to save the file in ASCII format from within GW-BASIC, didn't work either. Both just gave me an "Illegal function call" error:

GW-BASIC 3.22
(C) Copyright Microsoft 1983,1984,1986,1987
60300 Bytes free
Ok
LOAD"Pwrharm
Ok
LIST
Illegal function call
Ok
SAVE "Pwrharm2",A
Illegal function call
Ok
RUN
[Program runs successfully]

Then again, the run command works just fine. What am I doing wrong?

Sep Roland
  • 33,889
  • 7
  • 43
  • 76
user2320886
  • 103
  • 1
  • 6

2 Answers2

11

You're not doing anything wrong; the file was originally saved in GWBASIC with the ,P option. There is a 'hack' to unprotect it, described at https://groups.google.com/forum/#!topic/comp.os.msdos.misc/PA9sve0eKAk - basically, you create a file (call it UNPROT.BAS) containing only the characters 0xff 0x1a, then load the protected file, then load UNPROT.BAS, and you should then be able to list and save the program.

Jeff Zeitlin
  • 9,773
  • 2
  • 21
  • 33
  • 3
    Thanks! This worked like a charm, but with one modification. The unprot.bas file had to have two characters: 0xff and 0x1a. – user2320886 Dec 15 '16 at 17:20
0

If you can't LIST or EDIT a GW-BASIC .BAS file that you LOADed from disk, it means that the file was originally SAVEd in protected format via SAVE filespec, P.

The 1988 "Handbook of BASIC - third edition" by David I. Schneider describes it as follows:

A program that has been SAVEd in protected format can be unprotected with the following technique.

(a) Create a file called RECOVER.BAS with the following program.

 10 OPEN "RECOVER.BAS" FOR OUTPUT AS #1  
 20 PRINT #1, CHR$(255);  
 30 CLOSE #1  

(b) LOAD the protected program into memory.
(c) Enter LOAD "RECOVER.BAS"

The formerly protected program will now be in memory and can be LISTed or EDITed, and reSAVEd in an unprotected format. This technique appears to work with most versions of BASIC. I have used it successfully with IBM PC BASIC, Compaq BASIC, and several versions of GW-BASIC. LOADing the file RECOVER.BAS will also restore a program after a NEW command has been executed.

Sep Roland
  • 33,889
  • 7
  • 43
  • 76