Selecting file to import at runtime

When data importing, sometimes we need to import a CSV file. To make the code flexible it is best to make the filename a variable and allow the user to select the file they want to import. This can be done in a class or a job using the Dialog control.

A code example is as follows:

Dialog Dialog;
DialogField filename;
;
Dialog = new Dialog(“Select File”);
filename = Dialog.addField(extendedTypeStr(filenameopen), “@SYS53125”);
if(Dialog.run())
{
if(WinAPI::fileExists(filename.value()))
{
Io = new CommaIO(filename.value(), “r”);
data = Io.read();
while(Io.status() == IO_Status::Ok)
{
data = Io.read();
}
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s