Mombu the Programming Forum

Go Back   Mombu the Programming Forum > Programming > Naming batch files and main-level programs
User Name
Password
REGISTER NOW! Mark Forums Read




Reply
1 17th September 21:09
robi
External User
 
Posts: 1
Default Naming batch files and main-level programs



Hey there everybody,

I've been using batch files and main-level programs a ton lately and I
wondered if anyone has any naming conventions for these files? It's
nice to name them with a suffix of .pro so that IDL will search for
them in !PATH. But then you've got batch files and main-level programs
mixed in with routines; if you .run batch_file.pro you're in for
trouble and if you @main_level.pro you're in for even worse.

My advisor came up with a scheme where he names batch files
name.idl.pro and main-level programs name.idlprc.pro. I have NO IDEA
where he came up with these (especially the latter!); he claims they
were some kind of standard naming convention way, way back in the day,
but I'm extremely dubious. I can't find anything in the online help
about file-naming conventions for batch files and main-level programs;
in fact, the documentation for batch files suggests just throwing a
..pro on the end, but that's it.

Just wondering. -Tim.
  Reply With Quote


 


2 17th September 21:09
greg michael
External User
 
Posts: 1
Default Naming batch files and main-level programs



Ha! Never tried that before, but you're right - @mainprog is really not
a good thing to type!

I don't see the problem, though - surely the batch files should be
doing something more specific than the prog files, so use a name that
reflects that... The other scheme looks ugly to me - won't it mean that
IDL can't find any of your routines?

regards,
Greg
  Reply With Quote
3 17th September 21:09
tim
External User
 
Posts: 1
Default Naming batch files and main-level programs


Hey there Greg,


You're right, the batch file should be descriptive, so, ya know, I have
batch files like accumulate_map.pro, but that doesn't tell me it's a
batch file when I do a directory listing. And there might be a
function named accumulate_spectra.pro... both very descriptive names,
but not in the sense of telling me whether a routine or batch file or
main-level program lives inside, so your suggestion isn't quite the
whole story. The key is, yes, there should be something descriptive in
the name to differentiate batch files and main-level programs from
routines. But that descriptive name has to include some specifier to
denote its batch-ness or main-level-ness. Something like
accumulate_map.bat.pro, well, that might do the trick. Or
accumulate_map.ml.pro or accumulate_map.main.pro for a main-level program.


Sorry, I don't understand this question. All routines should be stored
in files ending in .pro, so IDL will always be able to find them if you
specify the !PATH correctly. The ugly scheme you're referring to was a
stab at differentiating the batch files and main-level programs from
real routines (functions and procedures) while still maintaining the
..pro suffix so that IDL will be able to find them. I guess I'm
thinking that there's no way to avoid the gist of the scheme, but I
agree, the .idl and .idlprc part are pretty ugly to me, and seemingly
pulled out of the blue. I guess .bat.pro and .main.pro might be a bit
more descriptive.

Also, I think I'm being exhaustive when I state that the only types of
code that can be stored in text files and then used in some fashion by
IDL are routines, batch files and main-level programs. I've been using
these for years and always wondered if other people had worried about
differentiating them. I hadn't really started to trip over my own feet
until this last week when I started a huge project in a very ad-hoc
fashion and ended up with a ton of batch files and main-level programs.
They're nice for playing with complex data sets because they allow you
to have the functionality of a function or procedure but also allow you
to have command
line access to the variables that are defined at the MAIN level.

Best -Tim.
  Reply With Quote
4 17th September 21:09
paolo grigis
External User
 
Posts: 1
Default Naming batch files and main-level programs


If you really have trouble distinguishing them,
why don't you just put them in different subdirectories?

Somehting like

\yourproject\batch\
\yourproject\routines\

should clear any ambiguity...

Ciao,
Paolo
  Reply With Quote
5 17th September 21:09
greg michael
External User
 
Posts: 1
Default Naming batch files and main-level programs


Hi Tim,

But if your routine is called 'fred' and you save it in a file called
fred.idl.pro, when you call fred, IDL will be looking for fred.pro...
and therefore not find it.

If I had this problem, I'd either just put the batch files in their own
directory which tells what they are (maybe called 'batch'), or tag the
batch files and leave the rest alone (although probably better with a
'_' separator than a '.', for the reason above. You can also use a file
with no extension to indicate a batch file - that's fine on UNIX; not
ideal on Windows.

regards,
Greg
  Reply With Quote
6 17th September 21:09
greg michael
External User
 
Posts: 1
Default Naming batch files and main-level programs


Sorry - didn't catch the main-level part - I never use it myself. So
then you're using the full name anyway, so it would be found.

regards,
Greg
  Reply With Quote
7 17th September 21:10
tim
External User
 
Posts: 1
Default Naming batch files and main-level programs


Hey there Greg,

Right, you'd have to do @fred.bat or .run fred.main


Hmm, I don't know Windows well at all... I wonder if the above would
work... i.e., if you named a batch file fred.bat.pro and then did
@fred.bat ... can you have multiple periods in a Windows file name or
do you have to use underscores everywhere?

Thanks for the ideas. Best -Tim.
  Reply With Quote
8 28th September 10:18
jean h.
External User
 
Posts: 1
Default Naming batch files and main-level programs


No, he means that if you have a function/procedure "foo", it must be
saved in the file foo.pro if you want IDL to find it. If you save it in
bar.pro, IDL will not find it.


For a batch file, it would work... not that in this case it is uselless
to save as a .pro... You can save it as foo.idl and type @foo.idl
the good point of .pro extension is that you don't have to type it...
@foo = @foo.pro

Now for your question, yes, you can have multiple points...

Here is another suggestion, close to Greg's one:
why don't you call your files b_name.pro for the batch files and
name.pro for the routines? elegant, small, obivous...

Jean
  Reply With Quote
9 28th September 10:18
tim
External User
 
Posts: 1
Default Naming batch files and main-level programs


Hi there Jean,

Ah, right, that's true, but I'm not suggesting that. Routines named
routine_name should be stored in filed name routine_name.pro. That
whole .idl thing was for batch files... I'm not, and never was,
suggesting that a *routine* be stored in routine_name.idl.pro.


I completely disagree with your assertion that it is useless to save a
batch file as a .pro file. It is true that the file can be named
foo.idl and that @foo.idl would work, but ONLY if (a) you are in the
directory in which foo.idl is stored, (b) that directory was explicitly
added to !PATH, or (c) there happens to be a .sav or .pro file in that
directory so that it was added to !PATH via the "+" mechanism.
Moreover, one of the suggestions was to store all the batch files in a
directory named batch/ ... well, there ya go... that entire directory
would be skipped by the "+" path expansion because there would be no
..pro files in it. So you'd have to be in that directory to use those
batch files, or worse, have to execute them with a fully-qualified path
to the batch file.

Great, thanks for confirming that.

Certainly true, good idea; maybe, in my mind, not as obvious to someone
who didn't create the files as the .bat.pro or .main.pro suffixes.

Anyway, it sounds like this is just not something most people have
encountered. I guess I can go back to assuming I'm the only one
worrying about this oddity.

Best -Tim.
  Reply With Quote
Reply


Thread Tools
Display Modes




666