USER command questions

Tyler Style tyler.style at gmail.com
Thu Sep 10 22:00:34 PDT 2009


John Esak wrote:
> You sound frustrated at filePro for not being able to do something 
> simple.  You haven't taken the time to find out how this should be 
> done.  I suppose it is admirable that you at least tried something you 
> thought might work.  However, when it didn't work, your bashing about 
> on filePro is disheartening.
You're jumping to conclusions assuming this is the only thing I've 
tried.  And to answer the obvious question, no, I didn't feel it 
necessary to list all the things I tried and didn't work, especially if 
the documentation I have indicates that they SHOULDN'T work.

My frustration is perhaps more properly aimed at the documentation.  
Nonetheless, most people would consider the product and the 
documentation as one and the same, as the product is only as good as 
it's documentation.  It doesn't matter if a program can solve world 
hunger with just two commands written in 3 seconds if you aren't aware 
of the command at all, or the documentation is inaccurate or too vague 
to understand.
> When you want to open a directory (folder) and do something to each of 
> the files you find therein, use the "opendir() function.
Actually, I don't want an alternative for opening a directory.  USER ls 
is working beautifully for that.  If you read the original post, I'm 
asking for help with USER and the unix mv command.  But let's address 
the OPENDIR vs. USER issue anyway.

I actually tried OPENDIR first.  I couldn't get it to read in anything - 
all I got back was nulls.  After reading the STN dev ref and online docs 
several times, I found this:
"It returns the number of files in a filePro directory that meet the 
criteria."

So...what the heck is a filePro directory in this context?  The online 
docs do in fact list this in the contents and index.  Unfortunately it's 
"FilePro Directory - Option ?".  Totally off topic.  How about 
"glossary?"  That should work!  Nope, content's entry doesn't have it 
listed, and the index entry leads to "Introduction To fileProODBC".  
Searches also turn up nothing obviously useful.  Google of course brings 
back nada. 

So I decided that this must mean something within the filepro directory 
structure.  Lots of other places refer to filePro directories, which are 
always the filePro file directories.  Since the directory I want to 
examine is outside of that, I decided that the command had some 
arbitrary limit on what it could read.
> It has some special masks to show you only the specified filePro 
> format types of screens outputs, etc.  But, its real value is just 
> specifying some wildcard to retrieve only the exact files you want.  
> You could specify "*" and get every file in a directory (in which case 
> you will also get the . and .. entrires, so you have to be aware of 
> this and skip over them with a test.  But essentially, to use 
> opendir() you do it like this:
>  
>  then: declare num_files(4,.0), cnt(4,.0);  cnt="1"     
>  then: num_files=opendir("*","/tmp/path/to/dir")
The online docs show that the second argument is a filepro file 
filename, not a general filepath as in your example:
"N = opendir("SCR_MASK", "fpcust")              Creates a list of all 
screens for the fpcust file."

When I tried it, I used this (derived from the dev ref):
DECLARE filepath(128,*); filepath='/public/mailerLists/Prospect'
CHDIR filepath;
opendir("*.csv")

There is no formal definition of the second parameter beyond that.  So 
the documentation would lead one to believe this is a bad choice.
> So, you will be saying something like the following.  It will be 
> somewhat stylized, I haven't looked closely at your code, and don't 
> have time to code exadctly what you need... but you can modify the 
> code I"ll write now in about 3 minutes to do just what you need done.  
> Here I go, I'm timing myself....
>  
> <GET_TIME>
>  
>        then: declare num_files(4,.0), num_files(4,.0);  cnt="1"
>        then: num_files=opendir("*","/some/path/to/a/folder")
> loop      if: cnt gt num_files
>        then: num_files=closedir();  return (or go somewher else)
>             if: @dirlist_filename[..] eq "." or @dirlist_filename 
> [cnt] eq ".."
>        then: cnt=cnt + "1";  goto loop
>            if: @dirlist_filename[cnt] eq "something you want" to move"
>        then: declare SysCmd;  SysCmd="mv" < 
> @dirlist_filename[cnt]  the_other_place_and_name { ""
>        then: system SysCmd
>        then: cnt=cnt + "1";  goto loop
>  
> </GET_TIME>  Just about 1 minute 30 seconds.
>  So, you see, it is not so difficult to do a simple job in filePro if 
you use the right tool.

Provided, of course, that you have decades of experience, you know in 
advance all of the commands and their undocumented features, and don't 
have to rely on the online manual or the dev ref.  In which case, yes, 
it is not so difficult!
>  
> Good luck,
>  
> John Esak
Thank you.  I did try your variation out, and OPENDIR does work as you 
describe - huzzah!  Here's the test code:

::DECLARE filepath(128,*):
::DECLARE filename(32,*):
:':':
::filepath="/public/mailerListsSent/Prospects/":
:':':
::'CHDIR filepath:
::i=OPENDIR("*.csv", filepath);:
loop01s::filename=NEXTDIR():
:filename eq "":goto loop01e:
::msgbox filename:
loop01n::goto loop01s:
loop01e:::

Unfortunately, while interesting, none of this addresses why the mv and 
cp commands don't work with USER.

Other than the original example I've also tried USER move= 
filepath{filename<filepath{"imported/"{filename and other variants 
trying to get it to work properly.  Still no dice.  Any ideas?

Tyler Style


More information about the Filepro-list mailing list