Input From - error trapping question

Hi All,

I have a simple question that I can't seem to find any information
on. If someone could please help it would be really appreciated.

I am asking the user to put in a path and filename, eg. c:\temp\sometestfile.csv.
I then open the file and read the contents. The problem is
when they enter an invalid path or filename, ie. one that does
not exist, I would like to be able to display my own message
instead of the progress error that I get now.

The code is very simple. what I need to add to the, very simple,
example below to capture the errors?

/*********************************************/
/* Open input from file */
INPUT FROM VALUE(lvFile:SCREEN-VALUE IN FRAME Frame-A).

REPEAT:
/* Read in each line */
IMPORT UNFORMATTED lvLine.

/* Do all processing here */
END.

INPUT CLOSE.
/*******************************************/


If anyone has a solution I would love to hear it. Thank you all
in advance for any help offered.

Wayne Singh
Cedar Creek Company
Australia
 

TonySh

New Member
Hey there,

The way I do it is:
if search(fTextFile:screen-value) <> ? then
iDescription:read-file(fTextFile:screen-value).
else message "File Not Found".

Where fTextFile is your fill-in where the file name is;
iDescription is your screen field (in my case editor box) where you want you file contest to appear.

You can also let your users browse for a file if they're not sure about the file name.

system-dialog get-file fTextFile.
display fTextFile with frame {&frame-name}.

I'm not that expirienced myself, but it works for me.
Hope this helps. :awink:
 
Top