GMW@psuvm.BITNET (06/05/85)
%% Program to download files to my Commodore 64 %% Sends lines, one at a time. Each line is followed by a %% checksum. Commodore validates checksum, and either sends %% "OK" or "NG". If no good, retransmit. Last line's checksum %% is sent with a leading minus sign to show end-of-file. start_up = proc () po:stream := stream$primary_output() pi:stream := stream$primary_input() file:stream := stream$open(file_name$parse(get_jcl()),"read") except when not_possible(why:string): stream$putl(po,"Could not open file: " || why) return end received:string := "" while received ~= "OK" do received := stream$getl(pi) end % don't start until initial OK while ~stream$empty(file) | received = "NG" do line:string if received = "OK" then line := stream$getl(file) end checksum:int := 0 for c:char in string$chars(line) do stream$putc_image(po,c) checksum := checksum + char$c2i(c) end stream$putc_image(po,'\r') if stream$empty(file) then stream$putc(po,'-') end stream$puts_image(po, int$unparse(checksum) || "\r") received := stream$getl(pi) end