procedure sortnames(i : integer); { sort name file selected by i} var j,rec : integer; finished : boolean; namepkt,nextpkt : namentry; temps : string20; begin poscur(7,1); flashon; write('SORTING'); flashoff; assign (fn,padarray[i].namfile); update(fn); j:=1; rec:=0; finished:=false; repeat if rec=0 then finished:=true; seek(fn,rec); read(fn,namepkt); if not eof(fn) then begin read(fn,nextpkt); if namepkt.names[1]>nextpkt.names[1] then begin finished:=false; seek(fn,rec); write(fn,nextpkt); write(fn,namepkt); end; if namepkt.names[1]=nextpkt.names[1] then begin if namepkt.namel0 then begin for j:=1 to mapa[loop].mapl do begin receivehexpair(num); mapa[loop].maps[j]:=chr(num); end; end; loop:=loop+1; until finished; receivehexpair(num); {get length of set parameter} setpl:=num; receivehexpair(num); {get zero after length} if setpl>0 then begin for j:=1 to setpl do begin receivehexpair(num); setps[j]:=chr(num); end; end; receivehexpair(num); {get length of description} descl:=num; receivehexpair(num); for j:=1 to descl do begin receivehexpair(num); descs[j]:=chr(num); end; poscur(5,20); hlighton; write(names); hlightoff; end; { end with} receivehexpair(num); {get checksum} write(fn,namepkt); nameno:=nameno+1; end else {end =8} notex:=false; end {end =2 test} else begin receivehexpair(chcksum) ; { first packet not received correctly } poscur(7,1); write('--> Error in receive name table. ABORTING.') ; pause; notex := false end {Num <> 2 test end} end ; {matches while notex} if nameno = 0 then erase(fn) { if no names received } else close(fn); if nameno<>0 then sortnames(i); end {matches start receiving yes} else begin poscur(7,1); write('--> No action occured') { error conditions } end; end ; { rec } procedure tranname(i:integer); {main calling procedure for transmitting configs } var alldone : ptr ; finished, netok : boolean ; number , num , con , nameno : byte ; namepkt : namentry; j,loop : integer ; begin if fstat(padarray[i].namfile) then begin cls; writeln; poscur(1,1); hlighton; write(' Set up call to manager port, names saved from SuperPAD ',padarray[i].address); setpromptline; setupbuf ; clrbuf ; asemul; cls; poscur(3,1); write('Start name transmission (Y/N): ') ; if yesno then begin assign(fn,padarray[i].namfile); reset(fn); finished:=false; rcstr.charin := ord('b') ; { get into correct mode } sctprt ; wait(10) ; clraux ; nameno := 0 ; rcstr.charin := ord(':') ; { send first char of update packet } sctprt ; sendhexpair(2); sendhexpair(10); sendhexpair(244); waitchaux ; prtchr ; receivehexpair(num); receivehexpair(num); receivehexpair(num); poscur (5,1); write('Transmitting name: ') ; repeat read(fn,namepkt); with namepkt do begin poscur(5,20); hlighton; write(names); hlightoff; rcstr.charin := ord(':') ; { send first char of packet } sctprt ; checksum:=0; sendhexpair(pktl) ; sendhexpair(8); sendhexpair(0); {dummy number} sendhexpair(namel) ; sendhexpair(0); for j:=1 to namel do sendhexpair(ord(names[j])); sendhexpair(omapl); sendhexpair(0); for j:=1 to 5 do begin if mapa[j].mapl<>0 then begin sendhexpair(mapa[j].mapf); sendhexpair(mapa[j].mapl); for loop:=1 to mapa[j].mapl do sendhexpair(ord(mapa[j].maps[loop])); end; end; sendhexpair(setpl); sendhexpair(0); if setpl<>0 then begin for j:= 1 to setpl do sendhexpair(ord(setps[j])); end; sendhexpair(descl); sendhexpair(0); for j:= 1 to descl do sendhexpair(ord(descs[j])); { note : assumes checksum is correct } if checksum<>0 then sendhexpair(256-checksum) else sendhexpair(0); end ; { end with} waitchaux ; { receive confirmation } prtchr ; receivehexpair(number) ; receivehexpair(num) ; receivehexpair(con) ; if num <> 2 then begin writeln; writeln('--> Load finished.') ; pause; finished:=true; end else begin rcstr.charin := ord(':') ; { send first char of update packet } sctprt ; sendhexpair(2); sendhexpair(11); sendhexpair(243); waitchaux ; prtchr ; receivehexpair(num); receivehexpair(num); receivehexpair(num); end; until (eof(fn)) or (finished); end; {said no} end {file not found} else begin writeln('--> cannot find ',padarray[i].namfile); pause; end; end ; { trans } procedure import(i:integer) ; { import ascii file into namfile} var finished, notex , first , netok : boolean ; k,j,loop : integer ; l, num , nameno , number , chcksum : byte ; namepkt : namentry; currrec , lastrec : ptr ; temps : string64; begin first := true ; cls ; poscur(3,1); write('Filename to import from: ') ; fnread(13,temps); writeln; if fstat(temps) then begin assign(f,temps); reset(f); assign(fn,padarray[i].namfile); rewrite(fn); nameno := 0 ; repeat with namepkt do begin readnst(temps); {read name} namel:=slen(temps); {save length} for j:=1 to 18 do names[j]:=temps[j]; loop:=1; for j:=1 to 5 do mapa[j].mapl:=0; finished:=false; readnst(temps); {read restricted flag} if temps[1]='1' then mapa[1].mapf:=64 else mapa[1].mapf:=0; num:=0; for loop:=1 to 5 do begin readnst(temps); {get map} mapa[loop].mapl:=slen(temps); {save length} if (mapa[loop].mapl<>0) then num:=loop; for j:=1 to 64 do mapa[loop].maps[j]:=temps[j]; end; num:=mapa[1].mapf+num; for loop:=1 to 5 do mapa[loop].mapf:=num; if mapa[1].mapl=0 then begin mapa[1].mapl:=1; mapa[1].maps[1]:='-'; end; readnst(temps); setpl:=slen(temps); for j:=1 to 32 do setps[j]:=temps[j]; if setpl=0 then begin setpl:=1; setps[1]:=' '; end; readnst(temps); descl:=slen(temps); for j:=1 to 32 do descs[j]:=temps[j]; l:=0; for j:=1 to 5 do begin l:=l+mapa[j].mapl; if mapa[j].mapl<>0 then l:=l+2; end; omapl:=l; l:=l+descl+namel+setpl+1+1+2+2+2+2+1; {type, nameno, namel, omapl, settl+descl+chksum} pktl:=l; end; { end with} write('.'); write(fn,namepkt); nameno:=nameno+1; until eof(f); close(fn); close(f); sortnames(i); end {end fstat test} else begin poscur(7,1); write('--> Cannot find name file.') ; pause; end; end; procedure export(i:integer); {main calling procedure for transmitting configs } var alldone : ptr ; abort, netok : boolean ; number , num , con , nameno : byte ; namepkt : namentry; j,loop : integer ; temps : string64; begin if fstat(padarray[i].namfile) then begin abort:=false; cls; poscur(3,1); write('File to store ASCII version of name table: ') ; fnread(13,temps); writeln; if not fstat(temps) then begin assign(f,temps); rewrite(f); end else begin poscur(5,1); write('--> file already exists, overwrite (Y/N): '); if yesno then begin assign(f,temps); rewrite(f); end else abort:=true; end; if not abort then begin writeln; assign(fn,padarray[i].namfile); reset(fn); nameno := 0 ; repeat write('.') ; read(fn,namepkt); with namepkt do begin for j:=1 to namel do write(f,names[j]); writeln(f,''); if mapa[1].mapf>64 then writeln(f,'1') else writeln(f,'0'); for j:=1 to 5 do begin for loop:=1 to mapa[j].mapl do write(f,mapa[j].maps[loop]); writeln(f,''); end; if setpl<>0 then begin for j:=1 to setpl do write(f,setps[j]); end; writeln(f,''); for j:= 1 to descl do write(f,descs[j]); writeln(f,''); end ; { end with} until (eof(fn)); end; {said abort} end {file not found} else begin writeln('--> cannot find ',padarray[i].namfile); pause; end; end ; { export }