; CONTACT.FS
;

; The AUTO macro is executed when the form system is run
;
#AUTO MACRO Go

MENU MainMenu
{
; Main menu replaces the Filler default menu
;
PopUp "&File"
  Begin
    MenuItem "&New Record", DataNewRecord
    MenuItem "&Save Record", DataUpdateRecord
    MenuItem "&Delete Record", DataDeleteRecord
    MENUITEM SEPARATOR
    MENUITEM "Set&up...", ShowSetUp
    MENUITEM "Form &Info...", FileFormInfo
    MENUITEM SEPARATOR
    MENUITEM "Print &Record", PrintRecord
    MENUITEM "Print &All", PrintAllRecords
    MENUITEM "&Printer Setup...", FilePrinterSetup
    MENUITEM SEPARATOR
    MENUITEM "E&xit", FileExit
    MENUITEM SEPARATOR
    MENUITEM "&Escape", SystemRestoreSystem
  END
PopUp "&Edit"
  Begin
    MenuItem "C&ut", EditCut
    MenuItem "&Copy", EditCopy
    MenuItem "&Paste", EditPaste
  END
PopUp "&View"
  Begin
    MENUITEM "&Enlarge", ViewEnlarge
    MENUITEM "&Real Size", ViewRealSize
    MENUITEM "Fit &Sides", ViewFitSides
    MENUITEM "&Full Page", ViewFitInWindow
  END
PopUp "&Search"
  Begin
    MenuItem "Alphabetical", AbcRibbon
    MenuItem "By Lastname", SearchLastName
  END
PopUp "&Help"
  Begin
    MenuItem "&Index...", HelpHelpIndex
    PopUp "&About..."
      Begin
        MenuItem "&Filler...", HelpAboutPerFORMPRO
        MenuItem "Form &System...", AboutThisFS
      END
  END
}

RIBBON VcrButtonsRibbon
{
; VCR style ribbon
;
Bitmap "RIGHT", LocateRecordFirst
Bitmap "TWORIGHT", LocateRecordNext
Bitmap "TWOLEFT", LocateRecordPrevious
Bitmap "LEFT1", LocateRecordLast
Button "ABC...", AbcRibbon
Space
Button "UPDATE", DataUpdateRecord
Bitmap "FILESAVE", DataAddRecord
Space
Bitmap "FILEQUIT", FileExit
Space
}

RIBBON AbcRibbon
{
; Alphabetic search ribbon with letters A through M
;
Button "A", A
Button "B", B
Button "C", C
Button "D", D
Button "E", E
Button "F", F
Button "G", G
Button "H", H
Button "I", I
Button "J", J
Button "K", K
Button "L", L
Button "M", M
Button "More...", MoreAlphaRibbon
Button "Close", VcrButtonsRibbon
Space
Button "UPDATE", DataUpdateRecord
}

RIBBON MoreAlphaRibbon
{
; Alphabetic search ribbon with letters N through Z
;
Button "N", N
Button "O", O
Button "P", P
Button "Q", Q
Button "R", R
Button "S", S
Button "T", T
Button "U", U
Button "V", V
Button "W", W
Button "X", X
Button "Y", Y
Button "Z", Z
Button "Back...", AbcRibbon
Button "Close", VcrButtonsRibbon
Space
Button "UPDATE", DataUpdateRecord
}



MACRO Go
{
; This macro is run automatically when the form system is "Run"
;
; Set up the window
;
WindowSetTitle="Contact Sheet"
WindowCloseAll
MainMenu
ViewShowRibbon 0
ViewShowGraphics 1
VcrButtonsRibbon
;
; Open Contact first so the user sees something happening
;
BeginExec FileOpenForm
  File="Contact.frp"
  Title="Contact Mngr."
  MultiCopies="No"
EndExec
WindowFormMaximize
ViewFitInWindow
;
; now open Setup hidden behind to avoid all the flashing
;
BeginExec FileOpenForm
  File="Setup.frp"
  Title="Setup"
  Show="Hidden"
  MultiCopies="No"
EndExec
WindowFormDisable "Setup.frp"
;
; get the app names into the buttons
;
AssignAppsToButtons
}


MACRO ShowSetUp
{
; Show the setup form and hide the CONTACT form
;
; Hide the menu and ribbon
;
  SystemMenu ="<None>"
  SystemRestoreRibbon
  WindowFormEnable "Setup.frp"
  WindowFormActivate "Setup.frp"
  ViewFitInWindow
  WindowFormMaximize
}


MACRO UpdateSetUp
{
; Return to the CONTACT form
;
; Update the SETUP record and hide the form
;
DataUpdateRecord
WindowFormHide "Setup.frp"
WindowFormDisable "Setup.frp"
;
; Restore the CONTACT environment
;
MainMenu
VcrButtonsRibbon
WindowFormActivate "contact.frp"
WindowFormMaximize
AssignAppsToButtons
}


/* Application that are launched from within FormSystem. */

MACRO LoadCalc
{
; Launch the Windows Calculator program
;
SystemRunProgram "calc.exe"
}

MACRO LoadDosSession
{
; Launch a DOS Session
;
SystemRunProgram "Dos.pif"
}

MACRO LoadCalndr
{
; Launch the Windows Calender program
;
SystemRunProgram "calendar.exe"
}

MACRO LoadTaskMngr
{
; Launch the Windows Switcher dialog
;
SystemRunProgram "Taskman.exe"
}

MACRO AboutThisFS
{
Message="[0][PerForm PRO Plus|Contact Manager Version 1.0|by Michael Harris|Delrina Technology Inc.][OK]"
}

Macro PrintRecord
{
; Print the current record on the printing form
;
LoadPrintForm
Printfrp->DATATYPE="CURRENT"
LocateGoToRecordNumber CONTACT->REC_NO
ThePrint
}

Macro PrintAllRecords
{
; Print all the records on the printing form
;
LoadPrintForm
Printfrp->DATATYPE="ALL"
ThePrint
}

MACRO LoadPrintForm
{
; Load the printing form
;
BeginExec FileOpenForm
  File= "PRINTFRP.FRP"
  Title="Printing..."
  Show="Hidden"
EndExec
}

MACRO ThePrint
{
; Print the form and data in the range specified
;
BeginExec FilePrint
  PAGEFROM    "All"
  COPIES      1
  PRINTSPEED  "FAST"
  PRINTCOLORS "AS_BLACK"
  PRINTFORM   "YES"
  PRINTDATA   "YES"
  DATA        Printfrp->DATATYPE
EndExec
;
; Restore the CONTACT form
;
FileCloseForm
WindowFormActivate "contact.frp"
}

/* Search for entry by first letter of lastname */

MACRO SearchLastName
{
; Show the Search on Index dialog ready for the user to fill in a value
; for the lastname.
;
BeginDialog LocateSearchOnIndexField
  BeginIndex
    File  "CONTACT.NDX"
    IndexExpression  "LAST"
    IndexCaseSensitive
  EndIndex
  SearchData LAST=""
  SearchMatch  "Equal to"
  StartSearchFromFirst
EndDialog
}


MACRO ButtonSearch
{
; Execute the search initiated by pressing one of the ribbon buttons
;
BeginExec LocateSearchOnIndexField
  BeginIndex
    File  "CONTACT.NDX"
    IndexExpression  "LAST"
    IndexCaseSensitive
  EndIndex
  SearchData LAST=QUERYFIELD
  SearchMatch  "Greater than or Equal to"
  StartSearchFromFirst
EndExec
}

Macro A
{
; Search for the first entry with a lastname that starts with the letter "A"
;
QUERYFIELD="A"
ButtonSearch
}

Macro B
{
QUERYFIELD="B"
ButtonSearch
}

Macro C
{
QUERYFIELD="C"
ButtonSearch
}

Macro D
{
QUERYFIELD="D"
ButtonSearch
}

Macro E
{
QUERYFIELD="E"
ButtonSearch
}

Macro F
{
QUERYFIELD="F"
ButtonSearch
}

Macro G
{
QUERYFIELD="G"
ButtonSearch
}

Macro H
{
QUERYFIELD="H"
ButtonSearch
}

Macro I
{
QUERYFIELD="I"
ButtonSearch
}

Macro J
{
QUERYFIELD="J"
ButtonSearch
}

Macro K
{
QUERYFIELD="K"
ButtonSearch
}

Macro L
{
QUERYFIELD="L"
ButtonSearch
}

Macro M
{
QUERYFIELD="M"
ButtonSearch
}

Macro N
{
QUERYFIELD="N"
ButtonSearch
}

Macro O
{
QUERYFIELD="O"
ButtonSearch
}

Macro P
{
QUERYFIELD="P"
ButtonSearch
}

Macro Q
{
QUERYFIELD="Q"
ButtonSearch
}

Macro R
{
QUERYFIELD="R"
ButtonSearch
}

Macro S
{
QUERYFIELD="S"
ButtonSearch
}

Macro T
{
QUERYFIELD="T"
ButtonSearch
}

Macro U
{
QUERYFIELD="U"
ButtonSearch
}

Macro V
{
QUERYFIELD="V"
ButtonSearch
}

Macro W
{
QUERYFIELD="W"
ButtonSearch
}

Macro X
{
QUERYFIELD="X"
ButtonSearch
}

Macro Y
{
QUERYFIELD="Y"
ButtonSearch
}

Macro Z
{
QUERYFIELD="Z"
ButtonSearch
}

Macro AssignAppsToButtons
{
; Plant the text in the 6 user defined buttons on CONTACT.  Must fill in
; all the buttons in case some were removed by going to SETUP.
;
NAME1=Setup->NAME1
NAME2=Setup->NAME2
NAME3=Setup->NAME3
NAME4=Setup->NAME4
NAME5=Setup->NAME5
NAME6=Setup->NAME6
}

Macro UserApp1
{
; Respond to a user pressing the first application button on CONTACT
;
If Setup->APP1
  SystemRunProgram Setup->APP1
End
}

Macro UserApp2
{
If Setup->APP2
  SystemRunProgram Setup->APP2
End
}

Macro UserApp3
{
If Setup->APP3
  SystemRunProgram Setup->APP3
End
}

Macro UserApp4
{
If Setup->APP4
  SystemRunProgram Setup->APP4
End
}

Macro UserApp5
{
If Setup->APP5
  SystemRunProgram Setup->APP5
End
}

Macro UserApp6
{
If Setup->APP6
  SystemRunProgram Setup->APP6
End
}

