- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In an application I use Internet Explorer to open and display a HTML files.
The program line below used to work well, both with QVF and with Intel VF version 10.026
iret = WinExec('C:\Program Files\Internet Explorer\iexplore.exe ' //trim(WORKDIR)//'HTM4621\UMTVA462A.HTML'C,SW_MAXIMIZE)
When compiling with IVF 2013 I get the following warning:
Compiling with Intel(R) Visual Fortran Compiler XE 14.0.1.139 [IA-32]...
Instructions.f90
C:\IV-Fortran\TVA51-2C -April2014\TVA51-single-clas-2014-2C\Instructions.f90(15): warning #5275: The backslash character and following character is not a valid escape sequence
When I run the program, the IE starts, but it does not display the HTML file.
How can this problem be fixed?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think that the compiler doesn't like the C-string that you append, since it contains a backslash which, in a C-string, the compiler expects to signal the start of a two-character escape sequence from a limited list of such sequences, such as \r (carrage return), \a (bell), \\ (backslash) and so on. \U is not on the list of acceptable escape sequences. So if you want a backslash in a C-string, just double it up:
'HTM4621\\UMTVA462A.HTML'C
or just remove the C-string flag 'C' and append CHAR (0) instead:
'HTM4621\UMTVA462A.HTML'//CHAR(0)
The absence of the 'C terminating character prevents the compiler interpreting the backslashes in the string
as the start of a two-character escape sequence, thus removing the problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please use ShellExecute for this purpose. It will use the users default browser and doesn't rely on a specific path to the browser (which can change.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you both for advising me,
Anthony, it works fine when removing the C-flag.
Steve, Do I find something in the sample folders about the Fortan calling convention when using Shellexecute ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
reidar wrote:
Thank you both for advising me,
Anthony, it works fine when removing the C-flag.
Steve, Do I find something in the sample folders about the Fortan calling convention when using 1880.94 ?
#3 has a link with an example attached.
The API doc is at http://msdn.microsoft.com/en-gb/library/windows/desktop/bb762153(v=vs.85).aspx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
reidar wrote:
Anthony, it works fine when removing the C-flag.
Be careful doing that, as you end with a string which is not terminated by a null character and such a string will normally fail in its use if
it is sent to a Windows API function which expects null-terminated character strings. Unless you are sure you will not need it, add the CHAR(0) in order to make the string a C-string.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes of course, I replaced the C-flag with CHAR(0)...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Just another question about use of the C-flag: in most Windows procedures and calls like the example below,
should the C be replaced with char(0) as well?
rgs, Reidar
Example of
hInfo = SetHandle (lParam)
if (hInfo .NE. 0 ) then
pInfo = LocalLock(hInfo)
if (pInfo == NULL) then
iret = MessageBox(ghwndMain, "Failed in LocalLock"C, "Error"C, MB_OK)
end if
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
MesageBox expects null-terminated character strings, so the expression is fine. So long as there is not a forward-slash character inside the string between quotes there is no problem. If a forward slash is included, then the compiler will try to interpret that and the next character as a two character escape sequence and store an interpretation of the escape sequence along with the other characters in the string. If it fails to recognise the two-character string as a valid escape sequence, compilation will fail. If you actually want a forward slash to be interpreted by the compiler and stored in the string, you must double it up e.g.
"c://this is my folder path"C ! In this case the escape sequence is "//" and it is valid and is interpreted as a single forward slash because of the terminating C
Only if you define and save strings in character variables such as
mymessage="Failed in LocalLock"
boxtitle="Error in folder c:/my folder path" ! note that no interpretation of this forward slash occurs because there is no terminating C
iret = MessageBox(ghwndMain, mymessage//char(0), boxtitle//char(0), MB_OK)
and then use them in a function that expects null-terminated character strings must you add the terminating char(0) explicitly, as in that case the compiler is not permitted to modify what you have programmed under the assumption that what you might want is a null-terminated string.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I did some tests with ShellExecute to call a browser. The sample console program (with slight modifications) worked as expected. To expand the sample for my needs I would like to stop the Browser from the Fortran program. What is the recommeded way to do this? Grab the handle and kill the browser window? Or is something better available, hidden in the vaults of Window (7)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You would have to use ShellExecuteEx and get the hProcess field from the SHELLEXECUTEINFO structure. Then call TerminateProcess to ask it to exit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Steve, I will try your suggestion when I have collected the necessary information on ShellExecuteEx and TerminateProcess. I would like to inform you that your image is scrambled (I see only text with your name), since I installed Firefox 32.0 this morning. The images of others seem to be ok, including mine's.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I too cannot see Steve's image, although I can see others (e.g. rase and app4619).
I am using IE 10
Les
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, I know about my picture. It has come and gone over the last few months. I wonder if they're trying to tell me something. I'm working this with the forum developers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For ShellExecuteEx, you get the created process handle in SI%hProcess, where SI must be defined as a SHELLEXECUTEINFO structure.
For CreateProcess, you get the created process handle in PI%hProcess, where PI must be defined as a PROCESS_INFORMATION structure that is populated by CreateProcess. These structures are defined in the IFWINTY module.
Then use TerminateProcess(hProcess, exitcode) to terminate the process when required.

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