home *** CD-ROM | disk | FTP | other *** search
- ;╔════════════════════════════════════════════════════════════════════════════╗
- ;║ SCRIPT NAME : TPINSERT.SC ║
- ;╚═══════╦════════════════════╦════════════════════╦═════════════════╦════════╝
- ;░░░░░░░░║ by Anthony Lee ║ DATE : 12/11/88 ║ TIME : ║░░░░░░░░░
- ;╔═══════╩════════════════════╩════════════════════╩═════════════════╩════════╗
- ;║ LIBRARY : TPINSERT ║
- ;║ PROCEDURES : ║
- ;║ ║
- ;║ PURPOSE : ║
- ;║ ║
- ;╚════════════════════════════════════════════════════════════════════════════╝
-
- If isfile("TPINSERT.lib") then
- Run "Del TPINSERT.lib"
- Endif
-
- Libname = "TPINSERT"
- Createlib Libname
-
- ;╔════════════════════════════════════════════════════════════════════════════╗
- ;║ Driver script : TPINSERT.SC ║
- ;╚════════════════════════════════════════════════════════════════════════════╝
- ;Begin main script - TPINSERT.SC
- ;Necessary tables are: TPINSERT.DB, TPSTRUCT.DB, and TPLOOKUP.DB
- ;
- ;
- ;Autolib = "TPInsert"
- ;
- ;SetPopup("TPLOOKUP")
- ;GetTPTable()
- ;GetYears()
- ;GetDates()
- ;InsertDates()
- ;ExitTPInsert()
- ;
- ;Clearall
- ;View tptable
- ;
- ;Release Vars tptable
-
-
-
- Proc GetTPTable() ;-----------------------------------------------------------
- ;Ask for a valid Time Planner table
- ;
- private TPFields,choice,tplen
-
- clear
- clearall
-
- style attribute 30
- @1,0 ?? format("W76,AC","SideKick Time Planner Utility")
- style attribute 27
- @2,0 ?? format("W76,AC","Posting Annual Events")
-
-
- style attribute 94
- @4,4 ??" ╔════════════════════════════════════════════════════════════════╗ "
- @5,4 ??" ║ ║ "
- @6,4 ??" ║ Which SideKick Time Planner table do you wish to add to: ║ "
- @7,4 ??" ║ < > ║ "
- @8,4 ??" ║ ║ "
- @9,4 ??" ╚════════════════════════════════════════════════════════════════╝ "
-
- style attribute 31
- @22,7 ?? "Please enter an existing Time Planner tablename or press <Esc> to exit. "
- style attribute 30
- @24,7 ?? "(For instructions, see the file SIDEKICK on your Sample Tables Disk)"
-
- While true
- Style Attribute 30
- @7,12 Accept "A52" Picture "*!" to tptable
- if retval = false then
- ExitTPInsert()
- endif
- tplen = len(tptable)
- cursor off
- Switch
- Case retval = false : ;User pressed <Esc>
- ExitTPInsert()
- Quit
- Case substr(tptable,tplen,1) <> "A" :
- @20,7 ??"The Time Planner filename must end with the letter A."
- Clear eol
- Case isblank(tptable) : ;User did not input a table name
- @20,7 clear eol
- Case tptable = "STRUCT":
- @20,7 ??"You may not select the STRUCT table"
- Clear eol
- Case istable(tptable) : ;Check if valid TP Structure
- @20,7 ??"Checking to see if valid Time Planner table"
- Style Attribute 158
- ??"....."
- clear eol
- style attribute 30
-
- {Tools} {Info} {Structure} select tptable
- TPFields = nrecords("Struct")
- Subtract "TPStruct" "Struct"
- if isempty("Struct") and TPFields = 7 then
- delete "struct"
- quitloop
- else
- @20,7 ??TPTable," is not a valid Time Planner table."
- Clear eol
- endif
- Otherwise : ;Table does not exist
- @20,7 ?? tptable," is not a tablename."
- Clear eol
- Endswitch
- cursor normal
- Endwhile
-
- Endproc
- Writelib Libname GetTPTable
- Release Procs GetTPTable
-
-
-
- Proc GetYears() ;-------------------------------------------------------------
- ;Ask for a table to insert
- ;
-
- Style Attribute 94
- @11,4 ??" ╔════════════════════════════════════════════════════════════════╗ "
- @12,4 ??" ║ ║ "
- @13,4 ??" ║ Annual Event -------> Starting Year: < > ║ "
- @14,4 ??" ║ Ending Year : < > ║ "
- @15,4 ??" ║ ║ "
- @16,4 ??" ╚════════════════════════════════════════════════════════════════╝ "
-
-
- @20,7 Clear eol
- style attribute 31
- @22,7 ?? "Please enter a year or press <Esc> to exit. "
- clear eol
-
- While true
- Style Attribute 30
- @13,52 Accept "A4" Picture "{1{9},2{0}}##" to StartYear
- cursor off
- Switch
- case retval = false : ;User pressed <Esc>
- clearall
- ExitTPInsert()
- Quit
- Case isblank(StartYear): ;User didn't enter a year
- @20,7 clear eol
- Clear eol
- Otherwise :
- quitloop
- Endswitch
- cursor normal
- Endwhile
-
-
- While true
- Style Attribute 30
- @14,52 Accept "A4" Picture "{1{9},2{0}}##" to EndYear
- cursor off
- Switch
- case retval = false : ;User pressed <Esc>
- clearall
- ExitTPInsert()
- Quit
- Case isblank(StartYear): ;User didn't enter a year
- @20,7 clear eol
- Clear eol
- Case numval(EndYear) < numval(StartYear) :
- @20,7 ??"Ending year must be greater that Starting year"
- Clear eol
- Otherwise :
- quitloop
- Endswitch
- cursor normal
- Endwhile
-
-
- Endproc
- Writelib Libname GetYears
- Release Procs GetYears
-
-
-
-
- Proc GetDates() ;-------------------------------------------------------------
- ;Ask for yearly events
- ;
- Private x
-
- Clear
- Clearall
-
- Edit "TPInser1"
- ;Pickform 1
-
- While true
- Wait Record
- Prompt "Please enter annual events to post to the Time Planner: ",
- "<F1> list category icons <Esc> exit application <F2> Do_it! "
- Until "F1", "F2", "Up", "Down", "Esc", "Del", "Enter", "Tab", "Right"
-
- Switch
- case retval = "Esc" : ;User pressed <Esc>
- Menu {Cancel} {Yes} clearall
- ExitTPInsert()
- Quit
- case retval = "F1" :
- Style Attribute 30
- if field() = "Icon Type" then
- echo normal echo off
- @21,13 ??"Please select the category icon for this event."
- Popup(5,55,1,11)
- [] = retval
- else
- @21,13 ??"No lookup help available for this field."
- sleep 2000
- endif
- case retval = "F2" :
- quitloop
- case ((retval = "Enter" or retval = "Tab" or retval = "Right") and field() <> "Description") :
- Right
- case retval = "Up" and (isblank([Month]) or isblank([Day])) and recno() <> 1 :
- keypress "Del"
- case retval = "Up" or retval = "Down" or retval="Tab" or retval="Enter" or retval = "Right" :
- If retval = "Up" and recno() = 1 then
- beep
- Endif
- ; baddate = False
- ; If retval = "Up" and isblank([Month]) or isblank([Day]) then
- ; keypress "Del"
- ; baddate = True
- ; Endif
- x=dateval(strval([Month])+"/"+strval([Day])+"/87")
- If x <> "Error" then
- execute retval
- else
- if [Month] = "02" and [Day] = "29" then
- @21,13 ??"No leap year entries allowed."
- clear eol
- sleep 2000
- else
- @21,13 ??"Invalid date. Please re-enter."
- clear eol
- sleep 2000
- endif
- Endif
- case retval = "Del" :
- execute retval
- Otherwise :
- quitloop
- Endswitch
- Endwhile
- Do_it!
-
- If isempty("TPInser1") then
- ExitTPInsert()
- echo normal echo off cursor off
- @21,13 ??"No records will be posted."
- clear eol
- sleep 2500
- quit
- Endif
-
- echo normal echo off cursor off
- @21,13 ??"Processing query"
- Style Attribute 158
- ??"....."
- clear eol
- @22,0 clear eol
- @23,0 clear eol
-
-
- Menu {Ask} {Tpinsert} typein "insert"
- [Month] = "_a"
- [Day] = "_b"
- [Icon Type] = "_c"
- [Alarm] = "_d"
- [Description] = "_e"
-
- Menu {Ask} {Tpinser1}
- [Month] = "_a"
- [Day] = "_b"
- [Icon Type] = "_c"
- [Alarm] = "_d"
- [Description] = "_e"
-
- Do_it!
- clearall
-
-
- EndProc
- Writelib Libname GetDates
- Release Procs GetDates
-
- Proc InsertDates() ;----------------------------------------------------------
- ;
- Private i,str
- Edit "TPInsert"
- Scan
- If [Alarm] = "Y" then
- [Alarm Time] = "12:00"
- else
- [Alarm Time] = "-1"
- endif
- endscan
- Do_it!
-
-
- For i from Numval(startyear) to numval(endyear)
-
- Edit "TPInsert"
- scan
- str = [month] + "/" + [day] + "/" + strval(i)
- [date] = dateval(str)
- endscan
- do_it!
-
-
- Menu {Ask} select tptable
- Menu {Ask} {TPInsert}
-
-
- moveto tptable
- typein "insert"
- [Date] = "_dateval"
- [Start Time] = "12:00"
- [End Time] = "12:00"
- [Order] = 1
- [Alarm Time] = "_Alarm"
- [Type] = "_type"
- [Description] = "_desc"
-
- moveto "TPInsert"
- [Date] = "_dateval"
- [Icon Type] = "_type"
- [Description] = "_desc"
- [Alarm Time] = "_alarm"
- do_it!
-
- Clearall
- Endfor
-
- Empty "Tpinsert"
- Empty "Tpinser1"
-
- endproc
- Writelib Libname InsertDates
- Release Procs InsertDates
-
-
-
-
- Proc ExitTPInsert() ;--------------------------------------------------------
- ;Release all variables when user quits application
- ;
-
- Release Vars Autolib, StartYear, EndYear,
- PopupLen,PopupList,PopupNumber,PopupStart
-
- if not isassigned(tptable) then quit
- endif
- If istable("Struct") then Delete "Struct" Endif
-
- Play "AJL"
-
- Endproc
- WriteLib Libname ExitTPInsert
- Release Procs ExitTPInsert
-
-
-
-
-
-
-
- ;╔════════════════════════════════════════════════════════════════════════════╗
- ;║ Popup Procedures: SetPopup, Popup, PopDraw, PopRedraw ║
- ;╚════════════════════════════════════════════════════════════════════════════╝
-
-
- Proc SetPopup(Tables) ;-------------------------------------------------------
- Private;Tables, ;List of tables for which to define popup menus
- TempName, ;Array which stores the names of each table
- NumMenus, ;Number of tables specified in "Tables" parameter
- NumItems, ;Number of items in current table
- CurrTable, ;Current table being looked at
- X ;Loop index
- Array TempName[10]
- Array PopupStart[10] ;Stores pointer to beginning of item list
- Array PopupNumber[10] ;Stores number of items in menu list
- Array PopupLen[10] ;Stores length of longest menu choice
- NumMenus=0
- NumItems=0
- Tables=Tables+","
- While match(Tables,"..,..",CurrTable,Tables) ;Process each table name
- If not istable(CurrTable)
- Then Quit "Table "+CurrTable+" does not exist."
- Endif
- NumMenus=NumMenus+1 ;Update which menu this is
- TempName[NumMenus]=CurrTable
- PopupStart[NumMenus]=NumItems ;NumItems is a running total
- NumItems=NumItems+nrecords(CurrTable)
- Endwhile
- If NumItems<>0
- Then Array PopupList[NumItems] ;Stores all line items from data tables
- Endif
- For X from 1 to NumMenus
- If isempty(TempName[X])
- Then PopupNumber[X]=0
- Else View TempName[X]
- Right
- PopupNumber[X]=0
- PopupLen[X]=0
- Scan
- PopupLen[X]=max(PopupLen[X],len([])+4) ;Update max width
- PopupNumber[X]=PopupNumber[X]+1
- PopupList[PopupNumber[X]+PopupStart[X]]=[] ;Store line item
- Endscan
- PopupLen[X]=max(PopupLen[X],10)
- ClearImage
- Endif
- Endfor
- Endproc
- Writelib Libname SetPopup
- Release Procs SetPopup
-
-
- Proc Popup(R,C,Num,Size) ;----------------------------------------------------
- Private;R, ;Row position of popup window
- ;C, ;Column position of popup window
- ;Num, ;Popup menu number
- ;Size, ;Number of choices to be displayed at one time
- Char, ;Last key that was pressed
- MenuPos, ;Current position within menu
- Choice, ;Current menu selection
- X ;Counter
- If PopupNumber[Num]=0
- Then Return ""
- Endif
- If Size>PopupNumber[Num]
- Then Size=PopupNumber[Num]
- Endif
- Echo Off
- Cursor Off
- @0,0
- ?? "Highlight the appropriate selection using the cursor movement keys."
- Clear Eol
- ? "Press [Enter] to accept, [Esc] to cancel menu selection."
- Clear Eol
- ;Draw menu box
- @R,C
- ?? "╔",fill("═",PopupLen[Num]-2),"╗"
- @R+1,C
- ?? "║ CHOOSE:",spaces(PopupLen[Num]-10),"║"
- @R+2,C
- ?? "╟",fill("─",PopupLen[Num]-2),"╢"
- For X from 1 to Size
- @R+2+X,C
- ?? "║ ",substr(strval(PopupList[PopupStart[Num]+X])+
- spaces(PopupLen[Num]),1,PopupLen[Num]-3),"║"
- Endfor
- @R+3+Size,C
- ?? "╚",fill("═",PopupLen[Num]-2),"╝"
- If Size<>PopupNumber[Num] ;Is there more data that can't be displayed?
- Then @R+2+Size,C+1
- ?? "" ;Show that more items exist below
- Endif
- MenuPos=1
- Choice=1
- While True
- Style Reverse ;Highlight current selection
- PopDraw()
- Style
- Char=getchar()
- Switch
- Case Char=-72: ;Key was [Up]
- If Choice=1 ;Are we already at the top?
- Then Beep
- Else If MenuPos>1 ;Can we move within the menu?
- Then PopDraw() ; Yes- Blank current selection
- MenuPos=MenuPos-1 ; Move window position
- Else PopRedraw(Choice-2) ; No- Redraw entire menu
- Endif
- Choice=Choice-1 ;Select new choice
- Endif
- Case Char=-80: ;Key was [Down]
- If Choice=PopupNumber[Num] ;Are we already at the bottom?
- Then Beep
- Else If MenuPos<Size ;Can we move within the menu?
- Then PopDraw() ; Yes- Blank current selection
- MenuPos=MenuPos+1 ; Move window position
- Else PopRedraw(Choice-Size+1); No- Redraw entire menu
- Endif
- Choice=Choice+1 ;Select new choice
- Endif
- Case Char=-71: ;Key was [Home]
- If MenuPos=Choice ;Is first selection on screen?
- Then PopDraw() ; Yes- Blank current selection
- Else PopRedraw(0) ; No- Redraw menu from start
- Endif
- MenuPos=1 ;Position at first item
- Choice=1 ;Select first item
- Case Char=-79: ;Key was [End]
- If Choice+Size-MenuPos=PopupNumber[Num];Is last selection on screen?
- Then PopDraw() ; Yes- Blank current selection
- Else PopRedraw(PopupNumber[Num]-Size); No- Redraw end of menu
- Endif
- MenuPos=Size ;Position at bottom of menu
- Choice=PopupNumber[Num] ;Select last item
- Case Char=-73: ;Key was [PgUp]
- If MenuPos=Choice ;Are we within first screen?
- Then Beep ; Yes- Disallow PgUp
- Else If Choice-MenuPos-Size>0
- Then Choice=Choice-MenuPos-Size+1
- Else Choice=1
- Endif
- PopRedraw(Choice-1) ; No- Redraw previous page
- MenuPos=1 ; Position on that item
- Endif
- Case Char=-81: ;Key was [PgDn]
- If Choice+Size-MenuPos=PopupNumber[Num];Are we within last screen?
- Then Beep ; Yes- Disallow PgDn
- Else If PopupNumber[Num]-Size<Choice+Size-MenuPos
- Then Choice=PopupNumber[Num]-Size+1
- Else Choice=Choice+Size-MenuPos+1
- Endif
- PopRedraw(Choice-1) ; No- Redraw next page
- MenuPos=1 ; Position on that item
- Endif
- Case Char=13: ;Key was [Enter]
- Cursor Normal
- Return PopupList[PopupStart[Num]+Choice] ;Return selection
- Case Char=27: ;Key was [Esc]
- Cursor Normal
- Return ""
- Otherwise: ;Illegal key
- Beep
- Endswitch
- Endwhile
- Endproc
- Writelib Libname Popup
- Release Procs Popup
-
-
- Proc PopDraw() ;--------------------------------------------------------------
- @MenuPos+R+2,C+2
- ?? PopupList[PopupStart[Num]+Choice]
- Endproc
- Writelib Libname PopDraw
- Release Procs PopDraw
-
-
- Proc PopRedraw(Start) ;-------------------------------------------------------
- ;Private Start ;Location within PopupList to begin redraw
- For Z from 1 to Size ;Redraw all information in the menu box
- @R+Z+2,C+2
- ?? substr(strval(PopupList[PopupStart[Num]+Start+Z])+
- spaces(PopupLen[Num]),1,PopupLen[Num]-3)
- Endfor
- @R+3,C+1
- If Start=0 ;Are there records above?
- Then ?? " " ; No- Remove up arrow
- Else ?? "" ; Yes- Place up arrow to signify more records
- Endif
- @R+Size+2,C+1
- If Start+Size=PopupNumber[Num] ;Are there records below?
- Then ?? " " ; No- Remove down arrow
- Else ?? "" ; Yes- Place down arrow to signify more
- Endif
- Endproc
- Writelib Libname PopRedraw
- Release Procs PopRedraw
-
-
-
-