{WritEf v1.1.Beta by xenion@libero.it } uses crt; var file1 : file of byte; c1,inc,binary,i : integer; byte0 : byte; str0 : string; cont : longint; function strtoint(str: string) : longint; var a : integer; b : longint; begin val(str,b,a); strtoint:=b; end; begin if paramcount < 3 then begin clrscr; writeln; writeln('WritEf v1.1.Beta by xenion@libero.it'); writeln; writeln('> Sovrascrive con bytes dati il file input ad una posizione X <'); writeln; writeln('La sintassi cambia a seconda delle opzioni specificate : [-b] [-i] [-c]'); writeln; writeln('[Nessuna opzione] Immissione dati in formato stringa'); writeln('$writef [filename] [X1] [string1] [X2] [string2] [X3] [string3] ...'); writeln; writeln('[-b] Immissione dati in formato ottale'); writeln('$writef -b [filename] [X1] [byte1] [X2] [byte2] [X3] [byte3] ...'); writeln; writeln('[-i] Posizione incrementale'); writeln('$writef -i [filename] [X] [string1] [string2] [string3] ...'); writeln; writeln('[-c] riscrive o crea il file'); writeln; writeln('E'' possibile utilizzare contemporaneamente le 3 opzioni, badando al'); writeln('loro ordine : -b -i -c'); halt; end; i:=1; binary:=0; if paramstr(i) = '-d' then begin write('>> '); assign(file1,paramstr(i+1)); reset(file1); cont:=filesize(file1); close(file1); byte0:=48; binary:=0; repeat assign(file1,paramstr(i+1)); rewrite(file1); binary:=binary+1; write('.',binary); for cont:=1 to cont do write(file1,byte0); close(file1); until strtoint(paramstr(i+2))=binary; writeln(' .ok'); halt; end; if paramstr(i) = '-b' then begin binary :=1; i:=i+1; end; inc:=0; if paramstr(i) = '-i' then begin inc:=1; i:=i+1; end; if paramstr(i) = '-c' then begin assign(file1,paramstr(i+1)); rewrite(file1); i:=i+1; end else begin assign(file1,paramstr(i)); reset(file1); end; if inc=0 then i:=i-1 else begin seek(file1,strtoint(paramstr(i+1))-1); i:=i+1; end; repeat if inc = 1 then begin i:=i+1; str0:=paramstr(i); end else begin i:=i+2; seek(file1,strtoint(paramstr(i))-1); str0:=paramstr(i+1); end; if binary=0 then for c1:=1 to length(str0) do begin byte0:=ord(str0[c1]); write(file1,byte0); end else begin byte0:=strtoint(str0); write(file1,byte0); end; if (inc = 0) and (i+1 = paramcount) then i:=i+1; until i=paramcount; close(file1); end.