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
$118.93
Apple Inc.
-0.07
MSFT
$47.81
Microsoft Corpora
+0.06
GOOG
$541.83
Google Inc.
+1.46

MacTech Search:
Community Search:

Software Updates via MacUpdate

Adobe Photoshop Elements 13.0 - Consumer...
Adobe Photoshop Elements 12--the #1 selling consumer photo editing software--helps you edit pictures with powerful, easy-to-use options and share them via print, the web, Facebook, and more.Version... Read more
Skype 7.2.0.412 - Voice-over-internet ph...
Skype allows you to talk to friends, family and co-workers across the Internet without the inconvenience of long distance telephone charges. Using peer-to-peer data transmission technology, Skype... Read more
HoudahSpot 3.9.6 - Advanced file search...
HoudahSpot is a powerful file search tool built upon MacOS X Spotlight. Spotlight unleashed Create detailed queries to locate the exact file you need Narrow down searches. Zero in on files Save... Read more
RapidWeaver 6.0.3 - Create template-base...
RapidWeaver is a next-generation Web design application to help you easily create professional-looking Web sites in minutes. No knowledge of complex code is required, RapidWeaver will take care of... Read more
iPhoto Library Manager 4.1.10 - Manage m...
iPhoto Library Manager lets you organize your photos into multiple iPhoto libraries. Separate your high school and college photos from your latest summer vacation pictures. Or keep some photo... Read more
iExplorer 3.5.1.9 - View and transfer al...
iExplorer is an iPhone browser for Mac lets you view the files on your iOS device. By using a drag and drop interface, you can quickly copy files and folders between your Mac and your iPhone or... Read more
MacUpdate Desktop 6.0.3 - Discover and i...
MacUpdate Desktop 6 brings seamless 1-click installs and version updates to your Mac. With a free MacUpdate account and MacUpdate Desktop 6, Mac users can now install almost any Mac app on macupdate.... Read more
SteerMouse 4.2.2 - Powerful third-party...
SteerMouse is an advanced driver for USB and Bluetooth mice. It also supports Apple Mighty Mouse very well. SteerMouse can assign various functions to buttons that Apple's software does not allow,... Read more
iMazing 1.1 - Complete iOS device manage...
iMazing (was DiskAid) is the ultimate iOS device manager with capabilities far beyond what iTunes offers. With iMazing and your iOS device (iPhone, iPad, or iPod), you can: Copy music to and from... Read more
PopChar X 7.0 - Floating window shows av...
PopChar X helps you get the most out of your font collection. With its crystal-clear interface, PopChar X provides a frustration-free way to access any font's special characters. Expanded... Read more

Latest Forum Discussions

See All

Mystery Case Files: Dire Grove, Sacred G...
Mystery Case Files: Dire Grove, Sacred Grove HD Review By Jennifer Allen on November 28th, 2014 Our Rating: iPad Only App - Designed for the iPad A decent new installment for the popular Mystery Case Files series.   | Read more »
Castaway Paradise – Tips, Tricks, and St...
Ahoy there, castaways: Were you curious about our own thoughts regarding this pristine shipwreck? Check out our Castaway Paradise review! Castaway Paradise is out for iOS, finally giving mobile gamers the opportunity to enjoy the idyllic lifestyle... | Read more »
Castaway Paradise VIP Subs are on Sale f...
Castaway Paradise VIP Subs are on Sale for a Limited Time, and a Special Holiday Update is Coming Soon Posted by Rob Rich on November 28th, 2014 [ | Read more »
Primitive Review
Primitive Review By Jordan Minor on November 28th, 2014 Our Rating: :: FOLK ARTUniversal App - Designed for iPhone and iPad True to its name, Primitive is about as straightforward as runners get.   | Read more »
7 tips to get ahead of the competition i...
7 tips to get ahead of the competition in Dynasty of Dungeons Posted by Simon Reed on November 28th, 2014 [ permalink ] Playcrab has launched their action-packed new dungeon crawler, Dynasty of Dungeons, today. | Read more »
Master of Tea Kung Fu Review
Master of Tea Kung Fu Review By Jordan Minor on November 28th, 2014 Our Rating: :: ONE DROP RULESUniversal App - Designed for iPhone and iPad Master of Tea Kung Fu is a creative and complex caffeinated brawler.   | Read more »
Monster Strike Review
Monster Strike Review By Campbell Bird on November 28th, 2014 Our Rating: :: BILLIARD STRATEGYUniversal App - Designed for iPhone and iPad Collect monsters and battle by flinging them across the battlefield in this strangely... | Read more »
Proun+ Review
Proun+ Review By Jennifer Allen on November 28th, 2014 Our Rating: :: TWITCHY RACINGUniversal App - Designed for iPhone and iPad Twitchy racing aplenty in Proun+, an enjoyably tricky title.   | Read more »
Lucha Amigos (Games)
Lucha Amigos 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: Forget Ninja Turtles, and meet Wrestlers Turtles! Crazier, Spicier and…Bouncier! Sling carapaces of 7 Luchadores to knock all... | Read more »
Record of Agarest War Zero (Games)
Record of Agarest War Zero 1.0 Device: iOS Universal Category: Games Price: $7.99, Version: 1.0 (iTunes) Description: HyperDevbox Holiday Turkey Black Friday Special Pricing! To celebrate the opening of the holiday season HyperDevbox... | Read more »

Price Scanner via MacPrices.net

Up To 75% Off Infovole Text Apps Over Black F...
Infovole’s entire range of apps, including the Textkraft family of word processors for iPads and iPhones, is being offered at 50-75% off over the Black Friday and Cyber Monday weekend. The five-day... Read more
Black Friday: Up to $60 off Mac minis, NY tax...
 B&H Photo has new 2014 Mac minis on sale for up to $60 off MSRP as part of their Black Friday sale. Shipping is free, and B&H charges NY sales tax only: - 1.4GHz Mac mini: $449.99 $50 off... Read more
Black Friday: 27-inch 5K iMac for $2299, save...
 B&H Photo continues to offer Black Friday sale prices on the 27″ 3.5GHz 5K iMac, in stock today and on sale for $2299 including free shipping plus NY sales tax only. Their price is $200 off MSRP... Read more
Karalux Announces 24K Gold-Plated iPhone 6
Karalux, a Vietnam-based jewellery firm, has launched a unique 24 karat gold-plated iPhone 6 version with gold-cast monolithic dragon on its back panel. The real 24 karat gold plated enclosure doesn’... Read more
Black Friday: 13-inch 2.6GHz Retina MacBook P...
 B&H Photo has lowered their price for the 13″ 2.6GHz/128GB Retina MacBook Pro to $1159 for Black Friday. That’s $140 off MSRP, and it’s the lowest price for this model (except for Apple’s $1099... Read more
View all the Black Friday sales on our Mac Pr...
We’ve updated our Mac Price Trackers with the latest information on prices, bundles, and availability on systems from Apple’s authorized internet/catalog resellers. View Black Friday sale prices at a... Read more
Black Friday: 11-inch MacBook Air for $779, s...
 Best Buy has lowered their price for the 2014 11″ 1.4GHz/128GB MacBook Air to $779.99 for Black Friday. That’s $120 off MSRP. Choose free shipping or free local store pickup (if available). Sale... Read more
Apple Store Black Friday sale for 2014: $100...
BLACK FRIDAY The Apple Store has posted their Black Friday deals for 2014. Receive a $100 PRODUCT(RED) branded iTunes gift card with the purchase of select Macs, $50 with iPads, and $25 with iPods,... Read more
Black Friday: 15% off iTunes Gift Cards
Staples is offering 15% off $50 and $100 iTunes Gift Cards on their online store as part of their Black Friday sale. Click here for more information. Shipping is free. Best Buy is offering $100... Read more
BEVL Releases Dock Tailored for iPhone 6 and...
Seattle based BEVL has released their first product: an iPhone dock that is divergent in build quality, rock-solid function and visual simplicity to complement the iPhone. BEVL is now accepting... Read more

Jobs Board

*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
Senior Event Manager, *Apple* Retail Market...
…This senior level position is responsible for leading and imagining the Apple Retail Team's global event strategy. Delivering an overarching brand story; in-store, 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* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.