tinyfiledialogs is a cross-platform C library that provides modal dialogs and file dialogs. I’ve recently completed the interface module to call this code from Fortran.
! calling function tinyfd_inputbox
write(*,'(A)') "Enter tinyfd_inputbox()"
aTitle = "a Title" // char(0)
aMessage = "a Message" // char(0)
aDefaultInput = "an Input" // char(0)
cpointer = tinyfd_inputBox(aTitle, aMessage, c_loc(aDefaultInput) )
! or for a password box: cpointer = tinyfd_inputbox(atitle, amessage, c_null_ptr )
if ( c_associated(cpointer) ) then
! Convert C Pointer to Fortran pointer
call c_f_pointer(cpointer, fpointer)
! Remove NULL character at the end
string = fpointer(1:index(fpointer,c_null_char)-1)
write (*,'(A)') string
endif
tinyfiledialogs in Fortran handles char strings as UTF-8 (on windows and on unix).