Post by Scott brosious on Jul 13, 2004 13:54:49 GMT -5
Ok, This is not basic4gl code. sorry!
But it is an old program I wrote in qb45.
If anyone wants to convert it I would like to see the results.
part one:
1000 REM *** Dimension Arrays ***
1002 DIM Grab$(80), New$(80), Check(80)
1004 DIM Shift$(80), Pat(80), Equal(80)
1006 DIM B(80)
1100 CLS
1102 W = 1
GOSUB 20000
2500 REM *** Scramble Message ***
2502 GOSUB 9500
2504 Check(W) = R
Pat(0) = R
2506 FOR N = 2 TO Number
2508 GOSUB 9500
Pat(W) = R
2510 W = W + 1
2512 Check(W) = R
2514 FOR V = W - 1 TO 1 STEP -1
2516 IF Check(W) = Check(V) THEN 2524
2518 NEXT V
2520 NEXT N
2522 GOTO 3000
2524 W = W - 1
2526 GOTO 2508
3000 REM *** Show Outcome ***
3002 FOR N = 1 TO Number
3004 New$(N) = Grab$(Check(N))
3006 PRINT New$(N);
3008 NEXT N
PRINT : PRINT
FOR N = 1 TO Number
B(N) = ASC(New$(N))
REM PRINT B(N);
NEXT N
FOR N = 1 TO Number
Mess$ = CHR$(B(N))
Big$ = Big$ + Mess$
NEXT N
3500 REM *** Save File ***
OPEN "c:\qb\Message.txt" FOR OUTPUT AS #1
PRINT #1, Big$
CLOSE #1
PRINT : PRINT
REM *** Save Pattern ***
OPEN "c:\qb\Pat.txt" FOR OUTPUT AS #1
4002 FOR N = 0 TO Number - 1
4004 PRINT #1, Pat(N) - 1;
4006 REM PRINT Pat(N) - 1;
4008 NEXT N
CLOSE #1
5000 FOR N = 0 TO Number - 1
5002 Equal(N) = N
5004 NEXT N
PRINT : PRINT
6000 FOR N = 0 TO Number - 1
6002 FOR Q = 0 TO Number - 1
6004 Count = Count + 1
6006 IF Pat(Q) - 1 = Equal(N) THEN 7000
6008 NEXT Q
6010 REM *** RESET ***
6012 NEXT N
6014 GOTO 9000
7000 REM PRINT Grab$(Check(Count));
7002 Count = 0
7004 GOTO 6010
9000 END
9500 REM *** Random Number Generator ***
9502 RANDOMIZE TIMER
9504 R = INT(RND(1) * Number) + 1
9506 RETURN
20000 REM *** Load in File ***
OPEN "c:\qb\filename.txt" FOR INPUT AS #1
DO
INPUT #1, Temp$
LOOP UNTIL EOF(1) = -1
CLOSE #1
Number = LEN(Temp$)
FOR N = 1 TO Number
A$ = MID$(Temp$, N, 1)
Grab$(N) = A$
NEXT N
CLS
G = 1
FOR N = 0 TO Number - 1
Shift$(N) = Grab$(G)
PRINT Shift$(N);
G = G + 1
NEXT N
PRINT : PRINT
RETURN
ok, now what that does is allow the user to write a message and then the computer scrambles it and saves it as a file also it give you the secret code that part two will need to unscramble it and put it back in order.
part two:
DIM Grab$(80), Shift$(80)
DIM Pat(80), Equal(80)
DIM Check(80)
W = 1
CLS
GOSUB 10000
FOR N = 0 TO Number - 1
Equal(N) = N
NEXT N
FOR N = 0 TO Number - 1
FOR Q = 0 TO Number - 1
Count = Count + 1
IF Pat(Q) = Equal(N) THEN 5500
NEXT Q
5000 REM *** RESET ***
NEXT N
GOTO 9000
5500 PRINT CHR$(ASC(Grab$(Count)));
Count = 0
GOTO 5000
9000 END
10000 REM *** Load in Message ***
OPEN "c:\qb\message.txt" FOR INPUT AS #1
DO
INPUT #1, Big$
LOOP UNTIL EOF(1) = -1
CLOSE #1
Number = LEN(Big$)
FOR N = 1 TO Number
A$ = MID$(Big$, N, 1)
Grab$(N) = A$
NEXT N
G = 1
FOR N = 0 TO Number - 1
Shift$(N) = Grab$(G)
PRINT Shift$(N);
G = G + 1
NEXT N
OPEN "c:\qb\pat.txt" FOR INPUT AS #1
FOR N = 0 TO Number - 1
INPUT #1, Pat(N)
REM PRINT Pat(N);
NEXT N
CLOSE #1
PRINT : PRINT
RETURN
There that should alloy you to reconstruct the original message.
I encurage you to try and see if you can get this these programs working in basc4gl as they might allow you to cipher you code so noone know what it is and can't hack it and when you want to work on your program again you can use your keycode to put it back to the way it was when you were last working on it.
Any qusetion or if you want to show me what you are doing with these two programs.
sbrosious@programmer.net
and also email me if you want all kinds of qb45 programs you can rewrite for basic4gl as I have been working with qb45 for alot longer.
But it is an old program I wrote in qb45.
If anyone wants to convert it I would like to see the results.
part one:
1000 REM *** Dimension Arrays ***
1002 DIM Grab$(80), New$(80), Check(80)
1004 DIM Shift$(80), Pat(80), Equal(80)
1006 DIM B(80)
1100 CLS
1102 W = 1
GOSUB 20000
2500 REM *** Scramble Message ***
2502 GOSUB 9500
2504 Check(W) = R
Pat(0) = R
2506 FOR N = 2 TO Number
2508 GOSUB 9500
Pat(W) = R
2510 W = W + 1
2512 Check(W) = R
2514 FOR V = W - 1 TO 1 STEP -1
2516 IF Check(W) = Check(V) THEN 2524
2518 NEXT V
2520 NEXT N
2522 GOTO 3000
2524 W = W - 1
2526 GOTO 2508
3000 REM *** Show Outcome ***
3002 FOR N = 1 TO Number
3004 New$(N) = Grab$(Check(N))
3006 PRINT New$(N);
3008 NEXT N
PRINT : PRINT
FOR N = 1 TO Number
B(N) = ASC(New$(N))
REM PRINT B(N);
NEXT N
FOR N = 1 TO Number
Mess$ = CHR$(B(N))
Big$ = Big$ + Mess$
NEXT N
3500 REM *** Save File ***
OPEN "c:\qb\Message.txt" FOR OUTPUT AS #1
PRINT #1, Big$
CLOSE #1
PRINT : PRINT
REM *** Save Pattern ***
OPEN "c:\qb\Pat.txt" FOR OUTPUT AS #1
4002 FOR N = 0 TO Number - 1
4004 PRINT #1, Pat(N) - 1;
4006 REM PRINT Pat(N) - 1;
4008 NEXT N
CLOSE #1
5000 FOR N = 0 TO Number - 1
5002 Equal(N) = N
5004 NEXT N
PRINT : PRINT
6000 FOR N = 0 TO Number - 1
6002 FOR Q = 0 TO Number - 1
6004 Count = Count + 1
6006 IF Pat(Q) - 1 = Equal(N) THEN 7000
6008 NEXT Q
6010 REM *** RESET ***
6012 NEXT N
6014 GOTO 9000
7000 REM PRINT Grab$(Check(Count));
7002 Count = 0
7004 GOTO 6010
9000 END
9500 REM *** Random Number Generator ***
9502 RANDOMIZE TIMER
9504 R = INT(RND(1) * Number) + 1
9506 RETURN
20000 REM *** Load in File ***
OPEN "c:\qb\filename.txt" FOR INPUT AS #1
DO
INPUT #1, Temp$
LOOP UNTIL EOF(1) = -1
CLOSE #1
Number = LEN(Temp$)
FOR N = 1 TO Number
A$ = MID$(Temp$, N, 1)
Grab$(N) = A$
NEXT N
CLS
G = 1
FOR N = 0 TO Number - 1
Shift$(N) = Grab$(G)
PRINT Shift$(N);
G = G + 1
NEXT N
PRINT : PRINT
RETURN
ok, now what that does is allow the user to write a message and then the computer scrambles it and saves it as a file also it give you the secret code that part two will need to unscramble it and put it back in order.
part two:
DIM Grab$(80), Shift$(80)
DIM Pat(80), Equal(80)
DIM Check(80)
W = 1
CLS
GOSUB 10000
FOR N = 0 TO Number - 1
Equal(N) = N
NEXT N
FOR N = 0 TO Number - 1
FOR Q = 0 TO Number - 1
Count = Count + 1
IF Pat(Q) = Equal(N) THEN 5500
NEXT Q
5000 REM *** RESET ***
NEXT N
GOTO 9000
5500 PRINT CHR$(ASC(Grab$(Count)));
Count = 0
GOTO 5000
9000 END
10000 REM *** Load in Message ***
OPEN "c:\qb\message.txt" FOR INPUT AS #1
DO
INPUT #1, Big$
LOOP UNTIL EOF(1) = -1
CLOSE #1
Number = LEN(Big$)
FOR N = 1 TO Number
A$ = MID$(Big$, N, 1)
Grab$(N) = A$
NEXT N
G = 1
FOR N = 0 TO Number - 1
Shift$(N) = Grab$(G)
PRINT Shift$(N);
G = G + 1
NEXT N
OPEN "c:\qb\pat.txt" FOR INPUT AS #1
FOR N = 0 TO Number - 1
INPUT #1, Pat(N)
REM PRINT Pat(N);
NEXT N
CLOSE #1
PRINT : PRINT
RETURN
There that should alloy you to reconstruct the original message.
I encurage you to try and see if you can get this these programs working in basc4gl as they might allow you to cipher you code so noone know what it is and can't hack it and when you want to work on your program again you can use your keycode to put it back to the way it was when you were last working on it.
Any qusetion or if you want to show me what you are doing with these two programs.
sbrosious@programmer.net
and also email me if you want all kinds of qb45 programs you can rewrite for basic4gl as I have been working with qb45 for alot longer.