Exclusive mode seems to work without deadlocks
[mirrors/Programs.git] / turbobasic / 1998 / 3RD-PA.RTY / QBASIC / MONEY.BAS
CommitLineData
0f95cc4b
H
1'\r
2' Q B a s i c M O N E Y M A N A G E R\r
3'\r
4' Copyright (C) Microsoft Corporation 1990\r
5'\r
6' The Money Manager is a personal finance manager that allows you\r
7' to enter account transactions while tracking your account balances\r
8' and net worth.\r
9'\r
10' To run this program, press Shift+F5.\r
11'\r
12' To exit QBasic, press Alt, F, X.\r
13'\r
14' To get help on a BASIC keyword, move the cursor to the keyword and press\r
15' F1 or click the right mouse button.\r
16'\r
17\r
18\r
19'Set default data type to integer for faster operation\r
20DEFINT A-Z\r
21\r
22'Sub and function declarations\r
23DECLARE SUB TransactionSummary (item%)\r
24DECLARE SUB LCenter (text$)\r
25DECLARE SUB ScrollUp ()\r
26DECLARE SUB ScrollDown ()\r
27DECLARE SUB Initialize ()\r
28DECLARE SUB Intro ()\r
29DECLARE SUB SparklePause ()\r
30DECLARE SUB Center (row%, text$)\r
31DECLARE SUB FancyCls (dots%, Background%)\r
32DECLARE SUB LoadState ()\r
33DECLARE SUB SaveState ()\r
34DECLARE SUB MenuSystem ()\r
35DECLARE SUB MakeBackup ()\r
36DECLARE SUB RestoreBackup ()\r
37DECLARE SUB Box (Row1%, Col1%, Row2%, Col2%)\r
38DECLARE SUB NetWorthReport ()\r
39DECLARE SUB EditAccounts ()\r
40DECLARE SUB PrintHelpLine (help$)\r
41DECLARE SUB EditTrans (item%)\r
42DECLARE FUNCTION Cvdt$ (X#)\r
43DECLARE FUNCTION Cvst$ (X!)\r
44DECLARE FUNCTION Cvit$ (X%)\r
45DECLARE FUNCTION Menu% (CurrChoiceX%, MaxChoice%, choice$(), ItemRow%(), ItemCol%(), help$(), BarMode%)\r
46DECLARE FUNCTION GetString$ (row%, col%, start$, end$, Vis%, Max%)\r
47DECLARE FUNCTION Trim$ (X$)\r
48\r
49'Constants\r
50CONST TRUE = -1\r
51CONST FALSE = NOT TRUE\r
52\r
53'User-defined types\r
54TYPE AccountType\r
55 Title AS STRING * 20\r
56 AType AS STRING * 1\r
57 Desc AS STRING * 50\r
58END TYPE\r
59\r
60TYPE Recordtype\r
61 Date AS STRING * 8\r
62 Ref AS STRING * 10\r
63 Desc AS STRING * 50\r
64 Fig1 AS DOUBLE\r
65 Fig2 AS DOUBLE\r
66END TYPE\r
67\r
68'Global variables\r
69DIM SHARED account(1 TO 19) AS AccountType 'Stores the 19 account titles\r
70DIM SHARED ColorPref 'Color Preference\r
71DIM SHARED colors(0 TO 20, 1 TO 4) 'Different Colors\r
72DIM SHARED ScrollUpAsm(1 TO 7) 'Assembly Language Routines\r
73DIM SHARED ScrollDownAsm(1 TO 7)\r
74DIM SHARED PrintErr AS INTEGER 'Printer error flag\r
75\r
76 DEF SEG = 0 ' Turn off CapLock, NumLock and ScrollLock\r
77 KeyFlags = PEEK(1047)\r
78 POKE 1047, &H0\r
79 DEF SEG\r
80 \r
81 'Open money manager data file. If it does not exist in current directory,\r
82 ' goto error handler to create and initialize it.\r
83 ON ERROR GOTO ErrorTrap\r
84 OPEN "money.dat" FOR INPUT AS #1\r
85 CLOSE\r
86 ON ERROR GOTO 0 'Reset error handler\r
87\r
88 Initialize 'Initialize program\r
89 Intro 'Display introduction screen\r
90 MenuSystem 'This is the main program\r
91 COLOR 7, 0 'Clear screen and end\r
92 CLS\r
93\r
94 DEF SEG = 0 ' Restore CapLock, NumLock and ScrollLock states\r
95 POKE 1047, KeyFlags\r
96 DEF SEG\r
97\r
98 END\r
99\r
100' Error handler for program\r
101' If data file not found, create and initialize a new one.\r
102ErrorTrap:\r
103 SELECT CASE ERR\r
104 ' If data file not found, create and initialize a new one.\r
105 CASE 53\r
106 CLOSE\r
107 ColorPref = 1\r
108 FOR a = 1 TO 19\r
109 account(a).Title = ""\r
110 account(a).AType = ""\r
111 account(a).Desc = ""\r
112 NEXT a\r
113 SaveState\r
114 RESUME\r
115 CASE 24, 25\r
116 PrintErr = TRUE\r
117 Box 8, 13, 14, 69\r
118 Center 11, "Printer not responding ... Press Space to continue"\r
119 WHILE INKEY$ <> "": WEND\r
120 WHILE INKEY$ <> " ": WEND\r
121 RESUME NEXT\r
122 CASE ELSE\r
123 END SELECT\r
124 RESUME NEXT\r
125\r
126\r
127'The following data defines the color schemes available via the main menu.\r
128'\r
129' scrn dots bar back title shdow choice curs cursbk shdow\r
130DATA 0, 7, 15, 7, 0, 7, 0, 15, 0, 0\r
131DATA 1, 9, 12, 3, 0, 1, 15, 0, 7, 0\r
132DATA 3, 15, 13, 1, 14, 3, 15, 0, 7, 0\r
133DATA 7, 12, 15, 4, 14, 0, 15, 15, 1, 0\r
134\r
135'The following data is actually a machine language program to\r
136'scroll the screen up or down very fast using a BIOS call.\r
137DATA &HB8,&H01,&H06,&HB9,&H01,&H04,&HBA,&H4E,&H16,&HB7,&H00,&HCD,&H10,&HCB\r
138DATA &HB8,&H01,&H07,&HB9,&H01,&H04,&HBA,&H4E,&H16,&HB7,&H00,&HCD,&H10,&HCB\r
139\r
140'Box:\r
141' Draw a box on the screen between the given coordinates.\r
142SUB Box (Row1, Col1, Row2, Col2) STATIC\r
143\r
144 BoxWidth = Col2 - Col1 + 1\r
145\r
146 LOCATE Row1, Col1\r
147