Using fileext to filter directory files

new topic     » goto parent     » topic index » view thread      » older message » newer message

My latest tweaks to the routines that load directory files into ed.ex's file_history sequence.

fileext is used to select only file specs contained in E_FILES.

procedure load_startup_directory_files() 
-- load E_FILES into file_history: 
 
    object tmp = {} 
    tmp = dir("*.*") 
    if not atom(tmp)then 
	if length(tmp)>1 then 
	    for x = 1 to length(tmp) do 
		if find("." & fileext(tmp[x][D_NAME]), E_FILES) then  --<--------- 
		    file_history = update_history(file_history, tmp[x][D_NAME]) 
		end if  
	    end for 
	end if 
    end if 
end procedure 
 
procedure load_files_from_new_directory(sequence path) 
-- load E_FILES into file_history 
-- an absolute path is created by prepending  
-- the path to the new directory 
 
object tmp = {} 
    tmp = dir("*.*") 
    if not atom(tmp)then 
	if length(tmp)>1 then 
	    for x = 1 to length(tmp) do 
		if find("." & fileext(tmp[x][D_NAME]), E_FILES) then  --<--------- 
		    file_history = update_history(file_history, sprintf("%s", {path & SLASH & tmp[x][D_NAME]})) 
		end if 
	    end for 
	    command_history = update_history(command_history, sprintf("ls %s", {path & SLASH})) 
	    command_history = update_history(command_history, sprintf("ls *.ex *.e %s", {path & SLASH})) 
	end if 
    end if 
end procedure 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu