TweetFollow Us on Twitter

FaceIt Fortran
Volume Number:5
Issue Number:9
Column Tag:Fortran's World

FaceIt Saves Fortran

By Mark McBride, Oxford, CA

Porting Number Crunching Routines

When the first Fortran articles appeared in MacTutor the goal was to discuss porting Fortran applications to the Mac. The articles I have written evolved into a discussion of programming the Mac interface using MacFortran. Porting Fortran programs really meant running the program in its sequential, non-Mac, form unless you were willing to invest substantial time re-writing the user front-end to your code. The advent of MPW based Fortran’s (Language Systems is shipping and Absoft is reportedly working on a MPW Fortran compiler) means we may eventually get MacApp support. But even MacApp support would mean writing your own event loop and window environment.

Enter FaceIt. FaceIt has been discussed previously in MacTutor. Chuck Bouldin reviews the basics of FaceIt (formerly known as MacFace) in the July 1987 issue. FaceIt’s author, Dan Kampmeier wrote a letter to the editor in which he presents where FaceIt can be beneficial. While earlier versions of FaceIt made adding a Mac interface easier for text windows and plotting graphs, most of my work as an economist involves heavy number crunching routines. The basic structure of the Fortran program sets up the data and parameters to be used, passes the array to a subroutine to calculate, and then writes out the results.

Version 3.3 of FaceIt adds a feature, sheets, which dramatically increases its value in porting number crunching Fortran programs. A sheet in FaceIt is a spreadsheet tagged to any numeric array you choose. The user can enter and edit the numeric values in the array with spreadsheet ease. The program can have as many as four sheets open at once. Sheets will be explained below.

Figure 1. A Sheet

At the same time that FaceIt was adding sheets, Absoft technical support released a subroutine which allows dynamic array allocation (phone 904 423-7587 to get a copy). Provision of a method of dynamically allocating arrays means that the toolbox memory manager can be used to allocate a block of memory for the array, with the size of the array depending on available memory. When the program needs a new array of different dimensions, the old array can be de-allocated, thus recapturing its space for use with the new array.

Given that using FaceIt is resource intensive, I have tried to structure the article into the main issues confronted with porting an existing number crunching program to a Mac interface. The example program (Listing One) is a general data editor program with a subroutine for calculating the means of the selected observations (rows) of the selected variables (columns). The user is given the opportunity to analyze (via a dialog) a set of variables and observations other than the current selection in the sheet window. The source code given can be used with very little modification to move your number crunching subroutine into a Mac interface. The structure for creating, opening, and saving real*8 arrays is provided. Just define the appropriate arrays and add your favorite cruncher.

Data Editor

Dynamic Arrays

Absoft has released an assembly language routine which allows a programmer to allocate memory using the toolbox and then assign an array to the newly allocated memory block. The process is straightforward.

• code a new main program to allocate an array (of any size) and call your original main program as a subroutine. For example:

 PROGRAM shell
 real*8 thearray(1)
 call main(thearray)
 end

• rewrite your main program as a subroutine which accepts an array as an argument. Continuing the example:

 SUBROUTINE main(thearray)
 real*8 thearray(*)
 integer i,toolbx,blkptr
 include memory.inc
 blkptr=toolbx(NEWPTR,1024)
 call dynam(blkptr)
 do (i=1,100)
   myarray(i)=i
 repeat
 call Cruncher(thearray)
 call toolbx(DISPOSEPTR,blkptr)
 return
 end
 SUBROUTINE Cruncher(thearray)
 real*8 thearray(*)
 {do something with the array}
 return
 end

• by allocating a new block of memory with the toolbox routine NEWPTR or NEWHANDLE, as much memory as can be reasonably retrieved can be used. If you use NEWHANDLE, be sure to lock the block in place before calling the dynam subroutine and using the memory space.

• When using dynam, the last argument passed in the subroutine call will be redirected to the allocated memory block. The ‘C’ compile option for detecting array boundary overruns will not be functional and cannot be used when compiling the program.

• To allocate a new array of a different size dispose of the old memory allocation, allocate a new pointer or handle and then just recall dynam. For example:

 Subroutine Main (thearray)
 ....
 blkptr=toolbx(NEWPTR,1024)
 call dynam(blkptr)
 {... use the array ...}
 call toolbx(DISPOSPTR,blkptr)
 blkptr=toolbx(NEWPTR,2048)
 call dynam(blkptr)
 {... use the new array space ...}
 ...

The only other task is to do error checking. Examination of the Data Editor program (Listing One) demonstrates simple error checking.

Event Handling

A Mac interface is programmed essentially as a continuously repeated event loop. When the user indicates an action, then an appropriate response is made. FaceIt simplifies adding the event driven loop by handling all the usual events in a Mac interface: standard menus; text window events; dialogs; text cut, copy, or paste; and sheet window events. The programmer concentrates on handling the program specific menu selections. A simple FaceIt program has the following event loop structure:

 do
   call FaceIt(0,0,0,0,0,0) !give control to user
   select case (MAC) !MAC tells us which menu chosen
     case(‘About’)
     .....{do about action}
     case(‘Means’)
     .....{do means action}
   end select
 repeat

The call FaceIt(0,0,0,0,0,0) turns control over to the FaceIt event loop, which handles events until a user specifies a program specific menu action. Thus the programmer need not be worried about dragging and re-sizing windows, tracking menu actions, handling DA’s, handling text entry in a text edit window, opening or saving text edit windows to disk, or number entry and editing in a spreadsheet window. When the user specifies a program specific menu action, FaceIt returns control to the programmer, passing the menu selection in the global variable MAC. Thus the programmer focuses on handling the program specific actions, not the basic Mac interface actions.

In the Data Editor program, one sheet window and one text edit window has been specified by retaining only wind resources #1001 and #1006 in the program specific copy of the FaceIt resources (more below on FaceIt resources). The FaceIt ‘File’ menu resource has been modified to include a ‘New Sheet’ choice:

The open, save as, and append to actions are provided by FaceIt for the text edit window. However, for the sheet window, we must provide our own open and save routines. The print routine will print the currently active window (either the text window or the sheet window). The only other menu added is the options menu (ID#105) which contains one item:

When selected, the current array assigned to the sheet window is passed to the routine which calculates the means of the selected observations. The results of the calculations are passed back to the text editor window for viewing, printing, and saving. Thus our program must contain code for creating a new array and tagging it to a sheet, opening and saving the sheet (array) to binary disk files, the means routine which operates on an array passed to it, and quitting (to insure the option of saving changes in the current sheet to the disk file).

New Sheet

Allocation of a new sheet in FaceIt using dynamic arrays involves a few simple steps. These steps are followed for creation of a brand new sheet or for opening into a sheet from a saved data file (see Listing One).

• If an existing sheet exists, then call a save routine to save the existing data.

• Call a setup dialog to get the number of rows and columns for the new array. Upon entry to the dialog, use COMPACTMEM to determine available space. Next retrieve the number of rows and columns from the user via a dialog. Finally, check to see if the requested number of data cells can fit in available memory (leaving a buffer for other program use). If the array can be allocated return to the new sheet allocation.

• If the number of cells requested can be allocated, dispose of the existing array in the heap, then call FaceIt’s NEWBLK routine. FaceIt’s routine will provide additional memory error handling protection over and above the toolbox routines (NEWPTR, NEWHANDLE). NEWBLK allocates a new handle in the heap and locks it in place.

• If the new memory is successfully allocated on the heap, call dynam to redirect the array to new memory space.

• Finally, relate the array to the sheet and clean up the sheet display with calls to the FaceIt routines SetSh and FixSh.

Following these steps the program can continually reuse heap space to allocate the array to the size needed whenever the user requests a new sheet or opens into a the sheet from a disk file. Notice allocating the array in heap space means that the program can be used under MultiFinder and will only use space allocated to the program.

Saving

Saving the current array to a binary disk file is a straight forward process. The format of the binary save is nmax, kmax (the number of rows and columns), the kmax titles, and finally the data. The steps are:

• If the user selected ‘save as’ set the current name to null. If the data has not been previously saved (name is null), call FaceIt’s StdSav routine to use the standard save dialog to select the disk file name. FaceIt returns the name the user selected in the variable ‘name’.

• If the user did not click cancel, then open the disk file as unformatted and write the data.

• Reset the sheet title to reflect the current name.

• Set the disk file type flag to ‘DPTE’ which indicates a binary data file created by the Data Editor program.

Opening

Opening an existing binary data file into the the array is much the same process as creating a new sheet. The binary data file must have been created with a save command from the Data Editor program and have a file type of ‘DPTE’. The steps to open are:

• If the user clicks cancel during any of the following steps, drop through the routine, leaving the current array/sheet intact.

• If an existing sheet exists, then call a save routine to save the existing data.

• Call the FaceIt routine StdOpn with a file type of ‘DPTE’ passed via the variable MAC. This will present the user with the standard file package open routine displaying only binary data files created by Data Editor.

• Dispose the existing array in the heap, read in the number of cells in the data file (nmax, kmax), then call FaceIt’s NEWBLK routine.

• If the new memory is successfully allocated on the heap, call dynam to redirect the array to new memory space, then read in the titles and data values.

• Finally, relate the array to the sheet and clean up the sheet display with calls to the FaceIt routines SetSh and FixSh.

Means

The means routine expects an array, the number of rows, and the number of columns. A dialog is called to have the user select the observations and variables on which to perform the analysis. The selection dialog could have been handled prior to the call to the means routine and the selection passed as an argument to the means subroutine. The dialog defaults to the current selection in the sheet window. The means are calculated and then output to the text edit window starting at the current selection point. Given the simple output nature of the means subroutine, I put the FaceIt calls necessary to write to the text edit window in the routine. However, on many occasions, there a substantial number of write statements. In those cases, the write statements can be sent to a temporary disk file and then the disk file opened into the text edit window (all with a few simple FaceIt calls).

Quitting

FaceIt normally handles the quit routine, but the programmer can have FaceIt return control during the quit sequence. The Data Editor program has a small quit routine which asks the user if the current sheet should be saved before quitting (or transferring) and then returns control to FaceIt to complete the quit (or transfer) process.

Resource Basis

Using FaceIt to attach a Mac interface is a resource intensive process. Whenever you start a new program, you copy the FaceIt resource file (called Resources) giving the copy a new name. The initial call to FaceIt expects the name of the resource file to be in the ‘name’ variable. Rezedit can be used to modify and add to the FaceIt resources. The resource file contains window resources for 4 text editors, 4 sheet windows, and 2 graph windows. By removing all the unwanted window resources, FaceIt knows how many windows (and their types) to use when starting. The standard FaceIt menus can be added to (but not removed) for your program specific actions. As shown earlier, Data Editor adds one item to the FaceIt File menu and adds one new menu (options).

One major aspect of using FaceIt is the handling of dialogs. By carefully constructing the dialog in Rezedit, the programmer can let FaceIt handle most of the dialog actions. The programmer only needs to worry about getting info into and out of the dialog. The FaceIt routine to handle dialogs is called Opndlg. The basic steps in using a dialog are:

• Create the dialog in Rezedit, assigning it a proc id of 0 and a resource ID greater than 1005 (Kampmeier may add modeless dialogs in a future release of FaceIt with ID’s 1001-1004).

• In the program code, set the default status of items via the shared array ‘dialog’.

• Set the default values for edit text items via the ‘name’ variable.

• Call the FaceIt routine OpnDlg.

• Read the changes made by the user to text items via the ‘name’ variable.

• Read the status of the items via the array ‘dialog’.

The Data Editor program uses two dialogs: one to get the new array size when the New Sheet menu item is selected, and one to get the observations and variables to number crunch.

New Sheet

The New Sheet dialog contains seven items. The DITL from Rezedit is shown below. The circles indicate the item number and the item type is listed next to the circle. The number in parenthesis indicates the value passed to the FaceIt’s array ‘Dialog’.

Figure 2. Dialog Parameters

Writing the default values for nmax and kmax to the new sheet dialog is easy from Fortran. A write(name,’2i8') nmax,kmax statement will stuff the values of nmax and kmax in the ‘name’ variable with the format I8. Notice that the values specified in the DITL for the editable text items gave the width each item was to take in the ‘name’ variable (in the case at hand, 8 spaces each).

When an enable dialog item has been activated by the user, FaceIt’s OpnDlg routine returns control to the program with the item number activated in array element ‘Dialog(1)’. For the new sheet dialog, I check for a click in the ok or cancel buttons. Actions in the edit text items are handled by FaceIt and the Data Editor program need not taken any additional action. If the ok button is clicked, then a read(name,’2i8')nmax,kmax statement will return the values of nmax and kmax specified by the user. When in operation the dialog appears as follows to the user:

Select Observations

The other custom dialog in the Data Editor program requests from the user which observations (rows) and variables (columns) of the spreadsheet to perform the calculations upon. The select observations dialog contains eight items. The DITL from Rezedit is given below. Again, the circles indicate the item number and the item type is listed next to the circle. The number in parenthesis indicates the value passed to the FaceIt’s array ‘Dialog’.

Notice that this dialog is very similar to the new sheet dialog and operates almost exactly the same manner. The starting and ending observations default values are passed by writing FaceIt’s variable selrect to the ‘name’ variable. The major difference is the inclusion of the user item (#8).

The user item provides space for a selection list. The names of the columns (which are maintained in a STR# resource) are passed by assigning the STR# resource ID to the FaceIt variable listID(1). Each variable (column) which was currently selected by the user has an asterisk append at the beginning to indicate to FaceIt that these variables are currently selected. The selection list will appear with those variables selected. Note that FaceIt does support multiple or single selections in a list, but the multiple selections must be contiguous (non-contiguous selections in a list are not support by the List Manager). After the user has clicked the ok button, the program can determine which items in the list were selected by searching for an asterisk at the start of each column name.

The dialog appears as follows to the user:

A final note about the selection dialog. If the user indicates an ending observation greater than the number of rows than all available observations are used.

Alerts

FaceIt also provides for the handling of alerts. Although alerts can be called easily from most any language, the advantages of using FaceIt are updating of windows behind the alert prior to giving control to the user and delaying the alert when the application is in the background under MultiFinder until the application is switched to the foreground. Examination of the Data Editor source indicates how easily alerts are integrated into a FaceIt program. The alerts used in Data Editor and their DITL lists are:

• About alert (ID # 1009)

• Memory Error Alert (ID # 1005)

• Save or Discard Alert (ID # 1030)

Cleaning Up

The program given in Listing One and the resources picture previously will allow you to get Data Editor up and running. Of course, FaceIt has to be on the disk, in the system file, or attached to the program. The remaining tasks to turn Data Editor into a true Mac application was to provide online help and assign custom icons. FaceIt gives you the ability to do both.

Customizing Help

FaceIt provides a limited ability to customize its help for your application. Given that FaceIt expects the Apple, File, Edit, and Window menus to be as designed, adding help under the Apple menu is not straight forward. In addition, FaceIt’s help under the Apple menu must remain, even though many aspects of it may not be apply to your application (why have graph help when your are not doing graphs). Version 3.3 supports some customization of the FaceIt help. You can re-assign some of the help buttons to your own custom help alerts and you can hide the others from view. I liked the heap space indicator and clipboard display of the FaceIt help alert, but didn’t need the graphing help buttons. Thus, I customized the help alert as shown:

To perform these customizations, the FaceIt alerts must be copied from the FaceIt file to your resource file. FaceIt will check for these resources in the applications resource file before using its own. In the customization, button item # 21 is connect to alert ID # 1102. My custom help alert ID # 1102 appears as:

Attaching Icons

The FaceIt manual provides simple step by step instructions for attaching icons using the BNDL resource. The creator was set to ‘MMDE’ with icons and Frefs set. The custom icons (with the ID #’s) for the Data Editor program are:

The ‘MMDE’ resource was created with the text that displays under the Get Info Finder menu option.

Conclusion

The major element necessary to customize this program for your favorite number crunching routine is the appropriate declaration of arrays and other variables, appropriate menu choices for actions to be undertaken with the arrays, and calls to the number crunching routines. The addition of sheets to FaceIt makes it relatively painless to port you Fortran programs to a Mac user interface and the Data Editor program provides the shell you need to start.

Listing One

***************************************************************
*  Data Editor                                                   
*  © 1988 by Mark E. McBride                                     
*            1205 Dana Drive                                     
*            Oxford, OH  45056                                       
                                                            
*  Developed using Absoft MacFortran/020 and FaceIt.             
*  Program provides a Mac user interface to which number         
*  crunching routines can easily be added.  Takes advantage      
*  of FaceIt’s general event loop, standard Mac environment,     
*  sheet windows.                                                    
                                                            
**************************************************************
      PROGRAM DataEdit
 real*8 pt(1)
 call main(pt)
 end
 
 Subroutine main(pt)
 implicit none
*  Absoft toolbox parameter equates, change path to reflect
*  your disk setup.
 include HD40:Fortran:Include Files:memory.inc
 INTEGER PTR
 PARAMETER (PTR=Z’C0000000')
*  Local variables
 real*8 pt(*)
      integer*4 toolbx,i,j,npt,PtPtr,PtHdl
 integer*4 action,nmax,kmax
 character*256 Head,saveMAC
 logical*1 check
 
*  Include FaceIt declarations
 include HD40:Fortran:FaceIt:StorMF.inc

*load JumpMF !!!REMOVE line if JumpMF is linked to program!!!
*load toolbx  !!!REMOVE line if toolbx is linked to program!!

      name = ‘DEdit.Rsrc’           !temporary resource file
      call FaceIt(1,1,-1,50,1,2)    !initialize FaceIt

*  setup default array information
 data nmax/100/
 data kmax/2/
 
*  set initial sheet to 1x1 array so that open command
*  is available, do not hide sheet
*  sheet window must be active window to get open routine
*  called for the sheet.
 PtPtr=0!pointer to pt array
 PtHdl=0!handle to pt array

* The use of “1” for the first argument of the SetSh1 command
* indicates that we will support “Open”, “Save As”, and “Save”
* for this sheet.
 pt(0)=0
 name=’empty’
 arrayptr(1) = toolbx(PTR,pt)
 call FaceIt(1,SetSh1,1,1,0,-6)
 call FaceIt(0,ShoSh1,RetCtl,0,0,0)
*  Set Means... menu off until an array has been tagged to
*  the sheet.
   call UpdateMenu(menuhdl(5),PtPtr)
   
*  Main loop
      do
        call FaceIt(0,0,0,0,0,0)        !give control to user
   select case (MAC)
     case(‘About’)
       call FaceIt(0,OpnAlt,1009,0,0,0)  !open “About” alert
* points can be loaded from a DEdit data file.  Data format
* consists of nmax, kmax, kmax string titles, the data.
     case(‘Open’)
       Head=’opening sheet’
 action=0
 if (PtPtr<>0) then
   call FaceIt(1,FixSh1,RetCtl,0,0,0)
   call SaveIt(Head,action)
 end if
 if (action=1)
     +      call SaveDa(pt,nmax*kmax,nmax,kmax)
 MAC = ‘DPTE’
 if (action<3) call FaceIt(0,StdOpn,0,0,0,0)
 if ((name<>’Cancel’).and.(action<3)) then
   if (PtPtr<>0)
     +  call toolbx(DISPOSHANDLE,PtHdl)
   open(3,file = name,status = ‘old’,
     +                      form=’unformatted’)
   read(3)nmax,kmax
   I4=nmax*kmax*8
   call FaceIt(0,NewBlk,0,0,0,0)
   if (I4<>0) then
     PtHdl=I4
     PtPtr=long(I4)
     call dynam(PtPtr)
   else
     MAC=’Failed to allocate memory.’
     call FaceIt(0,OpnAlt,1005,0,0,0)
     stop
   end if
   do (i=1,nmax*kmax)
     pt(i)=0
   repeat
   do (i=1,kmax)
     read(3)Head
     MAC=trim(Head)
     call FaceIt(0,SetStr,1001,i,0,0)
   repeat
   read(3)(pt(i),i=1,nmax*kmax)
   close(3)
   arrayptr(1) = toolbx(PTR,pt)
   call FaceIt(1,SetSh1,nmax,kmax,0,-6)
   fixrect(1)=1;fixrect(2)=1;
   fixrect(3)=nmax;fixrect(4)=kmax;
   call FaceIt(1,FixSh1,0,0,0,0)
 end if
* We also support the saving of points back to disk...
     case(‘Save As’,’Save’)
       if (MAC=’Save As’) name=’’
 call SaveDa(pt,nmax*kmax,nmax,kmax)
* Create a new array and tag it to the sheet window
     case(‘New Sheet’)
       Head=’setting new sheet’
 action=0
 if (PtPtr<>0) then
   call FaceIt(1,FixSh1,RetCtl,0,0,0)
   call SaveIt(Head,action)
 end if
 if (action=1)
     +      call SaveDa(pt,nmax*kmax,nmax,kmax)
 check=.false.
 if (action<3) call NewDlg(nmax,kmax,check)
 if ((check).and.(action<3)) then 
         if (PtPtr<>0)
     +            call toolbx(DISPOSHANDLE,PtHdl)
   I4=nmax*kmax*8
   call FaceIt(0,NewBlk,0,0,0,0)
   if (I4<>0) then
     PtHdl=I4
     PtPtr=long(I4)
     call dynam(PtPtr)
   else
     MAC=’Failed to allocate memory.’
     call FaceIt(0,OpnAlt,1005,0,0,0)
     stop
   end if
   do (i=1,nmax*kmax)
     pt(i)=0
   repeat
   name=’’
   do (i=1,kmax)
     I4=i
     call FaceIt(0,I4ToS,0,0,0,0)
     MAC=’X’//trim(MAC)
     call FaceIt(0,SetStr,1001,i,0,0)
   repeat
   arrayptr(1) = toolbx(PTR,pt)
   call FaceIt(1,SetSh1,nmax,kmax,0,-6)
   fixrect(1)=1;fixrect(2)=1;
   fixrect(3)=nmax;fixrect(4)=kmax;
   call FaceIt(1,FixSh1,0,0,0,0)
 end if
     case(‘Quit’,’Transfer’)
       saveMAC=MAC
 if (MAC=’Quit’)Head=’Quitting’
 if (MAC=’Transfer’)Head=’Transferring’
 action=0
 if (PtPtr<>0) then
   call FaceIt(1,FixSh1,RetCtl,0,0,0)
   call SaveIt(Head,action)
 end if
 if (action=1)
     +      call SaveDa(pt,nmax*kmax,nmax,kmax)
 if (action<3) then
   if (saveMAC=’Quit’) then
     call FaceIt(0,DoQuit,0,0,0,0)      !complete Quit
   else if (saveMAC=’Transfer’) then
     call FaceIt(0,DoTran,0,0,0,0)      !complete Transfer
   end if
 end if
     case(‘Means...’)
   call Means(pt,nmax,kmax)
     case default
   end select
   call UpdateMenu(menuhdl(5),PtPtr)
 repeat
      end

* The following menu-updating routine keeps a single menu item
* updated.
 SUBROUTINE UpdateMenu(amenuhdl,aPtr)
 implicit none
      INTEGER ENABLEITEM
      PARAMETER (ENABLEITEM=Z’93911000')
 INTEGER DISABLEITEM
 PARAMETER (DISABLEITEM=Z’93A11000')
 integer*4 amenuhdl,aPtr
 if (aPtr<>0) then !data in array
   call toolbx(ENABLEITEM,amenuhdl,1)
 else
   call toolbx(DISABLEITEM,amenuhdl,1)
 end if
 end

*  Write data to output file
 Subroutine SaveDa(pt,npts,nmax,kmax)
 implicit none
     real*8 pt(npts)
 integer*4 i,npts,nmax,kmax
 character*256 Head
 
      include HD40:Fortran:FaceIt:StorMF.inc
 
 if (trim(name)=’’) then
   MAC = ‘Save data points as’
   call FaceIt(0,StdSav,0,0,0,0)
 end if
 if (name <> ‘Cancel’) then
   open(3,file = name,status = ‘new’,form=’unformatted’)
   write(3)nmax,kmax
   do (i=1,kmax)
     call FaceIt(0,GetStr,1001,i,0,0)
     Head=trim(MAC)
     write(3)Head
   repeat
   write(3)(pt(i),i=1,npts)
   close(3)
   call FaceIt(1,MovSh1,0,0,0,0)  !reset title
   MAC = ‘DPTE’
   call FaceIt(0,SetTyp,RetCtl,0,0,0)
      end if
 end

*  means sub calculates the means of the selected variables
*  Over the selected observations
 Subroutine Means(pt,nmax,kmax)
 implicit none
 integer*4 nmax,kmax
 real*8 pt(nmax,kmax),sum,xbar
      integer*4 toolbx,i,j
 integer*4 nbeg,nend,kbeg,kend
 character*80 head(10),temp
 logical*1 check

      include HD40:Fortran:FaceIt:StorMF.inc

*  call dialog to get observations and variables
 call SelObs(nbeg,nend,nmax,kmax,check)
 if (check) then
*  Write out headers, first select output window
*  then write out information
   head(1)=’Calculated Means’
   head(2)=’’
   write(temp,’(i5)’) nbeg
   head(3)=’Observations:  # ‘//trim(temp)
   write(temp,’(i5)’) nend
   head(3)=trim(head(3))//’ to # ‘//trim(temp)
   head(4)=’’
   do (i=1,4)
     MAC=head(i)
     call FaceIt(-1,RetCtl,0,0,0,0)
   repeat
  
*  Calculate Means and print out results
   kbeg=0
   kend=0
   do (j=1,kmax)
     call FaceIt(0,GetStr,1001,j,0,0)
     if (MAC(1:1)=’*’) then
       if (kbeg=0) kbeg=j
 if ((kend=0).or.(kbeg>0)) kend=j
       sum=0
 do (i=nbeg,nend)
   sum=sum+pt(i,j)
 repeat
 xbar=sum/(nend-nbeg+1)
 write(temp,’(f12.6)’) xbar
 call FaceIt(0,GetStr,1001,j,0,0)
 MAC=’Mean of ‘//trim(MAC(2:22))//’= ‘//trim(temp)
 call FaceIt(-1,RetCtl,0,0,0,0)
     end if
   repeat
   selrect1(1)=nbeg
   selrect1(3)=nend
   selrect1(2)=kbeg
   selrect1(4)=kend
   fixrect(1)=1;fixrect(2)=1;
   fixrect(3)=nmax;fixrect(4)=kmax;
   call FaceIt(0,FixSh1,0,0,0,0)
 end if
 do (j=1,kmax)
   call FaceIt(0,GetStr,1001,j,0,0)
   if (MAC(1:1)=’*’) then
     MAC=MAC(2:len(trim(MAC)))
     call FaceIt(0,SetStr,1001,j,0,0)
   end if
 repeat 
 MAC=’ ‘
 call FaceIt(-1,RetCtl,0,0,0,0)
 MAC=’ ‘
 call FaceIt(-1,RetCtl,0,0,0,0)
 end

*  Set bounds for a new sheet
 subroutine NewDlg(nmax,kmax,check)
 implicit none
  integer*4 toolbx,i,nmax,kmax,avail
 integer*2 mydialog(7)
 logical*1 check
 character*256 oldname
*  Absoft toolbox param equates, change path for your setup
 include HD40:Fortran:Include Files:memory.inc
      include HD40:Fortran:FaceIt:StorMF.inc

 save mydialog
 data mydialog/0,0,-2,0,-2,0,-2/
 oldname=name
 write(name,10) nmax,kmax
10 format(2i8)
 do (i = 1,7)
   dialog(i) = mydialog(i)
 repeat
 check=.false.
 avail=toolbx(COMPACTMEM,8000000)
 while (check<>.true.)
   call FaceIt(0,OpnDlg,1010,0,0,0)      !open dialog #1010
   if (dialog(1) = 1) then
     read(name,12) nmax,kmax
12        format(2i8)
     if (nmax*kmax*8>avail-20000) then
       write(MAC,*)’Not enough memory. ‘,
     +      (avail-20000)/8,’ cells available.  ‘,
     +      ‘Click to continue.’
 call FaceIt(0,OpnAlt,1005,0,0,0)
     else
       check=.true.
 do (i = 1,7)                       !update all values
   mydialog(i) = dialog(i)
 repeat
     end if
   else if (dialog(2)=1) then
     check=.false.
     call FaceIt(0,RetCtl,0,0,0,0) !close dialog window
     name=oldname
     return
   end if
 repeat
 call FaceIt(0,RetCtl,0,0,0,0)!close dialog window
 end

*  Set observations to perform means on
 subroutine SelObs(nbeg,nend,nmax,kmax,check)
 implicit none
  integer*4 nbeg,nend,nmax,kmax
 integer*4 toolbx,i,j
 integer*2 mydialog(8)
 logical*1 check
 character*256 oldname
 
      include HD40:Fortran:FaceIt:StorMF.inc

 data mydialog/0,0,-2,0,-2,0,-2,0/
 oldname=name
 write(name,10) selrect1(1),selrect1(3)
10 format(2i8)
 do (j=selrect1(2),selrect1(4))
   call FaceIt(0,GetStr,1001,j,0,0)
   MAC=’*’//trim(MAC)
   call FaceIt(0,SetStr,1001,j,0,0)
 repeat
 do (i = 1,8)
   dialog(i) = mydialog(i)
 repeat
 listID(1)=-1001
 check=.false.
 while (check<>.true.)
   call FaceIt(0,OpnDlg,1020,0,0,0)        !open dialog #1020
   if (dialog(1) = 1) then
     read(name,12) nbeg,nend
12        format(2i8)
   if (nend>nmax) nend=nmax
     do (i = 1,8)                          !update all values
 mydialog(i) = dialog(i)
     repeat
     check=.true.
   else if (dialog(2)=1) then
     call FaceIt(0,RetCtl,0,0,0,0) !close dialog window
     check=.false.
     name=oldname
     return
   end if
 repeat
 name=oldname
 call FaceIt(0,RetCtl,0,0,0,0)      !close dialog window
 end

*  check whether to save Data before opening
 subroutine SaveIt(what,action)
 implicit none
 integer*4 action
 character*256 what
      include HD40:Fortran:FaceIt:StorMF.inc
 write(MAC,’(2a64)’)trim(name),trim(what)
 call FaceIt(0,OpnAlt,1030,0,0,0)
 action=dialog(1)
 end
*  Include FaceIt declarations
      include HD40:Fortran:FaceIt:FaceMF.inc

 
AAPL
$101.58
Apple Inc.
+0.72
MSFT
$46.52
Microsoft Corpora
-0.24
GOOG
$584.77
Google Inc.
+4.82

MacTech Search:
Community Search:

Software Updates via MacUpdate

BusyCal 2.6 - Powerful calendar app with...
BusyCal is an award-winning desktop calendar that combines personal productivity features for individuals with powerful calendar sharing capabilities for families and workgroups. BusyCal's unique... Read more
Apple iOS 8.0 - The latest version of Ap...
The latest version of iOS can be downloaded through iTunes. Apple iOS 8 comes with big updates to apps you use every day, like Messages and Photos. A whole new way to share content with your family.... Read more
Apple Digital Camera RAW Compatibility 5...
Apple Digital Camera RAW Compatibility update adds RAW image compatibility to Aperture 3 and iPhoto '11. For more information on supported RAW formats, see here.Version 5.07: Adds RAW camera... Read more
Transmit 4.4.7 - Excellent FTP/SFTP clie...
Transmit is an excellent FTP (file transfer protocol), SFTP, S3 (Amazon.com file hosting) and iDisk/WebDAV client that allows you to upload, download, and delete files over the internet. With the... Read more
Macgo Blu-ray Player 2.10.8.1715 - Blu-r...
Macgo Mac Blu-ray Player can bring you the most unforgettable Blu-ray experience on your Mac. Overview Macgo Mac Blu-ray Player can satisfy just about every need you could possibly have in a Blu-ray... Read more
Capture One Pro 8.0.0.433 - RAW workflow...
Capture One Pro 8 is a professional RAW converter offering you ultimate image quality with accurate colors and incredible detail from more than 300 high-end cameras -- straight out of the box. It... Read more
Adobe Acrobat Pro 11.0.09 - Powerful PDF...
Adobe Acrobat allows users to communicate and collaborate more effectively and securely. Unify a wide range of content in a single organized PDF Portfolio. Collaborate through electronic document... Read more
Adobe Reader 11.0.09 - View PDF document...
Adobe Reader allows users to view PDF documents. You may not know what a PDF file is, but you've probably come across one at some point. PDF files are used by companies and even the IRS to... Read more
iFFmpeg 4.6.1 - Convert multimedia files...
iFFmpeg is a graphical front-end for FFmpeg, a command-line tool used to convert multimedia files between formats. The command line instructions can be very hard to master/understand, so iFFmpeg does... Read more
NTFS 11.3.62 - Provides full read and wr...
Paragon NTFS breaks down the barriers between Windows and OS X. Paragon NTFS effectively solves the communication problems between the Mac system and NTFS, providing full read and write access to... Read more

Latest Forum Discussions

See All

Minuum - The Little Keyboard for Big Fin...
Minuum - The Little Keyboard for Big Fingers 1.0 Device: iOS iPhone Category: Utilities Price: $1.99, Version: 1.0 (iTunes) Description: Type faster, see more of your screen, and take control of autocorrect with Minuum: the little... | Read more »
TextExpander 3 + custom keyboard (Utili...
TextExpander 3 + custom keyboard 3.0 Device: iOS Universal Category: Utilities Price: $4.99, Version: 3.0 (iTunes) Description: | Read more »
Swype - Keyboard (Utilities)
Swype - Keyboard 1.0.1411 Device: iOS Universal Category: Utilities Price: $.99, Version: 1.0.1411 (iTunes) Description: Why type when you can Swype? One of the most requested apps for iPhone is finally here. "If Swype itself ever... | Read more »
Joinz (Games)
Joinz 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: Joinz is a clever block sliding puzzle game that is easy to play, nice to look at but tricky to master. You will be coming back again... | Read more »
Little World Escape Review
Little World Escape Review By Jordan Minor on September 17th, 2014 Our Rating: :: EARTHBOUNDUniversal App - Designed for iPhone and iPad Little World Escape draws players in with captivating concepts before pushing them away with... | Read more »
Light in the Dark Review
Light in the Dark Review By Nadia Oxford on September 17th, 2014 Our Rating: :: LIGHT 'EM UP UP UPUniversal App - Designed for iPhone and iPad Light in the Dark is an interesting and challenging puzzle game with some amusing bits... | Read more »
ShareFile for iPad is iOS 8-Ready with N...
ShareFile for iPad is iOS 8-Ready with New File-Editi​ng Feature Posted by Jessica Fisher on September 17th, 2014 [ permalink ] | Read more »
Pizo Animals
Pizo Animals By Amy Solomon on September 17th, 2014 Our Rating: :: DELIGHTFUL PUZZLESUniversal App - Designed for iPhone and iPad Pizo Animals is a puzzle app that includes many options adults can choose to customize the experience... | Read more »
ETA for iOS 8 Introduces Today View Exte...
ETA for iOS 8 Introduces Today View Extension and is Having a 50% Off Sale Posted by Jessica Fisher on September 17th, 2014 [ permalink ] | Read more »
Get Ready to Hit the Ice – NHL 2K is Com...
Get Ready to Hit the Ice – NHL 2K is Coming to the App Store Soon Posted by Jessica Fisher on September 17th, 2014 [ permalink ] 2K announced today that they are bringing NHL 2K< | Read more »

Price Scanner via MacPrices.net

Logitech Bluetooth Multi-Device Cross-Platfor...
Logitech has an enviable track record of making some of the best computer keyboards and mice. At least in my estimation, the best freestanding keyboards I’ve ever used have been Logitech units,... Read more
Roundup of Apple refurbished iPad Airs and iP...
Apple is offering Certified Refurbished iPad Airs for up to $140 off MSRP. Apple’s one-year warranty is included with each model, and shipping is free. Stock tends to come and go with some of these... Read more
Sprint offers 16GB iPad mini for $199.99 with...
Sprint is offering 1st generation 16GB iPad minis for $199.99 with a 2-year service agreement. Standard MSRP for this iPad is $429. Their price is the lowest available for this model. Read more
2.5GHz Mac mini remains on sale for $549, sav...
B&H Photo has the 2.5GHz Mac mini on sale for $549.99 including free shipping. That’s $50 off MSRP, and B&H will also include a free copy of Parallels Desktop software. NY sales tax only. Read more
Apple refurbished iMacs available for up to $...
The Apple Store has Apple Certified Refurbished iMacs available for up to $300 off the cost of new models. Apple’s one-year warranty is standard, and shipping is free. These are the best prices on... Read more
13″ 2.5GHz MacBook Pro offered for $100 off M...
B&H Photo has the 13″ 2.5GHz MacBook Pro on sale for $999.99 including free shipping plus NY sales tax only. Their price is $100 off MSRP. Read more
Free GIMP Professional Grade Graphics App Ver...
The latest 2.8.14 version of the oddly-named GIMP (acronym for: GNU Image Manipulation Program) open source, high-end image editing and creation alternative to Adobe’s Photoshop and refuge from... Read more
Apple Announces Record Pre-orders for iPhone...
Apple has released metrics showing a record number of first day pre-orders of iPhone 6 and iPhone 6 Plus, with over four million sold in the first 24 hours. Demand for the new iPhones exceeds the... Read more
10% off iPhone 6 and 6 Plus Otterbox cases
Get 10% off on popular Otterbox iPhone 6 and iPhone 6 Plus cases at MacMall through September 19th. Use code OTTERBOX10 to see the discount. Read more
15-inch MacBook Pros on sale for up to $125 o...
Amazon has the new 2014 15″ Retina MacBook Pros on sale for up to $125 off MSRP including free shipping: - 15″ 2.2GHz Retina MacBook Pro: $1899.99 save $100 - 15″ 2.5GHz Retina MacBook Pro: $2374... Read more

Jobs Board

*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.