- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi!
I need to tell my fortran program which directory to find all the files it will work with. To accomplish this, I use a text parameter through CALL GETARG().
I then
filename = workingdirectory // 'filename.dat'
OPEN(50,FILE=filename,FORM='FORMATTED')
Unfortunately, this leads to the following content in filename:
c:directory1 est svd2b.dat
I need a way to remove all the spaces. Any advice is greatly appreciated!
Thanks!
-- Kai
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use TRIM(workingdirectory)//trim(filename)
Linda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks! That helps a lot. Unfortunately, that seems to remove spaces from anywhere in the string (since I'm dealing with directory names, it removes some crucial spaces). Is there any way to remove only trailing spaces?
-- Kai :-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
TRIM( ) only removes trailing blanks. Standard Fortran since "forever".
It is best you read the manual, or type "trim fortran" into Google .
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks David!
You are right, of course, and I did actually google the problem before asking. I just realized that TRIM was not my problem.
As I mentioned above, I use GETARG() to get the directory name as a command line parameter. Unfortunately, it turns out that when the directory name contains spaces, these are treated as different parameters. Arg(h)...
I guess my question is whether there is a way to cap a string so that GETARG understands that it is one string rather than two (or 3,4,5,6)? I've tried Google with no luck, and my guesses of "c:dir 1" and 'c:dir 1' don't work.
Kai :-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use double quotes ( application.exe "here is the argument")and it will work fine.
Just to prove it, here is a simple Fortran console .EXE which I copied to the root directory c: and then ran from the Start..Run...command line as
c:getargument "here is an argument"
which gave the console output shown in the screenshot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you don't want to do this, you can add a space between each argument you retrieve with GETARG.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page