2 ' Q B a s i c M O N E Y M A N A G E R
4 ' Copyright (C) Microsoft Corporation 1990
6 ' The Money Manager is a personal finance manager that allows you
7 ' to enter account transactions while tracking your account balances
10 ' To run this program, press Shift+F5.
12 ' To exit QBasic, press Alt, F, X.
14 ' To get help on a BASIC keyword, move the cursor to the keyword and press
15 ' F1 or click the right mouse button.
19 'Set default data type to integer for faster operation
22 'Sub and function declarations
23 DECLARE SUB TransactionSummary (item%)
24 DECLARE SUB LCenter (text$)
25 DECLARE SUB ScrollUp ()
26 DECLARE SUB ScrollDown ()
27 DECLARE SUB Initialize ()
29 DECLARE SUB SparklePause ()
30 DECLARE SUB Center (row%, text$)
31 DECLARE SUB FancyCls (dots%, Background%)
32 DECLARE SUB LoadState ()
33 DECLARE SUB SaveState ()
34 DECLARE SUB MenuSystem ()
35 DECLARE SUB MakeBackup ()
36 DECLARE SUB RestoreBackup ()
37 DECLARE SUB Box (Row1%, Col1%, Row2%, Col2%)
38 DECLARE SUB NetWorthReport ()
39 DECLARE SUB EditAccounts ()
40 DECLARE SUB PrintHelpLine (help$)
41 DECLARE SUB EditTrans (item%)
42 DECLARE FUNCTION Cvdt$ (X#)
43 DECLARE FUNCTION Cvst$ (X!)
44 DECLARE FUNCTION Cvit$ (X%)
45 DECLARE FUNCTION Menu% (CurrChoiceX%, MaxChoice%, choice$(), ItemRow%(), ItemCol%(), help$(), BarMode%)
46 DECLARE FUNCTION GetString$ (row%, col%, start$, end$, Vis%, Max%)
47 DECLARE FUNCTION Trim$ (X$)
51 CONST FALSE = NOT TRUE
69 DIM SHARED account(1 TO 19) AS AccountType 'Stores the 19 account titles
70 DIM SHARED ColorPref 'Color Preference
71 DIM SHARED colors(0 TO 20, 1 TO 4) 'Different Colors
72 DIM SHARED ScrollUpAsm(1 TO 7) 'Assembly Language Routines
73 DIM SHARED ScrollDownAsm(1 TO 7)
74 DIM SHARED PrintErr AS INTEGER 'Printer error flag
76 DEF SEG = 0 ' Turn off CapLock, NumLock and ScrollLock
81 'Open money manager data file. If it does not exist in current directory,
82 ' goto error handler to create and initialize it.
83 ON ERROR GOTO ErrorTrap
84 OPEN "money.dat" FOR INPUT AS #1
86 ON ERROR GOTO 0 'Reset error handler
88 Initialize 'Initialize program
89 Intro 'Display introduction screen
90 MenuSystem 'This is the main program
91 COLOR 7, 0 'Clear screen and end
94 DEF SEG = 0 ' Restore CapLock, NumLock and ScrollLock states
100 ' Error handler for program
101 ' If data file not found, create and initialize a new one.
104 ' If data file not found, create and initialize a new one.
109 account(a).Title = ""
110 account(a).AType = ""
118 Center 11, "Printer not responding ... Press Space to continue"
119 WHILE INKEY$ <> "": WEND
120 WHILE INKEY$ <> " ": WEND
127 'The following data defines the color schemes available via the main menu.
129 ' scrn dots bar back title shdow choice curs cursbk shdow
130 DATA 0, 7, 15, 7, 0, 7, 0, 15, 0, 0
131 DATA 1, 9, 12, 3, 0, 1, 15, 0, 7, 0
132 DATA 3, 15, 13, 1, 14, 3, 15, 0, 7, 0
133 DATA 7, 12, 15, 4, 14, 0, 15, 15, 1, 0
135 'The following data is actually a machine language program to
136 'scroll the screen up or down very fast using a BIOS call.
137 DATA &HB8,&H01,&H06,&HB9,&H01,&H04,&HBA,&H4E,&H16,&HB7,&H00,&HCD,&H10,&HCB
138 DATA &HB8,&H01,&H07,&HB9,&H01,&H04,&HBA,&H4E,&H16,&HB7,&H00,&HCD,&H10,&HCB
141 ' Draw a box on the screen between the given coordinates.
142 SUB Box (Row1, Col1, Row2, Col2) STATIC
144 BoxWidth = Col2 - Col1 + 1
147 PRINT "Ú"; STRING$(BoxWidth - 2, "Ä"); "¿";
149 FOR a = Row1 + 1 TO Row2 - 1
151 PRINT "³"; SPACE$(BoxWidth - 2); "³";
155 PRINT "À"; STRING$(BoxWidth - 2, "Ä"); "Ù";
160 ' Center text on the given row.
161 SUB Center (row, text$)
162 LOCATE row, 41 - LEN(text$) / 2
167 ' Convert a double precision number to a string WITHOUT a leading space.
170 Cvdt$ = RIGHT$(STR$(X#), LEN(STR$(X#)) - 1)
175 ' Convert an integer to a string WITHOUT a leading space.
177 Cvit$ = RIGHT$(STR$(X), LEN(STR$(X)) - 1)
181 ' Convert a single precision number to a string WITHOUT a leading space
183 Cvst$ = RIGHT$(STR$(X!), LEN(STR$(X!)) - 1)
187 ' This is the full-screen editor which allows you to change your account
188 ' titles and descriptions
191 'Information about each column
192 REDIM help$(4), col(4), Vis(4), Max(4), edit$(19, 3)
195 COLOR colors(7, ColorPref), colors(4, ColorPref)
198 COLOR colors(5, ColorPref), colors(4, ColorPref)
199 LOCATE 1, 1: PRINT SPACE$(80)
200 LOCATE 1, 4: PRINT "Account Editor";
201 COLOR colors(7, ColorPref), colors(4, ColorPref)
203 LOCATE 3, 2: PRINT "No³ Account Title ³ Description ³A/L"
204 LOCATE 4, 2: PRINT "ÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄ"
205 u$ = "##³\ \³\ \³ ! "
209 PRINT USING u$; X; account(X).Title; account(X).Desc; account(X).AType;
212 'Initialize variables
213 help$(1) = " Account name | <F2=Save and Exit> <Escape=Abort>"
214 help$(2) = " Account description | <F2=Save and Exit> <Escape=Abort>"
215 help$(3) = " Account type (A = Asset, L = Liability) | <F2=Save and Exit> <Escape=Abort>"
217 col(1) = 5: col(2) = 26: col(3) = 78
218 Vis(1) = 20: Vis(2) = 50: Vis(3) = 1
219 Max(1) = 20: Max(2) = 50: Max(3) = 1
222 edit$(a, 1) = account(a).Title
223 edit$(a, 2) = account(a).Desc
224 edit$(a, 3) = account(a).AType
231 PrintHelpLine help$(CurrCol)
233 'Loop until F2 or <ESC> is pressed
235 GOSUB EditAccountsShowCursor 'Show Cursor
238 LOOP UNTIL Kbd$ <> ""
240 IF Kbd$ >= " " AND Kbd$ < "~" THEN 'If legal, edit item
241 GOSUB EditAccountsEditItem
243 GOSUB EditAccountsHideCursor 'Hide Cursor so it can move
246 CASE CHR$(0) + "H" 'Up Arrow
247 CurrRow = (CurrRow + 17) MOD 19 + 1
248 CASE CHR$(0) + "P" 'Down Arrow
249 CurrRow = (CurrRow) MOD 19 + 1
250 CASE CHR$(0) + "K", CHR$(0) + CHR$(15) 'Left or Shift+Tab
251 CurrCol = (CurrCol + 1) MOD 3 + 1
252 PrintHelpLine help$(CurrCol)
253 CASE CHR$(0) + "M", CHR$(9) 'Right or Tab
254 CurrCol = (CurrCol) MOD 3 + 1
255 PrintHelpLine help$(CurrCol)
256 CASE CHR$(0) + "<" 'F2
262 CASE CHR$(13) 'Return
269 GOSUB EditAccountsSaveData
274 EditAccountsShowCursor:
275 COLOR colors(8, ColorPref), colors(9, ColorPref)
276 LOCATE CurrRow + 4, col(CurrCol)
277 PRINT LEFT$(edit$(CurrRow, CurrCol), Vis(CurrCol));
280 EditAccountsEditItem:
281 COLOR colors(8, ColorPref), colors(9, ColorPref)
285 Kbd$ = GetString$(CurrRow + 4, col(CurrCol), start$, end$, Vis(CurrCol), Max(CurrCol))
286 edit$(CurrRow, CurrCol) = LEFT$(end$ + SPACE$(Max(CurrCol)), Max(CurrCol))
291 IF X$ = "A" OR X$ = "L" OR X$ = "" OR X$ = " " THEN
293 IF X$ = "" THEN X$ = " "
294 edit$(CurrRow, CurrCol) = X$
305 EditAccountsHideCursor:
306 COLOR colors(7, ColorPref), colors(4, ColorPref)
307 LOCATE CurrRow + 4, col(CurrCol)
308 PRINT LEFT$(edit$(CurrRow, CurrCol), Vis(CurrCol));
312 EditAccountsSaveData:
314 account(a).Title = edit$(a, 1)
315 account(a).Desc = edit$(a, 2)
316 account(a).AType = edit$(a, 3)
324 ' This is the full-screen editor which allows you to enter and change
328 'Stores info about each column
329 REDIM help$(6), col(6), Vis(6), Max(6), CurrString$(3), CurrFig#(5)
330 'Array to keep the current balance at all the transactions
333 'Open random access file
334 file$ = "money." + Cvit$(item)
335 OPEN file$ FOR RANDOM AS #1 LEN = 84
336 FIELD #1, 8 AS IoDate$, 10 AS IoRef$, 50 AS IoDesc$, 8 AS IoFig1$, 8 AS IoFig2$
337 FIELD #1, 11 AS valid$, 5 AS IoMaxRecord$, 8 AS IoBalance$
339 'Initialize variables
347 IF valid$ <> "THISISVALID" THEN
351 LSET IoFig1$ = MKD$(0)
352 LSET IoFig2$ = MKD$(0)
354 LSET valid$ = "THISISVALID"
355 LSET IoMaxRecord$ = "1"
356 LSET IoBalance$ = MKD$(0)
360 MaxRecord = VAL(IoMaxRecord$)
366 Balance#(a) = Balance#(a - 1) + CVD(IoFig1$) - CVD(IoFig2$)
369 GOSUB EditTransWriteBalance
371 help$(1) = "Date of transaction (mm/dd/yy) "
372 help$(2) = "Transaction reference number "
373 help$(3) = "Transaction description "
374 help$(4) = "Increase asset or debt value "
375 help$(5) = "Decrease asset or debt value "
397 COLOR colors(7, ColorPref), colors(4, ColorPref)
400 COLOR colors(5, ColorPref), colors(4, ColorPref)
401 LOCATE 1, 1: PRINT SPACE$(80);
402 LOCATE 1, 4: PRINT "Transaction Editor: " + Trim$(account(item).Title);
404 COLOR colors(7, ColorPref), colors(4, ColorPref)
405 LOCATE 3, 2: PRINT " Date ³ Ref# ³ Description ³ Increase ³ Decrease ³ Balance "
406 LOCATE 4, 2: PRINT "ÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄ"
410 u1x$ = "ßßßßßßßß³ßßßßßß³ßßßßßßßßßßßßßßßßßßßßßßßßß³ßßßßßßßßßß³ßßßßßßßßßß³ßßßßßßßßßßßßßß"
412 u3$ = "###,###,###.##"
416 GOSUB EditTransPrintWholeScreen
420 PrintHelpLine help$(CurrCol) + "| <F2=Save and Exit> <F9=Insert> <F10=Delete>"
422 GOSUB EditTransGetLine
427 'Loop until <F2> is pressed
429 GOSUB EditTransShowCursor 'Show Cursor, Wait for key
430 DO: Kbd$ = INKEY$: LOOP UNTIL Kbd$ <> ""
431 GOSUB EditTransHideCursor
433 IF Kbd$ >= " " AND Kbd$ < "~" OR Kbd$ = CHR$(8) THEN 'If legal key, edit item
434 GOSUB EditTransEditItem
437 SELECT CASE Kbd$ 'Handle Special keys
438 CASE CHR$(0) + "H" 'up arrow
439 GOSUB EditTransMoveUp
440 CASE CHR$(0) + "P" 'Down arrow
441 GOSUB EditTransMoveDown
442 CASE CHR$(0) + "K", CHR$(0) + CHR$(15) 'Left Arrow,BackTab
443 CurrCol = (CurrCol + 3) MOD 5 + 1
444 PrintHelpLine help$(CurrCol) + "| <F2=Save and Exit> <F9=Insert> <F10=Delete>"
445 CASE CHR$(0) + "M", CHR$(9) 'Right Arrow,Tab
446 CurrCol = (CurrCol) MOD 5 + 1
447 PrintHelpLine help$(CurrCol) + "| <F2=Save and Exit> <F9=Insert> <F10=Delete>"
448 CASE CHR$(0) + "G" 'Home
450 CASE CHR$(0) + "O" 'End
452 CASE CHR$(0) + "I" 'Page Up
454 CurrTopline = CurrTopline - 19
455 IF CurrTopline < 1 THEN
458 GOSUB EditTransPrintWholeScreen
459 GOSUB EditTransGetLine
460 CASE CHR$(0) + "Q" 'Page Down
462 CurrTopline = CurrTopline + 19
463 IF CurrTopline > MaxRecord THEN
464 CurrTopline = MaxRecord
466 GOSUB EditTransPrintWholeScreen
467 GOSUB EditTransGetLine
468 CASE CHR$(0) + "<" 'F2
470 CASE CHR$(0) + "C" 'F9
471 GOSUB EditTransAddRecord
472 CASE CHR$(0) + "D" 'F10
473 GOSUB EditTransDeleteRecord
486 COLOR colors(8, ColorPref), colors(9, ColorPref)
487 LOCATE CurrRow + 4, col(CurrCol)
490 PRINT LEFT$(CurrString$(CurrCol), Vis(CurrCol));
492 IF CurrFig#(4) <> 0 THEN
493 PRINT USING u2$; CurrFig#(4);
495 PRINT SPACE$(Vis(CurrCol));
498 IF CurrFig#(5) <> 0 THEN
499 PRINT USING u2$; CurrFig#(5);
501 PRINT SPACE$(Vis(CurrCol));
508 COLOR colors(7, ColorPref), colors(4, ColorPref)
509 LOCATE CurrRow + 4, col(CurrCol)
512 PRINT LEFT$(CurrString$(CurrCol), Vis(CurrCol));
514 IF CurrFig#(4) <> 0 THEN
515 PRINT USING u2$; CurrFig#(4);
517 PRINT SPACE$(Vis(CurrCol));
520 IF CurrFig#(5) <> 0 THEN
521 PRINT USING u2$; CurrFig#(5);
523 PRINT SPACE$(Vis(CurrCol));
531 CurrRecord = CurrTopline + CurrRow - 1
532 COLOR colors(8, ColorPref), colors(9, ColorPref)
536 Kbd$ = GetString$(CurrRow + 4, col(CurrCol), Kbd$, new$, Vis(CurrCol), Max(CurrCol))
537 CurrString$(CurrCol) = new$
538 GOSUB EditTransPutLine
539 GOSUB EditTransGetLine
543 Kbd$ = GetString$(CurrRow + 4, col(4), start$, new$, Vis(4), Max(4))
546 LOOP WHILE new4# >= 999999.99# OR new4# < 0
550 Balance#(a) = Balance#(a) + new4# - CurrFig#(4) + CurrFig#(5)
555 GOSUB EditTransPutLine
556 GOSUB EditTransGetLine
557 GOSUB EditTransPrintBalances
558 GOSUB EditTransWriteBalance
562 Kbd$ = GetString$(CurrRow + 4, col(5), start$, new$, Vis(5), Max(5))
565 LOOP WHILE new5# >= 999999.99# OR new5# < 0
569 Balance#(a) = Balance#(a) - new5# + CurrFig#(5) - CurrFig#(4)
574 GOSUB EditTransPutLine
575 GOSUB EditTransGetLine
576 GOSUB EditTransPrintBalances
577 GOSUB EditTransWriteBalance
580 GOSUB EditTransPrintLine
585 IF CurrTopline = 1 THEN
589 CurrTopline = CurrTopline - 1
590 GOSUB EditTransGetLine
591 GOSUB EditTransPrintLine
594 CurrRow = CurrRow - 1
595 GOSUB EditTransGetLine
600 IF (CurrRow + CurrTopline - 1) >= MaxRecord THEN
605 CurrTopline = CurrTopline + 1
606 GOSUB EditTransGetLine
607 GOSUB EditTransPrintLine
609 CurrRow = CurrRow + 1
610 GOSUB EditTransGetLine
616 COLOR colors(7, ColorPref), colors(4, ColorPref)
617 CurrRecord = CurrTopline + CurrRow - 1
618 LOCATE CurrRow + 4, 2
619 IF CurrRecord = MaxRecord + 1 THEN
621 ELSEIF CurrRecord > MaxRecord THEN
624 PRINT USING u$; CurrString$(1); CurrString$(2); CurrString$(3);
625 IF CurrFig#(4) = 0 AND CurrFig#(5) = 0 THEN
626 PRINT USING u4$ + "³" + u4$ + "³" + u3$; Balance#(CurrRecord)
627 ELSEIF CurrFig#(5) = 0 THEN
628 PRINT USING u2$ + "³" + u4$ + "³" + u3$; CurrFig#(4); Balance#(CurrRecord)
630 PRINT USING u4$ + "³" + u2$ + "³" + u3$; CurrFig#(5); Balance#(CurrRecord)
635 EditTransPrintBalances:
636 COLOR colors(7, ColorPref), colors(4, ColorPref)
638 CurrRecord = CurrTopline + a - 1
639 IF CurrRecord <= MaxRecord THEN
641 PRINT USING u3$; Balance#(CurrTopline + a - 1);
646 EditTransDeleteRecord:
647 IF MaxRecord = 1 THEN
650 CurrRecord = CurrTopline + CurrRow - 1
651 MaxRecord = MaxRecord - 1
656 Balance#(a) = Balance#(a + 1) - CurrFig#(4) + CurrFig#(5)
660 LSET valid$ = "THISISVALID"
661 LSET IoMaxRecord$ = Cvit$(MaxRecord)
663 GOSUB EditTransPrintWholeScreen
664 CurrRecord = CurrTopline + CurrRow - 1
665 IF CurrRecord > MaxRecord THEN
666 GOSUB EditTransMoveUp
668 GOSUB EditTransGetLine
669 GOSUB EditTransWriteBalance
674 CurrRecord = CurrTopline + CurrRow - 1
679 Balance#(a + 1) = Balance#(a)
682 Balance#(CurrRecord + 1) = Balance#(CurrRecord)
683 MaxRecord = MaxRecord + 1
687 LSET IoFig1$ = MKD$(0)
688 LSET IoFig2$ = MKD$(0)
689 PUT #1, CurrRecord + 2
691 LSET valid$ = "THISISVALID"
692 LSET IoMaxRecord$ = Cvit$(MaxRecord)
694 GOSUB EditTransPrintWholeScreen
695 GOSUB EditTransGetLine
698 EditTransPrintWholeScreen:
700 FOR CurrRow = 1 TO 19
701 CurrRecord = CurrTopline + CurrRow - 1
702 IF CurrRecord <= MaxRecord THEN
703 GOSUB EditTransGetLine
705 GOSUB EditTransPrintLine
710 EditTransWriteBalance:
712 LSET IoBalance$ = MKD$(Balance#(MaxRecord))
717 CurrRecord = CurrTopline + CurrRow - 1
718 LSET IoDate$ = CurrString$(1)
719 LSET IoRef$ = CurrString$(2)
720 LSET IoDesc$ = CurrString$(3)
721 LSET IoFig1$ = MKD$(CurrFig#(4))
722 LSET IoFig2$ = MKD$(CurrFig#(5))
723 PUT #1, CurrRecord + 1
727 CurrRecord = CurrTopline + CurrRow - 1
728 GET #1, CurrRecord + 1
729 CurrString$(1) = IoDate$
730 CurrString$(2) = IoRef$
731 CurrString$(3) = IoDesc$
732 CurrFig#(4) = CVD(IoFig1$)
733 CurrFig#(5) = CVD(IoFig2$)
738 ' Clears screen in the right color, and draws nice dots.
739 SUB FancyCls (dots, Background)
742 COLOR dots, Background
745 FOR a = 95 TO 1820 STEP 45
757 ' Given a row and col, and an initial string, edit a string
758 ' VIS is the length of the visible field of entry
759 ' MAX is the maximum number of characters allowed in the string
760 FUNCTION GetString$ (row, col, start$, end$, Vis, Max)
761 curr$ = Trim$(LEFT$(start$, Max))
762 IF curr$ = CHR$(8) THEN curr$ = ""
768 GOSUB GetStringShowText
769 GOSUB GetStringGetKey
771 IF LEN(Kbd$) > 1 THEN
776 CASE CHR$(13), CHR$(27), CHR$(9)
782 curr$ = LEFT$(curr$, LEN(curr$) - 1)
786 IF LEN(curr$) < Max THEN
806 IF LEN(curr$) > Vis THEN
807 PRINT RIGHT$(curr$, Vis);
809 PRINT curr$; SPACE$(Vis - LEN(curr$));
810 LOCATE row, col + LEN(curr$)
823 ' Read colors in and set up assembly routines
829 FOR ColorSet = 1 TO 4
831 READ colors(X, ColorSet)
837 P = VARPTR(ScrollUpAsm(1))
838 DEF SEG = VARSEG(ScrollUpAsm(1))
844 P = VARPTR(ScrollDownAsm(1))
845 DEF SEG = VARSEG(ScrollDownAsm(1))
856 ' Display introduction screen.
863 Center 4, "Q B a s i c"
865 Center 5, "Ü Ü ÜÜÜÜ Ü Ü ÜÜÜÜ Ü Ü Ü Ü ÜÜÜÜ Ü Ü ÜÜÜÜ ÜÜÜÜÜ ÜÜÜÜ ÜÜÜÜÜ"
866 Center 6, "ÛßÜ ÜßÛ Û Û ÛÜ Û Û ÛÜÜÜÛ ÛßÜ ÜßÛ Û Û ÛÜ Û Û Û Û Û Û Û"
867 Center 7, "Û ß Û Û Û Û ßÜÛ Ûßßß Û Û ß Û ÛßßÛ Û ßÜÛ ÛßßÛ Û ßßÛ Ûßßß ÛßÛßß"
868 Center 8, "Û Û ÛÜÜÛ Û Û ÛÜÜÜ Û Û Û Û Û Û Û Û Û ÛÜÜÜÛ ÛÜÜÜ Û ßÜ"
870 Center 11, "A Personal Finance Manager written in"
871 Center 12, "MS-DOS QBasic"
872 Center 24, "Press any key to continue"
878 ' Center TEXT$ on the line printer
880 LPRINT TAB(41 - LEN(text$) / 2); text$
884 ' Load color preferences and account info from MONEY.DAT
887 OPEN "money.dat" FOR INPUT AS #1
891 LINE INPUT #1, account(a).Title
892 LINE INPUT #1, account(a).AType
893 LINE INPUT #1, account(a).Desc
901 ' Handles Menu Selection for a single menu (either sub menu, or menu bar)
902 ' currChoiceX : Number of current choice
903 ' maxChoice : Number of choices in the list
904 ' choice$() : Array with the text of the choices
905 ' itemRow() : Array with the row of the choices
906 ' itemCol() : Array with the col of the choices
907 ' help$() : Array with the help text for each choice
908 ' barMode : Boolean: TRUE = menu bar style, FALSE = drop down style
910 ' Returns the number of the choice that was made by changing currChoiceX
911 ' and returns the scan code of the key that was pressed to exit
913 FUNCTION Menu (CurrChoiceX, MaxChoice, choice$(), ItemRow(), ItemCol(), help$(), BarMode)
915 currChoice = CurrChoiceX
917 'if in bar mode, color in menu bar, else color box/shadow
918 'bar mode means you are currently in the menu bar, not a sub menu
920 COLOR colors(7, ColorPref), colors(4, ColorPref)
924 FancyCls colors(2, ColorPref), colors(1, ColorPref)
925 COLOR colors(7, ColorPref), colors(4, ColorPref)
926 Box ItemRow(1) - 1, ItemCol(1) - 1, ItemRow(MaxChoice) + 1, ItemCol(1) + LEN(choice$(1)) + 1
928 COLOR colors(10, ColorPref), colors(6, ColorPref)
929 FOR a = 1 TO MaxChoice + 1
930 LOCATE ItemRow(1) + a - 1, ItemCol(1) + LEN(choice$(1)) + 2
931 PRINT CHR$(178); CHR$(178);
933 LOCATE ItemRow(MaxChoice) + 2, ItemCol(MaxChoice) + 2
934 PRINT STRING$(LEN(choice$(MaxChoice)) + 2, 178);
938 COLOR colors(7, ColorPref), colors(4, ColorPref)
939 FOR a = 1 TO MaxChoice
940 LOCATE ItemRow(a), ItemCol(a)
953 CASE CHR$(0) + "H": GOSUB MenuUp
954 CASE CHR$(0) + "P": GOSUB MenuDown
955 CASE CHR$(0) + "K": GOSUB MenuLeft
956 CASE CHR$(0) + "M": GOSUB MenuRight
957 CASE CHR$(13): GOSUB MenuEnter
958 CASE CHR$(27): GOSUB MenuEscape
981 currChoice = (currChoice + MaxChoice - 2) MOD MaxChoice + 1
987 currChoice = (currChoice + MaxChoice - 2) MOD MaxChoice + 1
996 currChoice = (currChoice) MOD MaxChoice + 1
1007 currChoice = (currChoice) MOD MaxChoice + 1
1012 COLOR colors(8, ColorPref), colors(9, ColorPref)
1013 LOCATE ItemRow(currChoice), ItemCol(currChoice)
1014 PRINT choice$(currChoice);
1015 PrintHelpLine help$(currChoice)
1026 COLOR colors(7, ColorPref), colors(4, ColorPref)
1027 LOCATE ItemRow(currChoice), ItemCol(currChoice)
1028 PRINT choice$(currChoice);
1035 ' Main routine that controls the program. Uses the MENU function
1036 ' to implement menu system and calls the appropriate function to handle
1037 ' the user's selection
1040 DIM choice$(20), menuRow(20), menuCol(20), help$(20)
1046 GOSUB MenuSystemMain
1051 CASE 1: GOSUB MenuSystemFile
1052 CASE 2: GOSUB MenuSystemEdit
1053 CASE 3: GOSUB MenuSystemAccount
1054 CASE 4: GOSUB MenuSystemReport
1055 CASE 5: GOSUB MenuSystemColors
1057 FancyCls colors(2, ColorPref), colors(1, ColorPref)
1059 SELECT CASE subchoice
1060 CASE -2: choice = (choice + 3) MOD 5 + 1
1061 CASE -3: choice = (choice) MOD 5 + 1
1069 FancyCls colors(2, ColorPref), colors(1, ColorPref)
1070 COLOR colors(7, ColorPref), colors(4, ColorPref)
1072 Center 11, "Use arrow keys to navigate menu system"
1073 Center 12, "Press Enter to select a menu item"
1075 choice$(1) = " File "
1076 choice$(2) = " Accounts "
1077 choice$(3) = " Transactions "
1078 choice$(4) = " Reports "
1079 choice$(5) = " Colors "
1081 menuRow(1) = 1: menuCol(1) = 2
1082 menuRow(2) = 1: menuCol(2) = 8
1083 menuRow(3) = 1: menuCol(3) = 18
1084 menuRow(4) = 1: menuCol(4) = 32
1085 menuRow(5) = 1: menuCol(5) = 41
1087 help$(1) = "Exit the Money Manager"
1088 help$(2) = "Add/edit/delete accounts"
1089 help$(3) = "Add/edit/delete account transactions"
1090 help$(4) = "View and print reports"
1091 help$(5) = "Set screen colors"
1094 NewChoice = Menu((choice), 5, choice$(), menuRow(), menuCol(), help$(), TRUE)
1095 LOOP WHILE NewChoice = 0
1100 choice$(1) = " Exit "
1102 menuRow(1) = 3: menuCol(1) = 2
1104 help$(1) = "Exit the Money Manager"
1106 subchoice = Menu(1, 1, choice$(), menuRow(), menuCol(), help$(), FALSE)
1108 SELECT CASE subchoice
1109 CASE 1: finished = TRUE
1116 choice$(1) = " Edit Account Titles "
1118 menuRow(1) = 3: menuCol(1) = 8
1120 help$(1) = "Add/edit/delete accounts"
1122 subchoice = Menu(1, 1, choice$(), menuRow(), menuCol(), help$(), FALSE)
1124 SELECT CASE subchoice
1125 CASE 1: EditAccounts
1134 IF Trim$(account(a).Title) = "" THEN
1135 choice$(a) = RIGHT$(STR$(a), 2) + ". ------------------- "
1137 choice$(a) = RIGHT$(STR$(a), 2) + ". " + account(a).Title
1141 help$(a) = RTRIM$(account(a).Desc)
1144 subchoice = Menu(1, 19, choice$(), menuRow(), menuCol(), help$(), FALSE)
1146 IF subchoice > 0 THEN
1147 EditTrans (subchoice)
1153 choice$(1) = " Net Worth Report "
1154 menuRow(1) = 3: menuCol(1) = 32
1155 help$(1) = "View and print net worth report"
1158 IF Trim$(account(a).Title) = "" THEN
1159 choice$(a + 1) = RIGHT$(STR$(a), 2) + ". ------------------- "
1161 choice$(a + 1) = RIGHT$(STR$(a), 2) + ". " + account(a).Title
1163 menuRow(a + 1) = a + 3
1165 help$(a + 1) = "Print " + RTRIM$(account(a).Title) + " transaction summary"
1168 subchoice = Menu(1, 20, choice$(), menuRow(), menuCol(), help$(), FALSE)
1170 SELECT CASE subchoice
1174 TransactionSummary (subchoice - 1)
1180 choice$(1) = " Monochrome Scheme "
1181 choice$(2) = " Cyan/Blue Scheme "
1182 choice$(3) = " Blue/Cyan Scheme "
1183 choice$(4) = " Red/Grey Scheme "
1185 menuRow(1) = 3: menuCol(1) = 41
1186 menuRow(2) = 4: menuCol(2) = 41
1187 menuRow(3) = 5: menuCol(3) = 41
1188 menuRow(4) = 6: menuCol(4) = 41
1190 help$(1) = "Color scheme for monochrome and LCD displays"
1191 help$(2) = "Color scheme featuring cyan"
1192 help$(3) = "Color scheme featuring blue"
1193 help$(4) = "Color scheme featuring red"
1195 subchoice = Menu(1, 4, choice$(), menuRow(), menuCol(), help$(), FALSE)
1197 SELECT CASE subchoice
1199 ColorPref = subchoice
1209 ' Prints net worth report to screen and printer
1211 DIM assetIndex(19), liabilityIndex(19)
1217 IF account(a).AType = "A" THEN
1218 maxAsset = maxAsset + 1
1219 assetIndex(maxAsset) = a
1220 ELSEIF account(a).AType = "L" THEN
1221 maxLiability = maxLiability + 1
1222 liabilityIndex(maxLiability) = a
1226 'Loop until <F2> is pressed
1229 u1$ = "\ \$$###,###,###.##"
1230 u2$ = "\ \+$$#,###,###,###.##"
1232 COLOR colors(5, ColorPref), colors(4, ColorPref)
1233 LOCATE 1, 1: PRINT SPACE$(80);
1234 LOCATE 1, 4: PRINT "Net Worth Report: " + DATE$;
1235 PrintHelpLine "<F2=Exit> <F3=Print Report>"
1237 COLOR colors(7, ColorPref), colors(4, ColorPref)
1241 LOCATE 2, 16: PRINT " ASSETS "
1246 file$ = "money." + Cvit$(assetIndex(a))
1247 OPEN file$ FOR RANDOM AS #1 LEN = 84
1248 FIELD #1, 11 AS valid$, 5 AS IoMaxRecord$, 8 AS IoBalance$
1250 IF valid$ = "THISISVALID" THEN
1251 LOCATE 2 + count1, 3: PRINT USING u1$; account(assetIndex(a)).Title; CVD(IoBalance$)
1252 assetTotal# = assetTotal# + CVD(IoBalance$)
1259 LOCATE 2, 55: PRINT " LIABILITIES "
1263 WHILE a <= maxLiability
1264 file$ = "money." + Cvit$(liabilityIndex(a))
1265 OPEN file$ FOR RANDOM AS #1 LEN = 84
1266 FIELD #1, 11 AS valid$, 5 AS IoMaxRecord$, 8 AS IoBalance$
1268 IF valid$ = "THISISVALID" THEN
1269 LOCATE 2 + count2, 43: PRINT USING u1$; account(liabilityIndex(a)).Title; CVD(IoBalance$)
1270 liabilityTotal# = liabilityTotal# + CVD(IoBalance$)
1276 IF count2 > count1 THEN count1 = count2
1277 LOCATE 2 + count1, 25: PRINT "--------------"
1278 LOCATE 2 + count1, 65: PRINT "--------------"
1279 LOCATE 3 + count1, 3: PRINT USING u2$; "Total assets"; assetTotal#;
1280 LOCATE 3 + count1, 43: PRINT USING u2$; "Total liabilities"; liabilityTotal#
1282 COLOR colors(5, ColorPref), colors(4, ColorPref)
1283 LOCATE 1, 43: PRINT USING u2$; " NET WORTH:"; assetTotal# - liabilityTotal#
1285 DO: Kbd$ = INKEY$: LOOP UNTIL Kbd$ <> ""
1287 SELECT CASE Kbd$ 'Handle Special keys
1288 CASE CHR$(0) + "<" 'F2
1290 CASE CHR$(0) + "=" 'F3
1291 GOSUB NetWorthReportPrint
1298 NetWorthReportPrint:
1302 Center 10, "Prepare printer on LPT1 for report"
1303 Center 12, "Hit <Enter> to print, or <Esc> to abort"
1305 DO: Kbd$ = INKEY$: LOOP WHILE Kbd$ <> CHR$(13) AND Kbd$ <> CHR$(27)
1307 IF Kbd$ = CHR$(13) THEN
1309 Center 11, "Printing report..."
1311 u1$ = " \ \ $$###,###,###.##"
1312 u2$ = " --------------"
1313 u3$ = " ============="
1314 u4$ = " \ \+$$#,###,###,###.##"
1316 ON ERROR GOTO ErrorTrap ' test if printer is connected
1318 IF PrintErr = FALSE THEN
1319 LPRINT : LPRINT : LPRINT : LPRINT : LPRINT
1320 LCenter "Q B a s i c"
1321 LCenter "M O N E Y M A N A G E R"
1323 LCenter "NET WORTH REPORT: " + DATE$
1324 LCenter "-------------------------------------------"
1325 LPRINT USING u0$; "ASSETS:"
1329 file$ = "money." + Cvit$(assetIndex(a))
1330 OPEN file$ FOR RANDOM AS #1 LEN = 84
1331 FIELD #1, 11 AS valid$, 5 AS IoMaxRecord$, 8 AS IoBalance$
1333 IF valid$ = "THISISVALID" THEN
1334 LPRINT USING u1$; account(assetIndex(a)).Title; CVD(IoBalance$)
1335 assetTotal# = assetTotal# + CVD(IoBalance$)
1341 LPRINT USING u4$; "Total assets"; assetTotal#
1344 LPRINT USING u0$; "LIABILITIES:"
1347 WHILE a <= maxLiability
1348 file$ = "money." + Cvit$(liabilityIndex(a))
1349 OPEN file$ FOR RANDOM AS #1 LEN = 84
1350 FIELD #1, 11 AS valid$, 5 AS IoMaxRecord$, 8 AS IoBalance$
1352 IF valid$ = "THISISVALID" THEN
1353 LPRINT USING u1$; account(liabilityIndex(a)).Title; CVD(IoBalance$)
1354 liabilityTotal# = liabilityTotal# + CVD(IoBalance$)
1360 LPRINT USING u4$; "Total liabilities"; liabilityTotal#
1365 LPRINT USING u4$; "NET WORTH"; assetTotal# - liabilityTotal#
1366 LCenter "-------------------------------------------"
1367 LPRINT : LPRINT : LPRINT
1375 ' Prints help text on the bottom row in the proper color
1376 SUB PrintHelpLine (help$)
1377 COLOR colors(5, ColorPref), colors(4, ColorPref)
1384 ' Save color preference and account information to "MONEY.DAT" data file.
1386 OPEN "money.dat" FOR OUTPUT AS #2
1390 PRINT #2, account(a).Title
1391 PRINT #2, account(a).AType
1392 PRINT #2, account(a).Desc
1399 ' Call the assembly program to scroll the screen down
1401 DEF SEG = VARSEG(ScrollDownAsm(1))
1402 CALL Absolute(VARPTR(ScrollDownAsm(1)))
1407 ' Calls the assembly program to scroll the screen up
1409 DEF SEG = VARSEG(ScrollUpAsm(1))
1410 CALL Absolute(VARPTR(ScrollUpAsm(1)))
1415 ' Creates flashing border for intro screen
1419 a$ = "* * * * * * * * * * * * * * * * * "
1420 WHILE INKEY$ <> "": WEND 'Clear keyboard buffer
1424 LOCATE 1, 1 'print horizontal sparkles
1425 PRINT MID$(a$, a, 80);
1427 PRINT MID$(a$, 6 - a, 80);
1429 FOR b = 2 TO 21 'Print Vertical sparkles
1447 'TransactionSummary:
1448 ' Print transaction summary to line printer
1449 SUB TransactionSummary (item)
1450 FancyCls colors(2, ColorPref), colors(1, ColorPref)
1453 Center 10, "Prepare printer on LPT1 for report"
1454 Center 12, "Hit <Enter> to print, or <Esc> to abort"
1456 DO: Kbd$ = INKEY$: LOOP WHILE Kbd$ <> CHR$(13) AND Kbd$ <> CHR$(27)
1458 IF Kbd$ = CHR$(13) THEN
1460 Center 11, "Printing report..."
1462 ON ERROR GOTO ErrorTrap ' test if printer is connected
1464 IF PrintErr = FALSE THEN
1466 LPRINT : LPRINT : LPRINT : LPRINT : LPRINT
1467 LCenter "Q B a s i c"
1468 LCenter "M O N E Y M A N A G E R"
1470 LCenter "Transaction summary: " + Trim$(account(item).Title)
1473 u5$ = "--------|------|------------------------|----------|----------|--------------"
1475 LPRINT " Date | Ref# | Description | Increase | Decrease | Balance "
1477 u0$ = "\ \|\ \|\ \|"
1479 u3$ = "###,###,###.##"
1482 file$ = "money." + Cvit$(item)
1483 OPEN file$ FOR RANDOM AS #1 LEN = 84
1484 FIELD #1, 8 AS IoDate$, 10 AS IoRef$, 50 AS IoDesc$, 8 AS IoFig1$, 8 AS IoFig2$
1485 FIELD #1, 11 AS valid$, 5 AS IoMaxRecord$, 8 AS IoBalance$
1487 IF valid$ = "THISISVALID" THEN
1489 MaxRecord = VAL(IoMaxRecord$)
1491 WHILE CurrRecord <= MaxRecord
1493 GET #1, CurrRecord + 1
1494 Fig1# = CVD(IoFig1$)
1495 Fig2# = CVD(IoFig2$)
1497 LPRINT USING u0$; IoDate$; IoRef$; IoDesc$;
1498 IF Fig2# = 0 AND Fig1# = 0 THEN
1499 LPRINT USING u4$ + "|" + u4$ + "|" + u3$; Balance#
1500 ELSEIF Fig2# = 0 THEN
1501 Balance# = Balance# + Fig1#
1502 LPRINT USING u2$ + "|" + u4$ + "|" + u3$; Fig1#; Balance#
1504 Balance# = Balance# - Fig2#
1505 LPRINT USING u4$ + "|" + u2$ + "|" + u3$; Fig2#; Balance#
1507 CurrRecord = CurrRecord + 1
1519 ' Remove null and spaces from the end of a string.
1526 FOR a = 1 TO LEN(X$)
1528 IF y$ <> CHR$(0) AND y$ <> " " THEN
1532 Trim$ = LEFT$(X$, lastChar)