|
Thanks for your answerd, Scott. I have created exactly this solution. One question still. Does it consume much more time that a normal access? -----Ursprüngliche Nachricht----- Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im Auftrag von Scott Klement Gesendet: Freitag, 04. Juni 2004 11:00 An: RPG programming on the AS400 / iSeries Betreff: Re: Access API but with wild cards? Hello Jaime, > Does anybody know how to check if a file, that we just know the first > 5 possitions and the extension exists in a folder of the IFS? > Something like the access api, but with wild cards? You can't use the access() API, but you can use the opendir(), readdir(), closedir() APIs to read through the files in a directory and check to see if one or more of them matches your pattern. For example, the following program checks to to see if there's any files in the /home/klemscot directory that start with the letter 'e' and end with the letters '.txt'. If at least one file is found, the "FOUND" field is set *ON. H DFTACTGRP(*NO) * * You can get the ifsio_h member from my IFS tutorial * http://www.scottklement.com/rpg/ifs.html * /copy ifsio_h D msg s 52A D dirHandle s * D name s 640A varying D found s 1N inz(*OFF) c eval *inlr = *on c eval dirHandle = opendir('/home/klemscot') c if dirHandle = *NULL c eval msg = 'opendir() failed.' c dsply msg c return c endif c eval p_dirent = readdir(dirHandle) c dow p_dirent <> *NULL c eval name = %subst(d_name:1:d_namelen) c if %len(name) > 5 c and c %subst(name: 1: 1) = 'e' c and c %subst(name: %len(name)-3: 4) = '.txt' c eval found = *ON c endif c eval p_dirent = readdir(dirHandle) c enddo c callp closedir(dirHandle) c return -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.
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.