BHUBER@ECLA.USC.EDU (09/30/87)
Following Orca Pascal source code can be used to substitute for the UCSD Pascal IOError function. It provides additional functionality because, assuming that the requested file DCB is found, then file DCB information can be examined. For example, the code below will "reject" a DCB even if found if it is not an Appleworks word processor file (filetype $1A). The function "Find_File_DCB" will return a "TRUE" if the requested DCB is found or "FALSE" if not found. Call the function by coding the function name with the desired file name passed as a formal parameter inside parentheses. Example: If find_file_DCB(file_name_desired_goes_here) then {found the file} else {did not find the file}; type file_name_string = string[64]; var in_file_name: file_name_string; function Find_File_DCB (file_wanted: file_name_string): boolean; type pString = record len: byte; name: string[255]; end; pStringPtr = ^pString; getFileInfoDCB = record pathName: pStringPtr; access, fileType: integer; auxTypeOrTotalBlocks: longint; storageType, createDate, createTime, modDate, modTime: integer; blocksUsed: longint; end; getFileInfoDCBPtr = ^getFileInfoDCB; var trial_input_file_name_record: getFileInfoDCBPtr; trial_input_file_name: pStringPtr; function Get_File_Info (var parms: getFileInfoDCB): integer; prodos (6); begin {Find_File_DCB} new(trial_input_file_name); with trial_input_file_name^ do begin len := length(file_wanted); name := file_wanted end; new(trial_input_file_name_record); trial_input_file_name_record^.pathName := trial_input_file_name; Find_File_DCB := (get_file_info(trial_input_file_name_record^) = 0) and (trial_input_file_name_record^.fileType = $1A) {AWP is $1A} end; {Find_File_DCB} ------------------------------------------------------------------------------ repeat in_file_name := ''; write('Please provide an AWP input filename? '); readln(input,in_file_name); {following used to strip leading/following blanks to ensure legal names} while (length(in_file_name) > 0) and (in_file_name[1] = ' ') do delete(in_file_name,1,1); {strip pre and post blanks} while (length(in_file_name) > 0) and (in_file_name[length(in_file_name)] = ' ') do delete(in_file_name,length(in_file_name),1); if in_file_name = 'quit' then halt(0); {in case you want to exit early} until Find_File_DCB(in_file_name); reset(in_file,in_file_name); {guaranteed file exists by this time} --------------------------------------------------------------------------- If desired, it would be relatively simple to make this into a 'USES' file, assuming one did not need to easily change the code. Hope this helps the porting business, Bud Huber