Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner

AboutboxQQ and C-Style Escape Sequences

Jump to solution

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))

4-24-2017 5-38-36 PM.jpg

0 Kudos

Accepted Solutions
Highlighted
Black Belt

Try using CHAR(10) instead of

Jump to solution

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.

View solution in original post

0 Kudos
13 Replies
Highlighted
Black Belt
1 View

Try using CHAR(10) instead of

Jump to solution

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.

View solution in original post

0 Kudos
Highlighted
Beginner

IanH - Thanks.  That did the

Jump to solution

IanH - Thanks.  That did the trick:

4-24-2017 6-54-34 PM.jpg

0 Kudos
Highlighted
Black Belt

C-style escape sequences work

Jump to solution

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))

 

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
New Contributor II

STRING1 = 'Regular Build\n'c

Jump to solution
       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?

0 Kudos
Highlighted

>>How does Fortran manage

Jump to solution

>>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

0 Kudos
Highlighted
Black Belt

Quote:jimdempseyatthecove

Jump to solution

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.

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
Beginner

I tried both Steve's and

Jump to solution

I tried both Steve's and Gilles' suggestions but the result was less satisfying:

4-25-2017 8-48-57 AM.jpg

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:

4-25-2017 8-57-59 AM.jpg

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?

0 Kudos
Highlighted
Black Belt

You're right, my suggestion

Jump to solution

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.

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
Beginner

No worries, Steve. Thanks for

Jump to solution

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?

 

0 Kudos
Highlighted
Black Belt

Compiler version? I recall a

Jump to solution

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).

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
Beginner

Parallel Studio XE 2017

Jump to solution

Parallel Studio XE 2017 Update 2 Composer Edition for Fortran Windows* Integration for Microsoft VS 2015, Version 17.0.0041.14

0 Kudos
Highlighted
Black Belt

Ok, that's current. Perhaps

Jump to solution

Ok, that's current. Perhaps one of the Intel folks can check on the status of the QuickWin process persistence bug.

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted

!  strcat.f90

Jump to solution
!  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

0 Kudos