[alt.msdos.programmer] Protection mode in BASIC

darcy@druid.uucp (D'Arcy J.M. Cain) (07/31/90)

In article <4020@sonata> brianle@sonata ( ICCAD CO-OP) writes:
First of all you should use comp.os.msdos.programmer.  It supercedes the alt
group which should probably be removed by now.

>    In the GWBASIC or BASICA on IBM-PC. After finishing your program. Usually
> the user type save "FN.FT" then <CR>. You can protect your program by typing
> SAVE "FN.FT",P for protection mode. This option will protect the source code
> to be listed by other user but other user can still execute it.
>
I can help you but first let me mount my soapbox.  If you are writing programs
for commercial sale you shouldn't be using BASIC.  If not you still shouldn't
be using BASIC for anything but quick and dirty stuff.  If you feel you must
use BASIC then you shouldn't be protecting them but rather let others see the
actual code.  There are two benefits to this.  Others learn from you and some
of them may be able to suggest improvements in the code for you.  In any case
the "protection" is pretty flimsy.  See below.

>   My question is : how do you unprotect the source code after you saved it
> as protect mode? Is there any way to do this?
>
In theory you can't unprotect BASIC files so you save two versions of the
program.  You modify the regular file then "protect" it under a different
name.  This is the version that you send out so that no one can look at your
code but you still have the code in case it needs to be modified.  I think
of this scenario whenever I need a laugh.  In reality there is no problem
unprotecting a BASIC program.  Use debug to create a small BASIC program
as follows:

C>debug
-e100
xxxx:0100  xx:FF xx:1a
-rcx
CX 0000
:2
-nunprot.bas
-w
Writing 0002 bytes
-q
C>

Note that the computer responds with some of the text.  The x's mean that
something is printed here but it doesn't matter what.  This will create
a 2 byte file called UNPROT.BAS in the current directory.  To unprotect
a BASIC program simply load the protected program into BASIC and then load
the UNPROT program on top of it.  Voila!  Listable code.  This may not work
under BASICA but it works under all versions of GWBASIC that I have tried.

-- 
D'Arcy J.M. Cain (darcy@druid)     |
D'Arcy Cain Consulting             |   MS-DOS:  The Andrew Dice Clay
West Hill, Ontario, Canada         |   of operating systems.
+ 416 281 6094                     |