gwbasic311

dreging.jpg














Home | QBASIC in XP | random number generater for codeing blogs | 3.11 & 3.23 | e-mail text | code pictures | ser ## | contact us | 98 & random files | random acess | print bmp files to screen in basic | BLOG





the following program will count the number of times each asci charecter is used in a binary file.it is usefull to know what's in the file before accessing it.
 
10 FILES'ASCOUNT  ASC CODES.r,134
20 DIM Z(260)'setup array for the number of chr$s in file
30 INPUT"FILE FOR INPUT";I$:T=INSTR(I$,"."):T$=MID$(I$,1,T-1)+".ASC"'make new file for the number of chr$ in the file "filename.ASC"
40 OPEN "R",#1,I$,134:IF LOF(1)<1 THEN CLOSE:KILL I$:GOTO 230'deletes file typed in wrong(i needed this)
50 FIELD #1, 134 AS A$
60 A=INT(LOF(1)/134)+1:PRINT A'number of lines in file
70 LF=LOF(1)
80 OPEN T$ FOR OUTPUT AS #2
90 TM=INT(LOF(1)/4581818!)+1:PRINT"THIS WILL TAKE ABOUT "TM" MINUTES"'guess how long prog will take to process file will,verry with cpu's
100 FOR N=1 TO A
110 GET #1,N
120 FOR B=1 TO 134:C=ASC(MID$(A$,B,1)):GOSUB 240:NEXT B
130 NEXT N
140 CLOSE 1
150 FOR D=0 TO 130:PRINT D;Z(D);:NEXT D
160 INPUT"";S$'stop scrooll to vie(not good)use editer to see .asc file
170 FOR E=131 TO 255:PRINT E;Z(E);:NEXT E
180 FOR D=0 TO 255:PRINT#2,D,Z(D)'print to "file.ASC"to view
190 NEXT D
200 FOR G=0 TO 255:CL=CL+Z(G):NEXT G'compare results to lof(1)
210 PRINT CHR$(10):PRINT"lof= ";LF,"progam results= ";CL
215 PRINT"the difference between the length of the file and results is the trailing spcs,from the real end of the file and the arbatary end of 134,set by the prog, in the last line of the file
220 CLOSE:END
230 CLS:PRINT"************ can't find file named ";I$:GOTO 10
240 Z(C)=Z(C)+1:RETURN




























after pasteing the above programe the line wrap must be unwraped .the results of the prog will be in a file with the same name as the file scaned with a ".asc" at the end.to see the file names when the prog is run,the files must be in the same directory as you.all the counts are correct(i think) except the spcs.this prog opens the file with an arbatray length of 134(the length of a header in a .wav file) and it would be rare for the file to end there.the difference between the lof and caluated length is the number of spcs from the real end of the file,to the end of the last line in the file when oppened.
------------------------------------------------------------------
the next prog will take a text file,and find the location of each character from the txt file,and find it's location in a binary file(jpg seem the best) and put that location in another file.the name of that file is "list.lst".(i'm going to try pasting it here useing basic)
LIST
10 '"COPY"
20 FILES:INPUT"DIGITAL FILE ";D$'file to scan
30 INPUT "TXT FILE";T$'file to be recreated(coded)
40 OPEN "R",#1,D$,1:IF LOF(1)<1 THEN CLOSE:KILL"D$":GOTO 20
50 FIELD #1,1 AS A$
60 OPEN "R",#2,T$,1:IF LOF(2)<1 THEN CLOSE:KILL"D$":GOTO 20
70 FIELD #2,1 AS B$
80 OPEN "O",#3,"LIST.LST"'data list
90 FOR T=1 TO LOF(2)
100 GET #2,T'B$
110 GOSUB 140
120 NEXT T
130 CLOSE:END
140 FOR D=1 TO LOF(1)'start scan
150 GET #1,D'A$
160 IF A$=B$ THEN PRINT #3,D;:RETURN
170 IF D=LOF(1) THEN GOTO 190'chr$ not found
180 NEXT D
190 PRINT"CHR NOT FOUND":CLOSE:END
Ok_
i can't believe IT WORKED well any way.the next prog will be the one to retrive the text file from the binary file(which be the same file used to create the "list.lst" file in line 80.these are examples of useing basic to access and create files.i hope they are helpful to some. 






Enter secondary content here




























































































here is the prog that will recreate the file that was coded.it finds the location,given in the numbers file,in the file used for the code, and prints the charecter on the screen,
 
10 '"UNCOPY"
20 PRINT"the file to be scaned and "DATA.LIST"must be in same directory"
30 FILES:INPUT"digtil file";D$'file to scan
40 OPEN "R",#1,D$,1:IF LOF(1)<1 THEN CLOSE:KILL"D$":GOTO 30
50 FIELD #1,1 AS A$
60 OPEN "I",#2,"LIST.LST"'data list;created by copy prog
70 FOR T=1 TO LOF(2)
80 IF EOF(2) THEN PRINT"that's all":CLOSE:END
90 INPUT #2,N'get loc in dig file
100 GOSUB 120
110 NEXT T
120 GET #1,N'get chr from dig file
121 IF A$=CHR$(13) THEN GOTO 140'skip carege return
130 IF ASC(A$)=10 THEN INPUT "",BS$'pause to vie line
131 IF A$=CHR$(10) THEN GOTO 140 ELSE PRINT A$;
140 RETURN
these progs need digtial files like jpg files to work.the progs can be made much more dificult to decode.of couse the same file must be used to code & decode.
 
 
the following file must be namd "list.lst" for the prog to work

314 310 311 313 60 317 311 778 778 60 313 310 1647 317 60 314 310 307 60 317 246 319 60 313 1167 246 778 778 60 1167 307 313 313 246 309 307 313 42 39 1167 246 319 60 266 307 60 313 307 1416 314 60 314 1647 60 246 1416 306 60 308 267 1647 1167 60 1240 307 267 313 1647 1416 313 60 317 310 1647 60 246 267 307 60 305 1647 1416 305 307 267 1416 307 306 42 39 246 266 1647 315 314 60 1240 267 311 316 311 305 319 60 1647 1416 60 314 310 307 60 1416 307 314 42 39 42 39