- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all
I have an about box in a QuickWin app, compiled for x64 and I'm having some trouble getting some escape sequences to be respected. The following code generates the following about box. I've tried single quotes, double quotes, ''C or CHAR(0) to terminate the string with no change in result. The presence of "Use IFQWIN " has no impact. Any thoughts?
TIA - Ted
STRING1 = 'Regular Build\n' STRING2 = 'Mixed Aquifer pH used for isotherm selection\n' STRING3='Report Surface Water Body Results as Mass Fluxes' ii = ABOUTBOXQQ('EPAs Composite Model for Leachate '// > 'Migration with Transformation Products\n'// > 'EPACMTP Version '//getVerStr()//'\n'// > 'Build Notes:\n'// > trim(STRING1)//trim(STRING2)//trim(STRING3)//CHAR(0))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try using CHAR(10) instead of the embedded '\n' sequence, e.g.
STRING1 = "Regular Build" // CHAR(10)
Position 10 in the character set used by Intel Fortran (which is some sort of ascii extension - you could use ACHAR instead of CHAR) is the newline character.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try using CHAR(10) instead of the embedded '\n' sequence, e.g.
STRING1 = "Regular Build" // CHAR(10)
Position 10 in the character set used by Intel Fortran (which is some sort of ascii extension - you could use ACHAR instead of CHAR) is the newline character.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
IanH - Thanks. That did the trick:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
C-style escape sequences work only in C strings. Try this:
STRING1 = 'Regular Build\n' STRING2 = 'Mixed Aquifer pH used for isotherm selection\n' STRING3='Report Surface Water Body Results as Mass Fluxes' ii = ABOUTBOXQQ('EPAs Composite Model for Leachate '// > 'Migration with Transformation Products\n'C// > 'EPACMTP Version '//getVerStr()//'\n'C// > 'Build Notes:\n'C// > trim(STRING1)//trim(STRING2)//trim(STRING3)//CHAR(0))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
STRING1 = 'Regular Build\n'c STRING2 = 'Mixed Aquifer pH used for isotherm selection\n'c
Al strings with escaped characters must be C strings.
How does Fortran manage concatenation of C strings?
In my sens string1//string2 will lead to a char(0) in the middle of the resulting string. Am I wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>How does Fortran manage concatenation of C strings?
Likely by writing a function that locates the NULL in the left string (or used entire string in the event of lack of NULL).
It is Fortran, it knows not of C strings (other than for literal constant). You get the null.
character(len=128) :: text
text = "Howdy\n"C
Has a newline and NULL at positions 6 and 7, followed by 121 spaces.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
jimdempseyatthecove wrote:
>>How does Fortran manage concatenation of C strings?
Likely by writing a function that locates the NULL in the left string (or used entire string in the event of lack of NULL)
Nope - the only recognition of C-string as a concept (and this is an extension, not a standard feature), is in literal constants. Nothing else, including concatenation, knows that such a thing exists. Once you have a variable with an embedded NUL, that is just another byte of data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried both Steve's and Gilles' suggestions but the result was less satisfying:
IanH's suggestion worked:
STRING1 = 'Regular Build'//CHAR(10) STRING2 = 'Mixed Aquifer pH used for isotherm selection'//CHAR(10) STRING3='Report Surface Water Body Results as Mass Fluxes' ii = ABOUTBOXQQ('EPAs Composite Model for Leachate '// > 'Migration with Transformation Products'//CHAR(10)// > 'EPACMTP Version '//getVerStr()//CHAR(10)// > 'Build Notes:'//CHAR(10)// > trim(STRING1)//trim(STRING2)//trim(STRING3)//CHAR(0))
Result:
While testing I noticed something else. After changing the code and rebuilding for Release x64 I would get a LNK1104 error: cannot open file 'x64\Release\EPACMTPV2_2.exe'. I checked the Task Manager and the process from the previous test was still active. I had started the process with "Start without Debugging" and killed the application with Ctrl-C. After killing the process, the build would complete normally. Any idea why the process would persists after closing the program?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You're right, my suggestion won't work for you for exactly the reason I described in post 7. Sorry about that. The point remains that C escape sequences are recognized only inside C-string literals.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No worries, Steve. Thanks for the response. I did have another question that I hid at the end of my last post. Long story short, when I was testing the Release version of the program, the process seemed to persist after closing the program with Ctrl+C. Any clues as to why that would happen?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Compiler version? I recall a problem like this in QuickWin from last year, but thought it was fixed in 17.0.2 (or maybe earlier).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Parallel Studio XE 2017 Update 2 Composer Edition for Fortran Windows* Integration for Microsoft VS 2015, Version 17.0.0041.14
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, that's current. Perhaps one of the Intel folks can check on the status of the QuickWin process persistence bug.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
! strcat.f90 module string_lib contains function my_strcat(a, b) implicit none character(:), allocatable :: my_strcat character(LEN=*), intent(in) :: a, b integer a_end, b_end a_end = INDEX(a,CHAR(0)) if(a_end == 0) then a_end = LEN(a) else a_end = a_end-1 endif b_end = INDEX(b,CHAR(0)) if(b_end == 0) then b_end = LEN(b) else b_end = b_end-1 endif my_strcat = a(1:a_end)//b(1:b_end)//CHAR(0) end function my_strcat end module string_lib program strcat use string_lib implicit none character(:), allocatable :: fee character(:), allocatable :: foo character(:), allocatable :: text fee = "fee"//CHAR(0)//"junk" foo = "foo"//CHAR(0)//"junkToo" text = my_strcat(fee,foo) print *, text, len(text) end program strcat
Jim Dempsey
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page