home *** CD-ROM | disk | FTP | other *** search
- ; Vid-PAL.SC - Script to generate VIDEO.LIB containing the following
- ; procedures, which are part of the Video Store example
- ; application.
- ;
- ; Chime() - Play a 3-note musical alarm.
- ;
- ; VideoStartup() - Ask for a password before continuing.
- ;
- ; ShowVideoStatus() - Display statistics about the size of the video
- ; store's database (number of customers on file,
- ; etc.) This procedure is used to demonstrate
- ; the Workshop's ability to call a user-defined
- ; proc from the application menu.
- ;
- ; SetCustNo() - Assign a customer number to a new customer. This
- ; is an example of a user-defined procedure called
- ; during the execution of an edit session.
- ;
- ; CalcCharge() - Extend the rental fee amount while processing a
- ; return.
-
-
- CreateLib "Video" Size 50 ; (50 is the min. number of procs/lib)
-
- ;--------------------------------------------------------------------
- Proc Chime() ; Sound off a 3-note "chime"
- ; used by VideoStartup() (below)
- Private G,Middle_C,High_G,
- Quarter_Note,Half_Note
- G = Int(440*Pow(2,-2/12))
- Middle_C = Int(440*Pow(2,3/12))
- High_G = Int(440*Pow(2,10/12))
- Quarter_Note = 337
- Half_Note = 675
-
- Sound Middle_C Quarter_Note
- Sound G Quarter_Note
- Sound High_G Half_Note
- EndProc
- WriteLib "Video" Chime
- Release Procs Chime
-
-
- ;--------------------------------------------------------------------
- Proc VideoStartup() ; Proc to control initializtion of
- ; the video application
- Private StatWindow,StatWindowSpecs,EventBag,
- AuthCode,TimeofDay,Okay,Authorized,Hour,ValidTime
- ClearAll
- AuthCode = ""
- ShowDialog "Video Application Startup"
- @ 17,5 Height 7 Width 69
- @ 1,2 ?? "Please Enter Your Authorization Code (\"BORLAND\"):"
- Accept @1,52 Width 13 "A10" Picture "*!" Tag "Auth" to AuthCode
- ;Note: the accept statement above could have included the Hidden keyword
- Pushbutton @3,27 Width 12 "~O~K" OK Default Value True Tag "OK" to Okay
- EndDialog
- Authorized = (AuthCode="BORLAND") ; Check password (true/false)
- If Authorized then ; okay to continue with application
- Return True
- EndIf
-
- DynArray StatWindowSpecs[] ; (used in following Window Create)
- StatWindowSpecs["HasFrame"] = False ; No Frame
- StatWindowSpecs["Width"] = 60 ; Viewport Size
- StatWindowSpecs["Height"] = 9
- StatWindowSpecs["CanvasWidth"] = 60 ; Canvas Size
- StatWindowSpecs["CanvasHeight"] = 9
- Window Create Floating
- @ 1,10 ; where to place the window
- Attributes StatWindowSpecs ; (from above) no border around window
- To StatWindow ; window handle
- Text
-
- Unauthorized Access
- ─────────────────────────────────────────────────────
- A proper authorization code is required to run this
- application.
-
- Press any key to abort...
-
- EndText
- Chime() ; alert user of a problem
- GetEvent Key "ALL" Mouse "DOWN" To EventBag; wait for a keypress or mouse click
- Window Close
- Return False ; tell the Workshop to exit to DOS
- EndProc
- WriteLib "Video" VideoStartup
- Release Procs VideoStartup
-
-
- ;--------------------------------------------------------------------
- Proc ShowVideoStatus() ; Proc to display statistics
- ; about the Video Store database.
- Private StatWindow,StatWindowSpecs,EventBag
- ClearAll
- DynArray StatWindowSpecs[] ; (used in following Window Create)
- StatWindowSpecs["HasFrame"] = False
- StatWindowSpecs["Width"] = 60 ; Viewport Size
- StatWindowSpecs["Height"] = 15
- StatWindowSpecs["CanvasWidth"] = 60 ; Canvas Size
- StatWindowSpecs["CanvasHeight"] = 15
- Window Create Floating
- @ 5,10 ; where to place the window
- Attributes StatWindowSpecs ; (from above) no border around window
- To StatWindow ; window handle
- Text
-
- Current status of the Video Store database
- ────────────────────────────────────────────────────
- Customers on file ............................
- Number of film titles in the catalog .........
- Total tape inventory .........................
- Tapes currently rented out ...................
-
-
-
-
- Press any key to continue...
-
- EndText
- @ 3,50 ?? NRecords("Customer")
- @ 4,50 ?? NRecords("Films")
- FilmCount = CSum("Films","# of Copies")
- @ 5,50 ?? FilmCount
- @ 6,50 ?? FilmCount - CSum("Films","# in Stock")
- Message "Press any key to continue."
- GetEvent Key "ALL" Mouse "DOWN" To EventBag; wait for a keypress or mouse click
- Window Close
- Message ""; clear the message
- Window Close
- EndProc
- WriteLib "Video" ShowVideoStatus
- Release Procs ShowVideoStatus
-
-
- ;--------------------------------------------------------------------
- Proc SetCustNo() ; Proc to assign a customer no.
- ; This proc is attached to the
- ; "ADDCUST" edit session as an
- ; arrive-record event proc.
- ; It finds the highest number
- ; used so far and a increments
- ; it by one. While we're at it,
- ; we'll establish a membership
- ; expiration date.
- Private CustNo
- If IsBlank([Customer #]) Then ; customer record needs a number
- CustNo = CMax("Customer","Customer #"); find highest number assigned so far
- If CustNo = "Error" Then CustNo = 0 EndIf
- [Customer #] = Int(CustNo+1) ; set the next number
- EndIf
- If IsBlank([Expiration]) Then ; establish an expiration date
- [Expiration] = Today()+364
- EndIf
- Return 0 ; 0 = okay to proceed
- EndProc
- WriteLib "Video" SetCustNo
- Release Procs SetCustNo
-
-
- ;--------------------------------------------------------------------
- Proc CalcCharge() ; Proc to extend the rental fee.
- ; This proc is attached to the
- ; "RETURNS" edit session as a
- ; leave-field event proc.
- Private CustNo
- If Field() = "Return Date" Then ; (try to) calculate days out
- If IsBlank([]) or [Date]>[] Then ; can't calculate days out yet
- [Days Out] = 0
- Else
- [Days Out] = Max(1,[Return Date]-[Date]) ; same-day counts as 1 day
- EndIf
- EndIf
-
- If (Field() = "Return Date" or Field() = "Rewound?")
- And Not IsBlank([Days Out])
- And Not IsBlank([Rental Rate]) Then ; extend the charges
- [Total Due] = [Rental Rate]*[Days Out]
- +IIf(Upper([Rewound?])="Y",0,1) ; add $1 rewinding charge
- EndIf
-
- Return 0 ; 0 = okay to proceed
- EndProc
- WriteLib "Video" CalcCharge
- Release Procs CalcCharge
-
-
-