program iodemo(inp,output,infile,outfile); type string15=packed array[1..15]of char; ptr63 =^string63; string63=packed array[0..63]of char; string31=packed array[1..31]of char; var infile,outfile,inp:text; procedure pprompt(s:string15);extern; procedure pdefine(k:integer;p:ptr63);extern; procedure define_files; var filename:string31;length:integer;first_try,ok:boolean; function get_name(prompt:string15;var l:integer;var name:string31):boolean; var ok:boolean;temp:integer; begin if first_try then begin pprompt(prompt);reset(inp);first_try:=false;end else begin pprompt(prompt);while inp^=' ' do get(inp);end; for l:=1 to 31 do name[l]:=' '; l:=1; while (inp^<>' ') and not(eoln(inp)) and (l<31) do begin name[l]:=inp^;get(inp);l:=l+1;end; for l:=l downto 1 do if ('a'<=name[l])and(name[l]<='z')then name[l]:=chr(ord(name[l])-ord('a')+ord('A')); l:=31;while (name[l]=' ') and (l>0) do l:=l-1; ok:=(l>0)and(inp^=' '); if not ok and (l>0) then writeln('Invalid filename ',name); if not ok then while (inp^<>' ') and not(eof(inp)) do get(inp); get_name:=ok; end;{of get_name} procedure call_pdefine(pas_len:integer;pas_file:string15; emas_len:integer;emas_file:string31); const magic=402653312; var p63:ptr63;i,j:integer;param:string63; begin for i:=0 to 63 do param[i]:=' '; for i:=1 to pas_len do param[i]:=pas_file[i]; param[i]:=',';j:=i; for i:=1 to emas_len do param[i+j]:=emas_file[i]; {writeln('Command:pdefine',param);} {writeln('len=',i+j-1:1);} param[0]:=chr(i+j-1); new(p63); p63^:=param; pdefine(magic,p63); dispose(p63); end;{of call_define} begin {define_files} first_try:=true; writeln('Please give the name of the input file to be used:'); call_pdefine(3,'INP............',3,'.IN............................'); repeat; ok:=get_name('Input file: ',length,filename);until ok; call_pdefine(6,'INFILE.........',length,filename); writeln('Please give the name of the output file to be used:'); repeat; ok:=get_name('Output file: ',length,filename);until ok; call_pdefine(7,'OUTFILE........',length,filename); end;{ of define_files} begin {main program} writeln('This demonstration program shows how to avoid that "Data:" prompt'); writeln('that appears when you run a program. I askes for the names of two'); writeln('files and copies the input file to the output file '); writeln('File names must be no more than 31 characters long'); writeln; define_files; reset(infile); rewrite(outfile); while not eof(infile) do begin while not eoln(infile)do begin outfile^:=infile^;get(infile);put(outfile); end; writeln(outfile); if not eof(infile) then get(infile); end; end.