Topic: dlgrequesttext problem

dlgrequesttext does not output user text input in the following subroutine. Is it me (most likely) or a bug?

subroutine get_text(prompt, text)
use appgraphics

implicit none

integer i2
character :: prompt*(*), text*(*), title*5
logical ok

title = 'title'
ok = dlgrequesttext (text, title, prompt)
i2 = len(text)
! text = '4'
end subroutine get_text

Re: dlgrequesttext problem

I just tested your subroutine, and it seems to work fine.  Here's my working code:

program main
use appgraphics
implicit none

    integer::myscreen
    character(100)::txt
    
    myscreen = initwindow(800, 600, closeflag=.TRUE.)
    
    txt = ' '
    call get_text("Please Provide Text", txt)
    
    call dlgmessage(DIALOG_INFO, txt)
    
    call loop()
    
    call closewindow(myscreen)

contains

    subroutine get_text(prompt, text)
    use appgraphics

    implicit none

        integer i2
        character :: prompt*(*), text*(*), title*5
        logical ok

        title = 'title'
        ok = dlgrequesttext (text, title, prompt)
        i2 = len(text)
        ! text = '4'
    end subroutine get_text

end program main

What exactly do you mean that it "does not output user text input" in your message?

Jeff Armstrong
Approximatrix, LLC

Re: dlgrequesttext problem

The subroutine get_text properly displays a dialog with the correct input text and prompt to the user but the text typed in by the user does not change the input text in the message box as I understand the documentation to say. As you can see I hardcoded a text ('4') for now.

Re: dlgrequesttext problem

I'm not sure exactly what you're saying here.  In my code, when I call your routine get_text, a text box pops up, and the user enters text.  If the user clicks "Ok," that text is copied into the variable text in the subroutine get_text as expected.  My program simply displays the contents of the variable text after this operation, which appears to be correct.

Are you seeing something different if you run the code I provided as-is?

Jeff Armstrong
Approximatrix, LLC

Re: dlgrequesttext problem

I expected the same result as your code. My caller to the get_text subroutine calls it almost exactly as your main. Except that you declared the variable txt to be length 100 in your main whereas I declared my the equivalent variable in my caller to be length to be length 2. I expected it to be no longer than that because it represents only 1-digit number.

When I ran your code as is, I got expected results. But when I changed your declaration to txt(2) I got the same problem as my version. On the other hand when I changed my variable to be at least length 3 in my code, I got expected results. I can't find anything in the documentation of dlgrequesttext that says the string length should be at least 3. Also nothing in my Fortran manual that says so.

By the  way, is there a way to bold or italicize texts in composing this message?

Thanks!

Re: dlgrequesttext problem

I would try to make the text longer.  Because AppGraphics is interacting with Windows API calls, all strings will have a null character appended to them whether setting or retrieving.  We strip away this null character when passing back results, but it does take up memory (one of your two character spaces).  You probably need to make it a longer string variable.

You can look at the BBCode guide on how to italicize or bold text in your posts.

Jeff Armstrong
Approximatrix, LLC

Re: dlgrequesttext problem

Thank you Jeff. I suspected there were "hidden" extra characters that were throwing things off. I had solved the problem using the same idea that you suggested.