Changes between Initial Version and Version 1 of helloworld


Ignore:
Timestamp:
Sep 26, 2006, 5:04:32 PM (18 years ago)
Author:
shai
Comment:

"Hello world" tutorial

Legend:

Unmodified
Added
Removed
Modified
  • helloworld

    v1 v1  
     1= "Hello world" in FORTRAN/TK =
     2== A short tutorial ==
     3
     4This is a very very short tutorial about "Hello world" in FORTRAN/TK, to demonstrate how easy it is to write a GUI program with FORTRAN/TK.
     5
     6We need to include the "fortrantk.fap" for global pragmas and the "fortrantk.fi" for local function definitions and constants in the main program unit.[[BR]]
     7Then we need to initialize FORTRAN/TK. This is done with the !TkInit command which takes the path of the runtime DLLs as argument and returns NULL if no error occured and a positive value if one occured. We stop with an error message (on the console) if this happens. We assume that the libraries are installed on the system or are in the same directory as the program.[[BR]]
     8Then we 'withdraw' the main window (which would be otherwise still visible) from the screen by issuing the !TkWm command with 'withdraw' as an argument.[[BR]]
     9After this, we just call the !TkMessageBox function to display our important message. We don't need an event loop because we will just return after the call. Refer to your [http://www.tcl.tk/man/tcl8.0/ Tcl/Tk manual] for further information about the [http://www.tcl.tk/man/tcl8.0/TkCmd/messageBox.htm tk_messageBox] function.[[BR]]
     10At the end, we need to unload FORTRAN/TK by calling the !TkUnload function. We output an error message again if TkUnload returns a positive value.[[BR]]
     11This is a listing of this simple program:
     12
     13{{{
     14c$include fortrantk.fap
     15
     16      include 'fortrantk.fi'
     17
     18      if(TkInit('.'c))
     19     & stop 'FORTRAN/TK couldn''t get initialized!'
     20
     21      call TkWm('withdraw'c, '.'//dn)
     22      call TkMessageBox('-message'c, 'Hello world'c,
     23     &                  '-title'c,   'Test Application'c,
     24     &                  '-icon'c,    'info'//dn)
     25
     26      if(TkUnload())
     27     & write(*,*) 'FORTRAN/TK couldn''t get unloaded!'
     28      end
     29}}}
     30
     31You can download this file from [ftp://pub.netlabs.org/pub/fortrantk/misc/hello.for here].
     32
     33This code can be compiled by using the Open Watcom FORTRAN 77 Compile and Link Utility. Of course you have to initialize the necessary Open Watcom environmental variables and add the FORTRAN/TK path to the FINCLUDE variable first, eg. if your Watcom directory is "C:\PRG\WATCOM" and your FORTRAN/TK path is "C:\PRG\FORTRANTK" by issuing:[[BR]]
     34for OS/2:
     35
     36{{{
     37 C:\PRG\WATCOM\SETVARS.CMD
     38}}}
     39
     40or for Windows:
     41
     42{{{
     43 C:\PRG\WATCOM\SETVARS.BAT
     44}}}
     45
     46and finally
     47
     48{{{
     49 set FINCLUDE=%FINCLUDE%;C:\PRG\FORTRANTK
     50}}}
     51
     52on the commandline.[[BR]]
     53Assuming that you called your file "HELLO.FOR" and your FORTRAN/TK library is in the current directory you would have to enter:[[BR]]
     54for OS/2:
     55
     56{{{
     57 wfl386 hello.for fortrantk.lib -FE=hello.exe -BM -DEF=__OS2__ -L=OS2V2
     58}}}
     59
     60or for Windows:
     61
     62{{{
     63 wfl386 hello.for fortrantk.lib -FE=hello.exe -BM -DEF=__WIN__ -L=NT
     64}}}
     65
     66That's it - now you can run "HELLO.EXE" on your preferred system, but don't forget to put the Rexx/Tk and Tcl/Tk libraries in the current directory unless you defined another directory containing the libs using !TkInit. It's now compiled as a console program, so it features a console window.[[BR]]
     67Here's a screenshot of the "Hello world" program running under Windows XP:
     68
     69{{{
     70#!html
     71<center>
     72}}}
     73[[Image(helloworld.jpg)]]
     74{{{
     75#!html
     76</center>
     77}}}