Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Code from 10 years ago

Name: Anonymous 2012-12-12 0:20

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

Name: Anonymous 2012-12-12 0:30

Forgot to convert from code page 437 to UTF-8... Only affects a few lines:
PRINT "╔════════════════════════╗"
PRINT "║ The Encryption Program ║"
PRINT "╠═══╤════════════════════╣"
PRINT "║ 1 │ Encrypt            ║"
PRINT "╟───┼────────────────────╢"
PRINT "║ 2 │ Decrypt            ║"
PRINT "╟───┼────────────────────╢"
PRINT "║ 3 │ Exit               ║"
PRINT "╟───┴────────────────────╢"
PRINT "║ Command:               ║"
PRINT "╚════════════════════════╝"

Name: Anonymous 2012-12-12 1:53

>>1,2          `
>BASIC
>2002

ISHYGDDT

Name: Anonymous 2012-12-12 2:12

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: Anonymous 2012-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:

https://gist.github.com/4265925

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[][]


private boolean canrotate(int ax, int ay, int bx, int by, int cx, int cy, int dx, int dy) {
if ( (ax > -1) && (bx > -1) && (cx > -1) && (dx > -1) &&
(ax < gridx) && (bx < gridx) && (cx < gridx) && (dx < gridx) &&
(ay > -1) && (by > -1) && (cy > -1) && (dy > -1) &&
(ay < gridy) && (by < gridy) && (cy < gridy) && (dy < gridy) &&
(!game.isStatic(ax,ay)) && (!game.isStatic(bx,by)) && (!game.isStatic(cx,cy)) && (!game.isStatic(dx,dy)) ) {
return true;
}
return false;
}


I think I was a lot smarter back then.

Name: Anonymous 2012-12-12 3:21

>>5

I think I was a lot smarter back then.

My face when I recently looked at one of my first-year projects and it was full of witty, well-written (but pretentious!) prose comments.

I suppose it's because back then I'd just come out of IB English, but haven't written anything beyond 4chan comments since.

Name: Anonymous 2012-12-12 5:32

>>5
You could try FreeBASIC. It's compatible with most of QBASIC.

Name: Anonymous 2012-12-12 6:18

I have stopped writing qbasic in 1994.

Name: Anonymous 2012-12-12 6:51

menu driven's for poops

printf("hey indian wat u want to do?: ");
gets(cumsfrumdakeyboard);
kbhit

Name: Anonymous 2012-12-12 7:05

>>9
indian

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: Anonymous 2012-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;


and so on

Name: Anonymous 2012-12-12 9:12

You guys still have the same data as from 10 years ago?
No wonder hard drives are necessarily in terabytes of capacity.

Name: Anonymous 2012-12-12 12:33

>>12
THOUSANDS AND THOUSANDS OF kilobytes!

>>5,7
FreeBASIC should work, or QBASIC in DosBox.

Name: Anonymous 2012-12-12 13:57

I'm too lazy to decode the BASIC hieroglyphs, is this XOR-grade encryption?

Name: Anonymous 2012-12-12 18:21

>>14
this is RND1-grade encryption.

_____
1. https://goo.gl/pdqd3

Name: Anonymous 2012-12-12 19:20

>>11
Proof right here that Pascal is the ugly man's ALGOL.

Name: Anonymous 2012-12-13 8:46

>>16
You take that back! I'm a kawaii little girl!

Name: Anonymous 2012-12-13 13:25

I usually get ashamed of the code I write and delete it soon after

Name: Anonymous 2012-12-13 14:17

>>18
You should stop writing in Java/C#.

Name: Anonymous 2012-12-13 14:58

>>8
this
>>18
and this
.
good code of one years staleness is disgusting
job-quality code rots it terms of several days

Name: Anonymous 2012-12-13 14:59

>>18
Most of my code is shit, which is why I try to hide it under abstractions and forget about it the day I wrote it.

Name: Anonymous 2012-12-13 15:19

Pretty cool encryption, i suppose you made the formula right?

Name: Anonymous 2012-12-13 18:08

>>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.

Don't change these.
Name: Email:
Entire Thread Thread List