Program MRF_FOR !+ ! Copyright (c) 1994 - 1996 by ! Digital Equipment Corporation, Maynard, MA ! ! This software is furnished under a license and may be used and copied ! only in accordance with the terms of such license and with the ! inclusion of the above copyright notice. This software or any other ! copies thereof may not be provided or otherwise made available to any ! other person. No title to and ownership of the software is hereby ! transferred. ! ! The information in this software is subject to change without notice ! and should not be construed as a commitment by Digital Equipment ! Corporation. ! ! Digital(TM) assumes no responsibility for the use or reliability of its ! software on equipment which is not supplied by Digital. ! ! Digital is a trademark of Digital Equipment Corporation. ! !======== OpenVMS(TM) - Character-Cell and DECwindows Instructions ============== ! ! If your system manager copied the Mileage Reimbursement Application from ! the DECforms kit onto your system, you can run the application by doing ! the following: ! ! To run the character-cell version of the application: ! ! $ run forms$examples:forms$demo_mrf ! ! To run the DECwindows (Motif) version of the application: ! ! $ set display/create/node=your-node-name ! $ define forms$default_device decw$display ! $ run forms$examples:forms$demo_mrf ! ! Any printing you do while running the application will end up in your ! SYS$SCRATCH directory (usually your login directory). ! ! The Mileage Reimbursement Demonstration Application in the FORTRAN language ! consists of the following files: ! ! forms$demo_mrf_form.ifdl The IFDL source form ! forms$demo_mrf_for.for The application itself ! forms$demo_mrf_def.for An include file ! formsdef.f An include file with DECforms definitions ! ! The first three files are copied from the DECforms kit to the FORMS$EXAMPLES ! directory and the last is put into SYS$LIBRARY. Putting the files in ! FORMS$EXAMPLES is an installation option; talk to your system manager if they ! aren't there. The FORMSDEF.F file is put into SYS$LIBRARY unconditionally, so ! that you should be able to use it from all your FORTRAN programs using ! DECforms. ! ! To create a working version of the Mileage Reimbursement Application in ! the FORTRAN language in your own directory, follow these steps: ! ! 1. Set the default to your own directory: ! ! $ set default your-directory ! ! 2. Copy all the source files from FORMS$EXAMPLES to your own directory: ! ! $ copy forms$examples:forms$demo_mrf_form.ifdl, - ! forms$demo_mrf_for.for, - ! forms$demo_mrf_def.for [] ! ! 3. Translate the IFDL form file with the following command: ! ! $ forms translate forms$demo_mrf_form.ifdl ! ! This creates a binary form file named forms$demo_mrf_form.form. ! ! 4. Create the form object file with the following command: ! ! $ forms extract object /portable_api /form_load forms$demo_mrf_form.form ! ! This creates a forms object file named forms$demo_mrf_form.obj. ! ! 5. Compile the program with the following command: ! ! $ fortran forms$demo_mrf_for.for ! ! This creates an object file named forms$demo_mrf_c.obj. ! ! 6. Create a file named mrf_opt.opt that contains the following line: ! ! SYS$LIBRARY:FORMS$PORTABLE_API.EXE/SHARE ! ! This file tells the linker to link in the shareable image that ! contains the portable API entry points to the Form Manager. ! ! ! 7. Link the FORTRAN program with the following command: ! ! $ link forms$demo_mrf_for, forms$demo_mrf_form, mrf_opt/opt ! ! 8. To prepare to run this application on character-cell devices, define ! the logical FORMS$DEFAULT_DEVICE with the following command: ! ! $ define forms$default_device sys$input: ! ! 9. To prepare to run this application on DECwindows, define ! the logical FORMS$DEFAULT_DEVICE with the following command: ! ! $ define forms$default_device decw$display: ! ! 10. To create a trace file that will describe each action taken ! during the course of the application session, define the logical ! FORMS$TRACE with the following command: ! ! $ define forms$trace t ! ! 11. To the application, enter the following command: ! ! $ run forms$demo_mrf_for ! ! If you turned on the trace file, running the application will ! produce a log file named forms$demo_mrf_form.trace. ! !============================================================================ !- Implicit None Include 'Sys$Library:formsdef.f' Include 'forms$demo_Mrf_Def' ! ! Variables ! Record /trip_struct/ trips_record(TRIPRECORD) Record /header_info_struct/ header_info_record Record /totals_struct/ totals_record Record/Forms_Record_Data/header_info_record_descr Record/Forms_Record_Data/trips_record_descr Record/Forms_Record_Data/totals_record_descr Record/Forms_Request_Options/request_options(2) Integer MRF_FORM External MRF_FORM Character*16 session_id Character*16 print_session Integer status ! ! Request options for linked-in form ! request_options(1).option = forms_c_opt_form request_options(1).form_object = %loc (MRF_FORM) request_options(2).option = forms_c_opt_end ! ! Structure must contain the length and address of the record being sent ! or received from DECforms; shadow records are optionally used to track ! changes to fields in a data record - here they are set to 0 ! header_info_record_descr.data_length=sizeof(header_info_record) header_info_record_descr.data_record = %loc(header_info_record) header_info_record_descr.shadow_record = 0 header_info_record_descr.shadow_length = 0 trips_record_descr.data_length = sizeof(trips_record) trips_record_descr.data_record = %loc (trips_record) trips_record_descr.shadow_record = 0 trips_record_descr.shadow_length = 0 totals_record_descr.data_length = sizeof(totals_record) totals_record_descr.data_record = %loc (totals_record) totals_record_descr.shadow_record = 0 totals_record_descr.shadow_length = 0 ! ! Enable the form -- the ENABLE request expects 5 parameters; in FORTRAN ! requests, all expected parameters must be specified by passing a ! variable, a value, or a placeholder; session id returned by DECforms ! is used in all subsequent calls to the form and device ! status = forms_enable_for( 1 session_id, 2 , ! current device 3 , ! name of form file 4 'MRF_FORM', ! form name 5 request_options) ! ! Obtain the header information ! status = forms_receive_for( 1 session_id, 2 'header_info_record', !form record 3 header_info_record_descr, !program record 4 ) ! no request options ! ! Obtain information on all trips ! status = forms_receive_for( 1 session_id, 2 'trips_record', 3 trips_record_descr, 4 ) ! ! Obtain totals for all trips (to send to print session) ! status = forms_receive_for( 1 session_id, 2 'totals_record', 3 totals_record_descr, 4 ) ! ! Enable second session for print file ! status = forms_enable_for ( 1 print_session, 2 'prin_mrf.doc', 3 , 4 'MRF_FORM', 5 request_options) ! ! Send data from program to form for print file ! status = forms_send_for ( 1 print_session, 2 'header_info_record', 3 header_info_record_descr, 4 ) status = forms_send_for ( 1 print_session, 2 'trips_record', 3 trips_record_descr, 4 ) status = forms_send_for ( 1 print_session, 2 'totals_record', 3 totals_record_descr, 4 ) ! ! Disable the form ! status = forms_disable_for ( 1 print_session, ) status = forms_disable_for( 1 session_id,) End !+ ! Routine: Update_Row ! ! Functional Description: ! ! Updates the information in the row of a trip record. The mileage ! reimbursement amount is calculated from the number of miles travelled ! (using 22½¢ per mile) ! ! Formal Parameters: ! ! trip-record - the trip record ! !- Subroutine Update_Row (trip) Include 'sys$library:formsdef.f' Include 'forms$demo_Mrf_Def' Record /trip_struct/ trip trip.amount = Int((trip.miles * 22.5)+0.5) Return End !+ ! Routine: Do_Totals ! ! Functional Description: ! ! Computes and updates the totals given the entire collection of trip ! records. ! ! Formal Parameters: ! ! trips-record ! total-miles ! total-amount ! total-tolls ! form-total !- Subroutine Do_Totals (trips, miles, amount, tolls, total) Include 'sys$library:formsdef.f' Include 'forms$demo_Mrf_Def' Record /trip_struct/ trips(TRIPRECORD) Integer miles, amount, tolls, total, n ! ! Initialize counters to zero ! miles = 0 amount = 0 tolls = 0 total = 0 ! ! For each entry with a nonzero mileage, accumulate the trips values into ! the counters. ! Do n = 1,TRIPRECORD If (trips(n).miles .ne. 0) Then miles = miles + trips(n).miles amount = amount + trips(n).amount tolls = tolls + trips(n).toll total = total + trips(n).subtotal End If End Do Return End