'=========================================================================== ' Subject: Grievance Tracking Date: - - ( : ) ' Author: Burce Peaslee Code: Liberty BASIC ' Origin: peaslee@pacbell.net Packet: LIBERTYB.ABC '=========================================================================== Burce Peaslee peaslee@pacbell.net Liberty BASIC 'Grieve Easily '============= 'A grievance tracking program '(c)2001 Bruce Peaslee 'All rights reserved ' '~~~~~~~~~~~~~~ 'Initialization '~~~~~~~~~~~~~~ ForegroundColor$ = "Black" BackgroundColor$ = "Buttonface" TexteditorColor$ = "White" TextboxColor$ = "White" ComboboxColor$ = "White" ListboxColor$ = "White" CR$ = chr$(13) ' Carriage Return NOMAINWIN '================================================== 'Define Member Database '================================================== DIM Members$(100,14) memID = 0 'currently the record number, might change in future versions memFirstName = 1 memLastName = 2 memAddr1 = 3 memAddr2 = 4 memCity = 5 memZip = 6 memHomePhone = 7 memWorkPhone = 8 memEmail = 9 memChapter = 10 memSteward = 11 memFieldRep = 12 '================================================== 'Define Employer Database [NOT YET IMPLEMENTED] '================================================== DIM Employer$(100,21) empNumberOfSteps = 0 empName = 1 empStep1Name = 2 empStep1addr1 = 3 empStep1addr2 = 4 empStep1City = 5 empStep1Zip = 6 empStep2Name = 7 empStep2addr1 = 8 empStep2addr2 = 9 empStep2City = 10 empStep2Zip = 11 empStep3Name = 12 empStep3addr1 = 13 empStep3addr2 = 14 empStep3City = 15 empStep3Zip = 16 empStep4Name = 17 empStep4addr1 = 18 empStep4addr2 = 19 empStep4City = 20 empStep5Zip = 21 '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'Begin Main Program '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ WindowWidth = 571 WindowHeight = 274 UpperLeftX = 10 UpperLeftY = 10 menu #main, "&File" , _ "&New", [null] , _ "&Open", [null] , _ "&Save", [null] , _ | , _ "E&xit", [quit] FileMenu = 0 NewItem = 0 OpenItem = 1 SaveItem = 2 'Divider = 3 ExitItem = 4 menu #main, "&Edit" , _ "&Undo", [null], _ | , _ "Cu&t", [null], _ "&Copy", [null], _ "&Paste", [null] EditMenu = 1 UndoItem = 0 'Divider = 1 CutItem = 2 CopyItem = 3 PasteItem = 4 menu #main, "&Actions", _ "&Edits/Reports", [main.go] ActionsMenu = 2 EditsItem = 0 menu #main, "&Help" , _ "&Help" , [null], _ "&Credits", [credits], _ | , _ "&About", [about] HelpMenu = 3 HelpItem = 0 CreditsItem = 1 'Divider = 2 AboutItem = 3 Open "Grieve Easily" for window as #main print #main, "trapclose [quit]" print #main, "font courier_new bold 10" 'Disable unused or unready menu items CALL EnableMenuItem FileMenu, NewItem, "no" CALL EnableMenuItem FileMenu, OpenItem, "no" CALL EnableMenuItem FileMenu, SaveItem, "no" CALL EnableMenuItem EditMenu, UndoItem, "no" CALL EnableMenuItem EditMenu, CutItem, "no" CALL EnableMenuItem EditMenu, CopyItem, "no" CALL EnableMenuItem EditMenu, PasteItem, "no" CALL EnableMenuItem HelpMenu, HelpItem, "no" CALL EnableMenuItem HelpMenu, CreditsItem, "no" CALL EnableMenuItem HelpMenu, AboutItem, "no" wait [main.go] WindowWidth = 510 WindowHeight = 400 UpperLeftX = 30 UpperLeftY = 30 groupbox #go.Group1, "Add/Modify Records", 40, 60, 180, 230 button #go.EditMembers, "Edit Members", [Go.edit.members], UL, 65, 90, 130, 25 button #go.EditEmployers, "Edit Employers", [null], UL, 65, 130, 130, 25 button #go.EditGrievances, "Edit Grievances", [null], UL, 65, 170, 130, 25 button #go.EditReps, "Edit Field Reps", [null], UL, 65, 210, 130, 25 button #go.EditChapters, "Edit Chapters", [null], UL, 65, 250, 130, 25 groupbox #go.Group2, "Reports", 285, 60, 180, 150 button #go.RptAllMembers, "All Members", [null], UL, 310, 90, 130, 25 button #go.RptAllEmployers, "All Employers", [null], UL, 310, 130, 130, 25 button #go.RptAllGrievances, "All Grievances", [null], UL, 310, 170, 130, 25 button #go.close, "Close", [Go.close], UL, 190, 330, 130, 25 open "go" for dialog_modal as #go print #go, "trapclose [Go.close]" wait [Go.close] close #go wait [Go.edit.members] statictext #EditMembers.Static0, "ID #:", 35, 10, 90, 25 statictext #EditMembers.Static1, "", 130, 10, 90, 25 'to display record # statictext #EditMembers.Static2, "First Name", 35, 40, 90, 25 statictext #EditMembers.Static3, "Last Name", 35, 70, 90, 25 statictext #EditMembers.Static4, "addr 1", 35, 100, 90, 25 statictext #EditMembers.Static5, "addr 2", 35, 130, 90, 25 statictext #EditMembers.Static6, "City", 35, 160, 90, 25 statictext #EditMembers.Static7, "ZIP", 35, 190, 90, 25 statictext #EditMembers.Static8, "Home Phone", 35, 220, 90, 25 statictext #EditMembers.Static9, "Work Phone", 35, 250, 90, 25 statictext #EditMembers.Static10, "Email", 35, 280, 90, 25 statictext #EditMembers.Static11, "Chapter", 35, 310, 90, 25 statictext #EditMembers.Static12, "Steward", 35, 340, 90, 25 statictext #EditMembers.Static13, "Field Rep", 35, 370, 90, 25 textbox #EditMembers.FirstName, 130, 40, 190, 25 textbox #EditMembers.LastName, 130, 70, 190, 25 textbox #EditMembers.Addr1, 130, 100, 190, 25 textbox #EditMembers.Addr2, 130, 130, 190, 25 textbox #EditMembers.City, 130, 160, 190, 25 textbox #EditMembers.Zip, 130, 190, 90, 25 textbox #EditMembers.HomePhone, 130, 220, 190, 25 textbox #EditMembers.WorkPhone, 130, 250, 190, 25 textbox #EditMembers.Email, 130, 280, 190, 25 textbox #EditMembers.Chapter, 130, 310, 190, 25 textbox #EditMembers.Steward, 130, 340, 190, 25 textbox #EditMembers.FieldRep, 130, 370, 190, 25 button #EditMembers.New, "New", [EditMembers.new], UL, 400, 40, 60, 25 button #EditMembers.Add, "Add", [EditMembers.add], UL, 400, 70, 60, 25 button #EditMembers.Delete, "Delete", [EditMembers.delete], UL, 400, 100, 60, 25 button #EditMembers.Help, "Help", [EditMembers.help], UL, 400, 130, 60, 25 button #EditMembers.Save, "Save", [EditMembers.save], UL, 35, 420, 60, 25 button #EditMembers.Cancel, "Close", [EditMembers.close], UL, 120, 420, 60, 25 statictext #EditMembers.Static14, "Click 'Add' to update record.", 200, 425, 390, 25 button #EditMembers.First, "<<", [EditMembers.first], UL, 35, 470, 60, 25 button #EditMembers.Prev, "<", [EditMembers.previous], UL, 96, 470, 60, 25 button #EditMembers.Next, ">", [EditMembers.next], UL, 157, 470, 60, 25 button #EditMembers.Last, ">>", [EditMembers.last], UL, 218, 470, 60, 25 statictext #EditMembers.Static15, " First" , 35, 498, 60, 25 statictext #EditMembers.Static16, " Previous " , 96, 498, 60, 25 statictext #EditMembers.Static17, " Next " , 157, 498, 60, 25 statictext #EditMembers.Static18, " Last " , 218, 498, 60, 25 WindowWidth = 510 WindowHeight = 550 UpperLeftX = 1 UpperLeftY = 1 open "Edit Members" for dialog_modal as #EditMembers print #EditMembers, "trapclose [EditMembers.close]" print #EditMembers, "font ms_sans_serif 10" print #EditMembers.Static15, "!font ms_sans_serif bold 8" print #EditMembers.Static16, "!font ms_sans_serif bold 8" print #EditMembers.Static17, "!font ms_sans_serif bold 8" print #EditMembers.Static18, "!font ms_sans_serif bold 8" 'read in member data open "members.grv" for random as #members len = 224 field #members, _ 5 as id$, _ 20 as firstName$, _ 20 as lastName$, _ 20 as addr1$, _ 20 as addr2$, _ 20 as city$, _ 5 as zip$, _ 12 as homePhone$, _ 12 as workPhone$, _ 30 as email$, _ 20 as chapter$, _ 20 as steward$, _ 20 as fieldRep$ numberOfMemberRecords = lof(#members)/224 IF numberOfMemberRecords > 0 THEN currentMemberRecordNumber = 1 ELSE currentMemberRecordNumber = 0 END IF FOR i = 1 to numberOfMemberRecords get #members, i Members$(i, memID) = id$ Members$(i, memFirstName) = firstName$ Members$(i, memLastName) = lastName$ Members$(i, memAddr1) = addr1$ Members$(i, memAddr2) = addr2$ Members$(i, memCity) = city$ Members$(i, memZip) = zip$ Members$(i, memHomePhone) = homePhone$ Members$(i, memWorkPhone) = workPhone$ Members$(i, memEmail) = email$ Members$(i, memChapter) = chapter$ Members$(i, memSteward) = steward$ Members$(i, memFieldRep) = fieldRep$ NEXT i close #members 'display record #1 (if it exists) IF numberOfMemberRecords > 0 THEN CALL DisplayMemberRecord 1 END IF wait [EditMembers.first] IF numberOfMemberRecords > 0 THEN currentMemberRecordNumber = 1 CALL DisplayMemberRecord 1 END IF wait [EditMembers.previous] IF currentMemberRecordNumber > 1 THEN currentMemberRecordNumber = currentMemberRecordNumber - 1 CALL DisplayMemberRecord currentMemberRecordNumber END IF wait [EditMembers.next] IF currentMemberRecordNumber < numberOfMemberRecords THEN currentMemberRecordNumber = currentMemberRecordNumber + 1 CALL DisplayMemberRecord currentMemberRecordNumber END IF wait [EditMembers.last] IF currentMemberRecordNumber < numberOfMemberRecords THEN currentMemberRecordNumber = numberOfMemberRecords CALL DisplayMemberRecord currentMemberRecordNumber END IF wait [EditMembers.new] 'disable "New" button h = hwnd(#EditMembers.New) open "user.dll" for dll as #user calldll #user, "EnableWindow", _ h as word, _ 0 as ushort, _ ' 0 = disable; 1 = enable result as ushort close #user numberOfMemberRecords = numberOfMemberRecords + 1 currentMemberRecordNumber = numberOfMemberRecords print #EditMembers.FirstName, "!setfocus" print #EditMembers.Static1, str$(currentMemberRecordNumber) print #EditMembers.FirstName, "" print #EditMembers.LastName, "" print #EditMembers.Addr1, "" print #EditMembers.Addr2, "" print #EditMembers.City, "" print #EditMembers.Zip, "" print #EditMembers.HomePhone, "" print #EditMembers.WorkPhone, "" print #EditMembers.Chapter, "" print #EditMembers.Steward, "" print #EditMembers.FieldRep, "" print #EditMembers.Email, "" print #EditMembers.Static14, "Click 'Add' to finalize data before clicking 'Save'" wait [EditMembers.add] i = currentMemberRecordNumber Members$(i, memID) = str$(i) print #EditMembers.FirstName, "!contents?" input #EditMembers.FirstName, x$ IF x$ = "" THEN notice "First name must be filled" print #EditMembers.FirstName, "!setfocus" wait ELSE Members$(i, memFirstName) = x$ END IF print #EditMembers.LastName, "!contents?" input #EditMembers.LastName, x$ IF x$ = "" THEN notice "Last name must be filled" print #EditMembers.LastName, "!setfocus" wait ELSE Members$(i, memLastName) = x$ END IF print #EditMembers.Addr1, "!contents?" input #EditMembers.Addr1, x$ Members$(i, memAddr1) = x$ print #EditMembers.Addr2, "!contents?" input #EditMembers.Addr2, x$ Members$(i, memAddr2) = x$ print #EditMembers.City, "!contents?" input #EditMembers.City, x$ Members$(i, memCity) = x$ print #EditMembers.Zip, "!contents?" input #EditMembers.Zip, x$ Members$(i, memZip) = x$ print #EditMembers.HomePhone, "!contents?" input #EditMembers.HomePhone, x$ Members$(i, memHomePhone) = x$ print #EditMembers.WorkPhone, "!contents?" input #EditMembers.WorkPhone, x$ Members$(i, memWorkPhone) = x$ print #EditMembers.Chapter, "!contents?" input #EditMembers.Chapter, x$ Members$(i, memChapter) = x$ print #EditMembers.Steward, "!contents?" input #EditMembers.Steward, x$ Members$(i, memSteward) = x$ print #EditMembers.FieldRep, "!contents?" input #EditMembers.FieldRep, x$ Members$(i, memFieldRep) = x$ print #EditMembers.Email, "!contents?" input #EditMembers.Email, x$ Members$(i, memEmail) = x$ 're-enable "New" button h = hwnd(#EditMembers.New) open "user.dll" for dll as #user calldll #user, "EnableWindow", _ h as word, _ 1 as ushort, _ ' 0 = disable; 1 = enable result as ushort close #user print #EditMembers.Static14, "Click 'Save' to save to file, if done" wait [EditMembers.delete] '-------------------------------------------------------------------------------- 'Note: ' The delete process changes records in the array, but does NOT reduce the file. ' Thus we have to reconstruct the file. We do this in the "Save" routine by ' deleting the file (KILL), then creating a new one. '------------------------------------------------------------------------------- IF numberOfMemberRecords > 0 THEN IF currentMemberRecordNumber < numberOfMemberRecords THEN ' move records FOR i = currentMemberRecordNumber to numberOfMemberRecords Members$(i,memID) = str$(i) FOR j = memFirstName to memFieldRep Members$(i,j) = Members$(i+1,j) NEXT j NEXT i END IF numberOfMemberRecords = numberOfMemberRecords - 1 currentMemberRecordNumber = currentMemberRecordNumber -1 CALL DisplayMemberRecord currentMemberRecordNumber END IF wait [EditMembers.help] notice "Edit Members Help" + CR$ + _ "Use the << < > >> buttons to navigate to records" + CR$ + _ "" + CR$ + _ "To create a new record, click 'New' " + CR$ + _ "" + CR$ + _ "To edit a record, just type in the fields" + CR$ + _ "" + CR$ + _ "Click 'Add' when the fields on the screen are correct" + CR$ + _ "" + CR$ + _ "Click 'Delete' to delete the current record" + CR$ + _ "" + CR$ + _ "When you want to save to disk, click 'Save'" + CR$ + _ space$(100) wait [EditMembers.help.close] close #EditMembersHelp wait [EditMembers.save] kill "members.grv" open "members.grv" for random as #members len = 224 field #members, _ 5 as id$, _ 20 as firstName$, _ 20 as lastName$, _ 20 as addr1$, _ 20 as addr2$, _ 20 as city$, _ 5 as zip$, _ 12 as homePhone$, _ 12 as workPhone$, _ 30 as email$, _ 20 as chapter$, _ 20 as steward$, _ 20 as fieldRep$ FOR i = 1 to numberOfMemberRecords id$ = Members$(i, memID) firstName$ = Members$(i, memFirstName) lastName$ = Members$(i, memLastName) addr1$ = Members$(i, memAddr1) addr2$ = Members$(i, memAddr2) city$ = Members$(i, memCity) zip$ = Members$(i, memZip) homePhone$ = Members$(i, memHomePhone) workPhone$ = Members$(i, memWorkPhone) email$ = Members$(i, memEmail) chapter$ = Members$(i, memChapter) steward$ = Members$(i, memSteward) fieldRep$ = Members$(i, memFieldRep) put #members, i NEXT i close #members wait [EditMembers.close] close #EditMembers wait [null] wait [quit] close #main END '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUB EnableMenuItem MenuNumber, ItemNumber, ItemEnabled$ '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ open "user" for dll as #user hMain = hwnd(#main) CallDll #user, "GetMenu", _ hMain as word,_ 'handle of the window hMenuBar as word 'returns handle of MENU BAR CallDll #user, "GetSubMenu", _ hMenuBar as short,_ 'handle of MENU BAR MenuNumber as short,_ 'position of menu:0 is in the first position, 1 is the second, etc. hSubMenu as short 'handle of submenu CallDll #user, "GetMenuItemID", _ hSubMenu as word, _ ' handle of the submenu ItemNumber as short, _ 'position of the menu item on the popup menu menu.id as word 'the handle (or ID) of the menu item IF ItemEnabled$ = "yes" THEN menu.flag = _MF_ENABLED ELSE menu.flag = _MF_GRAYED END IF calldll #user, "EnableMenuItem", _ hSubMenu as word,_ 'handle of SubMenu that contains the Menu Item menu.id as word,_ 'ID of menu item menu.flag as word,_ 'enabled = _MF_ENABLED Menu.enabled.return as word 'returns previous state of menu item close #user END SUB 'EnableMenuItem '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUB DisplayMemberRecord recordNumber '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ i = recordNumber 'saves typing!! print #EditMembers.Static1, str$(i) print #EditMembers.FirstName, Members$(i, 1) print #EditMembers.LastName, Members$(i, 2) print #EditMembers.Addr1, Members$(i, 3) print #EditMembers.Addr2, Members$(i, 4) print #EditMembers.City, Members$(i, 5) print #EditMembers.Zip, Members$(i, 6) print #EditMembers.HomePhone, Members$(i, 7) print #EditMembers.WorkPhone, Members$(i, 8) print #EditMembers.Email, Members$(i, 9) print #EditMembers.Chapter, Members$(i, 10) print #EditMembers.Steward, Members$(i, 11) print #EditMembers.FieldRep, Members$(i, 12) END SUB 'DisplayMemberRecord