I just found this shit that I wrote in 2002.
What do you think of it, /prague/?
menu:
CLS
PRINT "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ͻ"
PRINT "▒ The Encryption Program ▒"
PRINT "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"
PRINT "▒ 1 ▒ Encrypt ▒"
PRINT "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒Ķ"
PRINT "▒ 2 ▒ Decrypt ▒"
PRINT "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒Ķ"
PRINT "▒ 3 ▒ Exit ▒"
PRINT "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒Ķ"
PRINT "▒ Command: ▒"
PRINT "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ͼ"
LOCATE 10, 12
INPUT "", C$
IF C$ = "1" THEN
GOSUB encrypt
ELSEIF C$ = "2" THEN GOSUB decrypt
ELSEIF C$ = "3" THEN GOSUB exitprog
END IF
GOTO menu
encrypt:
LOCATE 12, 1
INPUT "Input File: ", f$
INPUT "Output File: ", of$
INPUT "Password: ", p$
rp = 0
FOR i = 1 TO LEN(p$)
rp = rp + ASC(MID$(p$, i, 1))
NEXT i
RANDOMIZE rp
OPEN f$ FOR BINARY ACCESS READ AS #1
OPEN of$ FOR BINARY ACCESS WRITE AS #2
b = 1
ob = 1
inbyte$ = " "
WHILE NOT EOF(1)
GET #1, b, inbyte$
b = b + 1
IF EOF(1) THEN GOTO inputfileend
outbyte$ = ""
FOR i = 1 TO INT(RND * LEN(p$)) + 1
outbyte$ = outbyte$ + CHR$(ASC(inbyte$) + ASC(MID$(p$, INT(RND * LEN(p$))
+ 1, 1)) MOD 256)
NEXT i
PUT #2, ob, outbyte$
ob = ob + LEN(outbyte$)
WEND
PRINT "Encryption Complete."
PRINT f$; " > "; of$
WHILE INKEY$ = ""
WEND
CLOSE #1
CLOSE #2
RETURN
decrypt:
LOCATE 12, 1
INPUT "Input File: ", f$
INPUT "Output File: ", of$
INPUT "Password: ", p$
rp = 0
FOR i = 1 TO LEN(p$)
rp = rp + ASC(MID$(p$, i, 1))
NEXT i
RANDOMIZE rp
OPEN f$ FOR BINARY ACCESS READ AS #1
OPEN of$ FOR BINARY ACCESS WRITE AS #2
b = 1
ob = 1
inbyte$ = " "
WHILE NOT EOF(1)
FOR i = 1 TO INT(RND * LEN(p$)) + 1
GET #1, b, inbyte$
b = b + 1
outbyte1 = ASC(inbyte$) - ASC(MID$(p$, INT(RND * LEN(p$)) + 1, 1))
WHILE outbyte1 < 0
outbyte1 = outbyte1 + 256
WEND
IF i = 1 THEN outbyte = outbyte1
IF outbyte <> outbyte1 THEN GOTO progerr
NEXT i
outbyte$ = CHR$(outbyte)
PUT #2, ob, outbyte$
ob = ob + 1
WEND
inputfileend:
CLOSE #1
CLOSE #2
PRINT "Decryption Complete."
PRINT f$; " > "; of$
WHILE INKEY$ = ""
WEND
RETURN
progerr:
PRINT "Error: Incorrect Password"
WHILE INKEY$ = ""
WEND
RETURN
exitprog:
SYSTEM
Around 2003 I wrote my only non-trivial QBASIC program.
It was a ``menu-driven'' interactive display for a presentation at school, and included the following atrocities:
- I knew I should use labels but didn't know how (:label or label:?) so I maintained a sheet of paper translating names of functional areas to line numbers.
- I knew I should use GOSUB, but didn't know RETURN, so I used GOTO everywhere.
- I couldn't think of a better way of drawing menus than manually printing text at the top of the screen, interspersed with COLOR statements to make them stand out from the background.
- I didn't know how to do keyboard input, so I used 1345000 IF $CHR = "A" GOTO 4500
1345010 IF $CHR = "D" GOTO 1349000
1345020 GOTO 1345000
which would constantly poll the keyboard, and of course meant that only one in four keystrokes would be recognised correctly.
Name:
Anonymous2012-12-12 3:03
>>1
I like it. Any way to get it to run on a modern computer?
Also, since we're talking about code from our programming infancy, here's a tetris I wrote in JABBA when I was first learning programming:
Highlights:
*200+ line main
*Everything in one while loop, Thread.sleep()
*Didn't understand what JLabels were so just made new ones/removed all old ones every update cycle
*int[][]
That reminds me of another java program I did my first week
(indian or PC native american)
import java.io.*;
//babbys first java program
public class InameGen {
public static void main(String args[]) {
for (int i6 = 0; i6 == 0; i6 += 0) {
System.out.println("What is your name?");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String i1 = null;
try {
i1 = br.readLine();
}
catch (IOException e) {
System.out.println("NOPE.AVI");
System.exit(1);
}
System.out.println("What is your gender? 0 for male, 1 for female.");
BufferedReader bt = new BufferedReader(new InputStreamReader(System.in));
String i2 = null; int i3;
try {
i2 = bt.readLine();
}
catch (IOException e) {
System.out.println("NOPE.AVI");
System.exit(1);
}
i3 = Integer.parseInt(i2);
if (i3 == 0) {
System.out.println("Your indian name is...");
System.out.println(i1+"ino");
} else if (i3 == 1) {
System.out.println("Your indian name is...");
System.out.println(i1+"ina");
} else {
System.out.println("NOPE.AVI");
}
System.out.println();
System.out.println("Try again? Enter 0 for yes, 1 for no.");
BufferedReader bx = new BufferedReader(new InputStreamReader(System.in));
String i4 = null; int i5;
try {
i4 = bx.readLine();
}
catch (IOException e) {
System.out.println("NOPE.AVI");
System.exit(1);
}
i5 = Integer.parseInt(i4);
i6 = i6 + i5;
}
}
}
ENTERPRISE QUALITY MENU DRIVEN PROGRAMMING
There's something about shitty menu programming that attracts newbie programmers...
Name:
Anonymous2012-12-12 7:34
I was writing without indentation out of an old computer of my dad's.
program snake;
uses wincrt;
type
norm=array[1..72,1..24] of record
occupied: boolean;
life: byte;
end;
var
teclas: array[1..2] of record
nome: string;
up,down,left,right: char;
end;
multi: array[1..2] of record
teclas: record
nome: string;
up,down,left,right: char;
end;
highscore,points,maxlife,plustotal,padrao,mapx,mapy: longint;
menu,prevmenu: char;
end;
padrao: byte;
textfile: text;
file1: file of longint;
filemap: file of norm;
mapname: string[12];
menu,prevmenu,submenu,choice,symbol: char;
cont1,cont2,mapx,mapy: longint;
defeat: boolean;
highscore: longint;
map: norm;
speed,cresc,points: longint;
plusx,plusy: byte;
plustotal: word;
maxlife: byte;
procedure timer;
begin
for cont2:=1 to (11-speed)*110000 do write('');
end;
begin
randomize;
writeln('Erro: Falta ficheiros');
assign(file1,'snakesav.dat');
reset(file1);
read(file1,highscore);
close(file1);
clrscr;
teclas[1].nome:='Padrão WASD';
teclas[1].up:='W';
teclas[1].down:='S';
teclas[1].left:='A';
teclas[1].right:='D';
teclas[2].nome:='Numérico esquerdo';
teclas[2].up:='8';
teclas[2].down:='2';
teclas[2].left:='4';
teclas[2].right:='6';
symbol:='#';
repeat
repeat
clrscr;
writeln;
writeln(' :SNAKE:');
writeln;
writeln(' a - Jogo Solo');
writeln(' b - 2 Jogadores(!)');
writeln(' c - Instrucções');
writeln(' d - Sair');
write(' ');
menu:=upcase(readkey);
if menu='C' then begin
writeln;
writeln;
writeln;
writeln;
writeln(' -Direccionais');
writeln;
writeln(' W 8');
writeln(' A D ou 4 6 P para parar a partida');
writeln(' S 2');
writeln;
writeln(' ! -> Apanhe para a cobra crescer e ganhar pontos / Nr apanhado');
writeln(' V -> Velocidade da partida');
writeln(' C -> Velocidade de crescimento da cobra');
writeln(' P -> Pontos da partida');
writeln(' R -> Recorde de pontos de todas as partidas');
writeln;
write(' Não embate nas paredes ou na própria cobra senão perde o jogo.');
readkey;
end;
if menu='D' then donewincrt;
until (menu='A') or (menu='B');
if menu='A' then begin
mapname:='level001.txt';
speed:=1;
cresc:=1;
padrao:=1;
repeat
clrscr;
writeln;
writeln(' :SNAKE:');
writeln;
writeln(' a - Mapa=',mapname);
writeln(' b - Velocidade=',speed);
writeln(' c - Crescimento=',cresc);
writeln(' d - Teclas=',teclas[padrao].nome);
writeln(' e - Aceitar e continuar');
write(' ');
submenu:=upcase(readkey);
if submenu='A' then begin
gotoxy(11,4);
readln(mapname);
mapname:=mapname+'.txt';
clrscr;
writeln('Erro: Mapa não encontrado, programa crashou');
assign(textfile,mapname);
reset(textfile);
close(textfile);
end;
if submenu='B' then
repeat
gotoxy(17,5);
readln(speed);
until (speed>=1) and (speed<=10);
if submenu='C' then
repeat
gotoxy(18,6);
readln(cresc);
until (cresc>=1) and (cresc<=10);
if submenu='D' then
if padrao=1 then padrao:=2 else padrao:=1;
until submenu='E';
clrscr;
defeat:=false;
maxlife:=10;
prevmenu:=teclas[padrao].up;
points:=0;
plustotal:=0;
assign(textfile,mapname);
reset(textfile);
for cont2:=1 to 24 do begin
for cont1:=1 to 72 do begin
read(textfile,symbol);
if symbol='1' then begin
map[cont1,cont2].occupied:=true;
gotoxy(cont1,cont2);
write('N');
end else begin
map[cont1,cont2].occupied:=false;
end;
end;
>>22
Of course. It was originally used to encrypt private messages in a sort of BBS that I set up on the school's network when I was 12. I wrote the code in >>1 in 2002 after the sysadmin finally noticed and shut the thing down, because a few people had messages in their mailboxes that they wanted to get at, so they needed a way to decrypt them.