- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can save a completed image in the subroutine where it was created using a fixed filename. However, when I try to make it general, giving a filename in a dialog box after the image is completed (I haven't cracked menus yet) I get an error code out of saveimage_w. I have tried calling focusqq before saveimage_w but it does not help.
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I doubt that has anything to do with focus; rather, itlooks likean invalid file name.
What do you mean by "giving a filename in a dialog box"? Is it a standard "Save as" dialog box (GetSaveFileName) oryour customdialog? If the former, have in mind that SAVEIMAGE_W expects a "Fortran style" string (padded with blanks) while most APIs return "C style" strings (valid contents terminated with char(0), and the rest is garbage). Does perhaps the following work?:
iLen = INDEX(sFileName, CHAR(0))
IF (iLen.ne.0) sFileName = sFileName(1:iLen-1)
call SaveImage_W(sFileName...
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It worked! Thank you very much. I had not appreciated that the same format would not work for Open, Read, Write etc and for saveimage_w.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It works in OPEN? Actually, it shouldn't (more precisely, there's no guarantee in the Standard that it would, but CVF is certainly allowed to do it). Quick test...
Code:
Program OpenTest character(20):: sFileName integer:: i = 42 sFileName = "foo.txt" open(11, file=sFileName, action="write") write(11,*) i close(11) sFileName = "foo.txt"//char(0)//"garbage" open(11, file=sFileName, action="read", status="old") read(11,*) i write(*,*) i close(11) End Program OpenTest
It does work indeed :-), i.e. it outputs "42"
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I now find I was asking the wrong question. It was pure coincidence that it worked after I put your suggestion in. I have two output files - a character file and a bitmap file. It worked when I saved just the bitmap file.
I have a custom dialog box toask forthe (character) input file name, and another toask for the names ofthe character and bitmap output files. If only one output file is named then it is created or overwritten correctly. If both are named then the character file is created or overwritten correctly. If a bitmap file is already present thenit is deleted (I found I could not write a new version without first deleting the old one) before calling the saveimage_w function. SaveImage_w returns an error code (-1), and the bitmap file is empty. If the character output file is not requested, SaveImage_w returns an error code of zero and the bitmap file is written correctly.
This is my first-ever Visual Fortran program, and it is based on bits from various sample programs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
All the Windows-y stuff in my program is lifted from various sample programs.I don't know how much is essential and how much is just window-dressing, so I started removing stuff a bit at a time and re-running. I tried taking out the call to subroutine padstrfor, which came with the code I took from the mmplayer sample, and suddenlythewhole thingworked properly - but only if I also removed the code you gave me last week. This looked to me to be pretty harmless, so I was very surprised to find that it made a difference. I had wondered all along whether padstrfor was essential, but had not previously tried removing it to see what happened.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page