|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
JohnHorspool
Joined: 26 Sep 2005 Posts: 270 Location: Gloucestershire UK
|
Posted: Wed Oct 10, 2007 11:55 am Post subject: Starting applications in Explorer with associated files |
|
|
I have written my application to be able to read model data files via the open file dialog, drag/drop and from the command line in a DOS window. All of these methods of model data entry work fine. I then take the root file name and use different extensions like .log and .res to create log, and results files associated with the original model file. In windows explorer I can also open the application by clicking on the model data file. However I have found that with the explorer method the model file name is passed to the application using the library function COMMAND_LINE which works fine except that long file names get shortened to the old 8.3 file name format and subsequently the log and results files use this shortened eight character file name instead of the original long file name, thus losing their associativity. This becomes a problem when I re-visit the model, as the application doesn’t find the existing results file. The confusing thing is, if I start the application from a DOS window command line with the file name appearing after the application name, long file names in this case do not get shortened.
I realise that the problem probably lies with windows and not FTN95, as the application is handed an equivalent command line (with shortened names) by explorer, but is there any setting in windows that can prevent this happening or is there a method I could use to convert a short 8.3 file name back to its long name ? |
|
Back to top |
|
|
IanLambley
Joined: 17 Dec 2006 Posts: 490 Location: Sunderland
|
Posted: Wed Oct 10, 2007 12:35 pm Post subject: |
|
|
John,
I've just tried it on a Windows 2000 system and I don't get the problem, but as I am not allowed to associate file extensions on this machine, I was going through the procedure of double clicking and associating each time which worked here for each single single attempt.
However, I would like to comment that the file name was returned in quotation marks (") and caused a crash when the OPEN statement was issued. So I simply removed the quotes and it opened.
Next I tried using the inquire command as in
Inquire(file=file_name,name=inq_name)
This returned the full path of the file_name as inq_name but translated to uppercase.
Opening the file as say unit=10 and then using the inquire command as
Inquire(unit=10,name=inq_name)
returned the filename unaltered, i.e. still in lower case.
You might try this on your computer and see what happens. Code follows
Regards
Ian
Code: |
program test_start
character*256 file_name,inq_name
call command_line(file_name)
print *,trim(file_name)
call remove_specific_chars(file_name,'"')
print *,trim(file_name)
inquire(file=file_name,name=inq_name)
print *,trim(inq_name)
open(unit=10,file=file_name,status='readonly')
inquire(unit=10,name=inq_name)
print *,trim(inq_name)
end
subroutine remove_specific_chars(text,chars)
character*(*) text,chars
character*1 chr
!c
!c remove specific characters from text string
ilen = leng(text)
iout = 0
do 10 i=1,ilen
if(index(chars,text(i:i)) .eq. 0)then
iout = iout + 1
chr = text(i:i)
text(iout:iout) = chr
endif
10 continue
if(iout .lt. ilen)text(iout+1:)= ' '
return
end
|
|
|
Back to top |
|
|
JohnHorspool
Joined: 26 Sep 2005 Posts: 270 Location: Gloucestershire UK
|
Posted: Wed Oct 10, 2007 3:05 pm Post subject: |
|
|
Hi Ian,
Thank you for responding. I was already removing the quotation marks. I work on both XP and Win2K machines and the same problem occurs on both. Some how Win2K on my machine does manage to associate the file extension to my application, but it doesn't list it !!!! Anyway I was able to delete the association by searching for and deleting the extension in regedit. Then when I clicked on the relevant file in explorer, I was asked for an application to open it with. This worked fine, the long file name was not shortened. I closed the application, then doubled clicked again on the file in explorer. This time explorer did not ask for an application but proceeeded to open the file with my application straight away, only this time the long file name reverted back to the shortened 8.3 naming convention !!!!
At this point I did a google search, which yielded simple visual basic and csharp routines to convert short to long and vice versa, but no fortran (of course). However one of the visual basic routines provided the solution, a DOS dir command using the short file name as an argument returned the long file name
cheers
John |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|