'this library puts up a dialog asking the user to enter a string list. The user can either manually enter a space delimited list, or they can provide the name of an svector object in the workfile containing the list, or they can provide the name of a table object (where by the first column is assumed to contain the list), or they can provide the name of a text file on disk (where it is assumed that each line contains a new entry), or an Excel file on disk (data must be in the first column, first row) 'Issues - because tables don't know how many rows they have, the only way to detect the end of the list is to use a blank line to signify the end. Thus if the list truly does have blanks, it will mess things up. '%list will contain the list on output '%promptstr should contain the message prompt that will be displayed on the dialog subroutine getlistdlg(string %list, string %promptstr) !size = 100 if @len(%promptstr)>!size then !size = @len(%promptstr) endif !result = @uiedit(%list,%promptstr, !size) if !result = -1 then stop endif call getlist(%list) endsub subroutine getlist(string %list) 'check whether entered text is a text file on disk if @upper(@right(%list,4)) = ".TXT" or @upper(@right(%list,4)) = ".CSV" then if @instr(%list,"\") =0 then 'add the current eviews default directory to the start of the file name if no path was entered (using a search for the "\" character to determine if a path was entered %list = @datapath + "\" + %list endif if @fileexist(%list) = 0 then 'file not found %msg = %list + " was not found on disk" @uiprompt(%msg) stop endif call getlistfromtextfile(%list) return endif 'check whether entered text is an Excel file on disk if @upper(@right(%list,4)) = ".XLS" or @upper(@right(%list,5)) = ".XLSX" then if @instr(%list,"\") =0 then 'add the current eviews default directory to the start of the file name if no path was entered (using a search for the "\" character to determine if a path was entered %list = @datapath + "\" + %list endif if @fileexist(%list) = 0 then 'file not found %msg = %list + " was not found on disk" @uiprompt(%msg) stop endif call getlistfromxlsfile(%list) return endif 'check whether a table or svector object in workfile if @len(@wfname) > 0 then if @isobject(%list) then %tempn = @getnextname("_temp") if {%list}.@type="TABLE" then 'if it is a table object, then fill in the list variable from the table table {%tempn} = {%list} %line = {%tempn}(1,1) !row = 2 %list2 = "" while @len(%line)>0 %list2 = %list2 + " " + %line %line = {%tempn}(!row,1) !row = !row+1 wend %list = %list2 return else if {%list}.@type = "SVECTOR" then 'if it is a svector object, then fill in the list variable from the svector svector {%tempn} = {%list} %list2 = "" for !i=1 to @rows({%tempn}) %list2 = %list2 + " " + {%tempn}(!i) next endif %list = %list2 return endif endif d(noerr) {%tempn} endif 'If not a file or an object, return list as string (i.e. do nothing) endsub subroutine local getlistfromtextfile(string %list) 'check whether a workfile exists - if not, we need to create one to put the tempoary table object into !haswf = 1 if @wfname = "" then wfcreate u 1 !haswf = 0 endif 'create a table object containing shell(out=mytab) type {%list} %line = mytab(1,1) !row = 2 %list = "" while @len(%line)>0 %list = %list + " " + %line %line = mytab(!row,1) !row = !row+1 wend 'if we created a temporary workfile, close it if !haswf = 0 then wfclose endif endsub subroutine getlistfromxlsfile(string %list) 'open the excel file wfopen {%list} range="a1" %list = "" for !i=1 to @obsrange %list = %list + " " + series01(!i) next 'close the workfile wfclose {%list} endsub