× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




Scott has code to use IFS functions to open and query a folder for files
that are in the folder.

I have a service program that encapsulates these functions called XVIFSX
that I can provide to anyone interested. I can, also, send it over to
Lief at www.think400.dk/downloads.htm to make it available. Let me know
if you are interested.

Note in the following example, I have cut out of lot of stuff that has
nothing to do with showing the example.

*--------------------------------------------------
* Procedure name: ProcessDirectory
* Purpose: Process list of files in a given directory.
* Returns:
*--------------------------------------------------
p ProcessDirectory...
p b Export
d pi
d InDirectory...
d 128a Const

d DirectoryHandle...
d s Like(StdInt)
d FileName...
d s 512a Varying
/Free

// Open directory list.
DirectoryHandle = IFSX_OpenDirectory(%TrimR(InDirectory));

//Loop until we have processed all.
DoU 0 = 1;
// GetDirectoryEntry returns false if nothing found.
If IFSX_GetDirectoryEntry(DirectoryHandle:
FileName );
ProcessFile(InDirectory:
FileName );
Else;
Leave;
EndIf;
EndDo;

IFSX_CloseDirectory(DirectoryHandle);

/End-Free
p e
*--------------------------------------------------
* Procedure name: ProcessFile
* Purpose: Process a given EDI file
* Returns:
*--------------------------------------------------
p ProcessFile...
p b
d pi
d InDirectory...
d 128a Const
d InFileName...
d 512a Varying
d Const


d InPath...
d s 512a Varying
d InHandle...
d s Like(StdInt)
d CharactersRead...
d s Like(StdInt)
d EndOfFile...
d s Like(StdLgl)
d Inz(cFalse)
d Record...
d s 32767a
/Free

// Get full path name.
If %Subst(InDirectory :
%Len(InDirectory):
1 ) = '/';
InPath = %Trim(InDirectory) + InFileName;
Else;
InPath = %Trim(InDirectory) + '/' + InFileName;
EndIf;

// Open file as input only as text.
InHandle = IFSX_OpenText(InPath :
O_RDONLY + O_EXCL + O_TEXTDATA);

// Loop through file.
DoU 0 = 1;
// Get one line. Programs assumes the data is going to in
standard
// <CR><LF> format. If not, we would have a problem.
CharactersRead = IFSX_ReadLineText(InHandle :
%Size(Record):
EndOfFile :
Record );
If CharactersRead > 0;

// Write line.
EndIf;

If EndOfFile;
IFSX_CloseFile(InHandle);
Return;
EndIf;
EndDo;

/End-Free
p e




As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.