To demonstrate the usage of VFC GUI Generator interface for some numerical problem, I slightly modified the project #10 from "5. Default projects ( templates ) included into GUI Generator package" and, using the instructions from "6. Using generated FORTRAN codes and files with Compaq Visual Fortran 6.x.", I started with new application design.
Step 1. I created new program block - module ( User_Module.f90 ) for my own variables used in numerical algorithm:
module
user_parameters real*8 A,B end module user_parameters |
Step 2. I modified VFC_User_On_Init.f90 to set up the initial value for my variable (A):
!--------------------------------------------------------------------------------------- subroutine VFC_User_OnInit(hInstance,ireturn) !------------------------------- ! here we insert our module !------------------------------- use user_parameters !------------------------------- integer*4 hInstance,ireturn !------------------------------------------------------------------ ! ! Purpose : It allows user to perform some preliminary operations ! ( open file(s) with initial data, read data etc. ) ! ! Parameters : hInstance - handle of application ! ireturn - error code ! = 0 - no error(s) ! = 1 - error(s) appeared ! !------------------------------------------------------------------ ireturn = 0 !------------------------------------------------ ! Put your code below, please !------------------------------------------------ ! now we set value for variable from module A = 3.14159265358979 return end |
Step 3. I modified the VFC_ButtonDefinedAction.f90:
subroutine
ButtonDefinedAction(WndNumber,ButtonNumber,ButtonHandle) ! here we insert our module !------------------------------- use user_parameters !------------------------------- integer*4 WndNumber,ButtonNumber,ButtonHandle !------------------------------------------------------------------- ! Purpose - handler for created button(s) ! Parameters: ! WndNumber - current window number ! ButtonNumber - current button number ! ButtonHandle - current button handle !------------------------------------------------------------------- select case(WndNumber) case(1) select case(ButtonNumber) case(1) !-------------------------------------------------------- ! Put here your handler/subroutine for button #1 ! Button capture: ! <<Start>> ! Button description: ! == Push this button to start application... ! == ! == ! !-------------------------------------------------------- !================================ ! Calculate B = sin(A) B = DSIN(A) !====================================== ! Now we display input and output data call WriteDRealToVFCStaticAsFormatted(1,2,A,"(d12.5)") call WriteDRealToVFCStaticAsFormatted(1,4,B,"(d12.5)") case(4) !-------------------------------------------------------- ! Put here your handler/subroutine for button #4 ! Button capture: ! <<Exit>> ! Button description: ! == Push to exit application... ! == ! == ! ! Remember, please, that this button will close ! application. But you can't do this manualy !-------------------------------------------------------- end select end select return end !=================================================================== ! Also you have static control(s) in your program. ! !------------------------------------------------ ! Window #1 Static #1 ! Static control capture: ! <<Value of A =>> ! Static control description: ! == Parameter A ! == ! == ! ! You can use the next functions for control management : ! call SetVFCStaticCaption(1,1,text_string) ! call ClearVFCStaticCaption(1,1) ! call WriteRealToVFCStaticAsFormatted(1,1,value,fmt_string) ! call WriteRealToVFCStaticUnFormatted(1,1,value) ! call WriteDRealToVFCStaticAsFormatted(1,1,value,fmt_string) ! call WriteDRealToVFCStaticUnFormatted(1,1,value) ! call WriteIntegerToVFCStaticAsFormatted(1,1,value,fmt_string) ! call WriteIntegerToVFCStaticUnFormatted(1,1,value) !------------------------------------------------ ! Window #1 Static #2 ! Static control capture: ! <<>> ! Static control description: ! == Parameter A Value ! == ! == ! ! You can use the next functions for control management : ! call SetVFCStaticCaption(1,2,text_string) ! call ClearVFCStaticCaption(1,2) ! call WriteRealToVFCStaticAsFormatted(1,2,value,fmt_string) ! call WriteRealToVFCStaticUnFormatted(1,2,value) ! call WriteDRealToVFCStaticAsFormatted(1,2,value,fmt_string) ! call WriteDRealToVFCStaticUnFormatted(1,2,value) ! call WriteIntegerToVFCStaticAsFormatted(1,2,value,fmt_string) ! call WriteIntegerToVFCStaticUnFormatted(1,2,value) !------------------------------------------------ ! Window #1 Static #3 ! Static control capture: ! <<Value of B =>> ! Static control description: ! == Parameter B ! == ! == ! ! You can use the next functions for control management : ! call SetVFCStaticCaption(1,3,text_string) ! call ClearVFCStaticCaption(1,3) ! call WriteRealToVFCStaticAsFormatted(1,3,value,fmt_string) ! call WriteRealToVFCStaticUnFormatted(1,3,value) ! call WriteDRealToVFCStaticAsFormatted(1,3,value,fmt_string) ! call WriteDRealToVFCStaticUnFormatted(1,3,value) ! call WriteIntegerToVFCStaticAsFormatted(1,3,value,fmt_string) ! call WriteIntegerToVFCStaticUnFormatted(1,3,value) !------------------------------------------------ ! Window #1 Static #4 ! Static control capture: ! <<>> ! Static control description: ! == Parameter B Value ! == ! == ! ! You can use the next functions for control management : ! call SetVFCStaticCaption(1,4,text_string) ! call ClearVFCStaticCaption(1,4) ! call WriteRealToVFCStaticAsFormatted(1,4,value,fmt_string) ! call WriteRealToVFCStaticUnFormatted(1,4,value) ! call WriteDRealToVFCStaticAsFormatted(1,4,value,fmt_string) ! call WriteDRealToVFCStaticUnFormatted(1,4,value) ! call WriteIntegerToVFCStaticAsFormatted(1,4,value,fmt_string) ! call WriteIntegerToVFCStaticUnFormatted(1,4,value) ! !=================================================================== |
Here you can see, that first "block":
B = DSIN(A)
is the realization of our "numerical problem".
Strings
call
WriteDRealToVFCStaticAsFormatted(1,2,A,"(d12.5)")
call WriteDRealToVFCStaticAsFormatted(1,4,B,"(d12.5)")
were inserted with respect to recommendations for work with "passive controls".
Subroutine VFC_User_On_Exit.f90 remains without changes - I need no to free any resources...
Below you could
see the output screen of the created application...