Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1536 lines
45 KiB

  1. '
  2. ' Q B a s i c M O N E Y M A N A G E R
  3. '
  4. ' Copyright (C) Microsoft Corporation 1990
  5. '
  6. ' The Money Manager is a personal finance manager that allows you
  7. ' to enter account transactions while tracking your account balances
  8. ' and net worth.
  9. '
  10. ' To run this program, press Shift+F5.
  11. '
  12. ' To exit QBasic, press Alt, F, X.
  13. '
  14. ' To get help on a BASIC keyword, move the cursor to the keyword and press
  15. ' F1 or click the right mouse button.
  16. '
  17. 'Set default data type to integer for faster operation
  18. DEFINT A-Z
  19. 'Sub and function declarations
  20. DECLARE SUB TransactionSummary (item%)
  21. DECLARE SUB LCenter (text$)
  22. DECLARE SUB ScrollUp ()
  23. DECLARE SUB ScrollDown ()
  24. DECLARE SUB Initialize ()
  25. DECLARE SUB Intro ()
  26. DECLARE SUB SparklePause ()
  27. DECLARE SUB Center (row%, text$)
  28. DECLARE SUB FancyCls (dots%, Background%)
  29. DECLARE SUB LoadState ()
  30. DECLARE SUB SaveState ()
  31. DECLARE SUB MenuSystem ()
  32. DECLARE SUB MakeBackup ()
  33. DECLARE SUB RestoreBackup ()
  34. DECLARE SUB Box (Row1%, Col1%, Row2%, Col2%)
  35. DECLARE SUB NetWorthReport ()
  36. DECLARE SUB EditAccounts ()
  37. DECLARE SUB PrintHelpLine (help$)
  38. DECLARE SUB EditTrans (item%)
  39. DECLARE FUNCTION Cvdt$ (X#)
  40. DECLARE FUNCTION Cvst$ (X!)
  41. DECLARE FUNCTION Cvit$ (X%)
  42. DECLARE FUNCTION Menu% (CurrChoiceX%, MaxChoice%, choice$(), ItemRow%(), ItemCol%(), help$(), BarMode%)
  43. DECLARE FUNCTION GetString$ (row%, col%, start$, end$, Vis%, Max%)
  44. DECLARE FUNCTION Trim$ (X$)
  45. 'Constants
  46. CONST TRUE = -1
  47. CONST FALSE = NOT TRUE
  48. 'User-defined types
  49. TYPE AccountType
  50. Title AS STRING * 20
  51. AType AS STRING * 1
  52. Desc AS STRING * 50
  53. END TYPE
  54. TYPE Recordtype
  55. Date AS STRING * 8
  56. Ref AS STRING * 10
  57. Desc AS STRING * 50
  58. Fig1 AS DOUBLE
  59. Fig2 AS DOUBLE
  60. END TYPE
  61. 'Global variables
  62. DIM SHARED account(1 TO 19) AS AccountType 'Stores the 19 account titles
  63. DIM SHARED ColorPref 'Color Preference
  64. DIM SHARED colors(0 TO 20, 1 TO 4) 'Different Colors
  65. DIM SHARED ScrollUpAsm(1 TO 7) 'Assembly Language Routines
  66. DIM SHARED ScrollDownAsm(1 TO 7)
  67. DIM SHARED PrintErr AS INTEGER 'Printer error flag
  68. DEF SEG = 0 ' Turn off CapLock, NumLock and ScrollLock
  69. KeyFlags = PEEK(1047)
  70. POKE 1047, &H0
  71. DEF SEG
  72. 'Open money manager data file. If it does not exist in current directory,
  73. ' goto error handler to create and initialize it.
  74. ON ERROR GOTO ErrorTrap
  75. OPEN "money.dat" FOR INPUT AS #1
  76. CLOSE
  77. ON ERROR GOTO 0 'Reset error handler
  78. Initialize 'Initialize program
  79. Intro 'Display introduction screen
  80. MenuSystem 'This is the main program
  81. COLOR 7, 0 'Clear screen and end
  82. CLS
  83. DEF SEG = 0 ' Restore CapLock, NumLock and ScrollLock states
  84. POKE 1047, KeyFlags
  85. DEF SEG
  86. END
  87. ' Error handler for program
  88. ' If data file not found, create and initialize a new one.
  89. ErrorTrap:
  90. SELECT CASE ERR
  91. ' If data file not found, create and initialize a new one.
  92. CASE 53
  93. CLOSE
  94. ColorPref = 1
  95. FOR a = 1 TO 19
  96. account(a).Title = ""
  97. account(a).AType = ""
  98. account(a).Desc = ""
  99. NEXT a
  100. SaveState
  101. RESUME
  102. CASE 24, 25
  103. PrintErr = TRUE
  104. Box 8, 13, 14, 69
  105. Center 11, "Printer not responding ... Press Space to continue"
  106. WHILE INKEY$ <> "": WEND
  107. WHILE INKEY$ <> " ": WEND
  108. RESUME NEXT
  109. CASE ELSE
  110. END SELECT
  111. RESUME NEXT
  112. 'The following data defines the color schemes available via the main menu.
  113. '
  114. ' scrn dots bar back title shdow choice curs cursbk shdow
  115. DATA 0, 7, 15, 7, 0, 7, 0, 15, 0, 0
  116. DATA 1, 9, 12, 3, 0, 1, 15, 0, 7, 0
  117. DATA 3, 15, 13, 1, 14, 3, 15, 0, 7, 0
  118. DATA 7, 12, 15, 4, 14, 0, 15, 15, 1, 0
  119. 'The following data is actually a machine language program to
  120. 'scroll the screen up or down very fast using a BIOS call.
  121. DATA &HB8,&H01,&H06,&HB9,&H01,&H04,&HBA,&H4E,&H16,&HB7,&H00,&HCD,&H10,&HCB
  122. DATA &HB8,&H01,&H07,&HB9,&H01,&H04,&HBA,&H4E,&H16,&HB7,&H00,&HCD,&H10,&HCB
  123. 'Box:
  124. ' Draw a box on the screen between the given coordinates.
  125. SUB Box (Row1, Col1, Row2, Col2) STATIC
  126. BoxWidth = Col2 - Col1 + 1
  127. LOCATE Row1, Col1
  128. PRINT "�"; STRING$(BoxWidth - 2, "�"); "�";
  129. FOR a = Row1 + 1 TO Row2 - 1
  130. LOCATE a, Col1
  131. PRINT "�"; SPACE$(BoxWidth - 2); "�";
  132. NEXT a
  133. LOCATE Row2, Col1
  134. PRINT "�"; STRING$(BoxWidth - 2, "�"); "�";
  135. END SUB
  136. 'Center:
  137. ' Center text on the given row.
  138. SUB Center (row, text$)
  139. LOCATE row, 41 - LEN(text$) / 2
  140. PRINT text$;
  141. END SUB
  142. 'Cvdt$:
  143. ' Convert a double precision number to a string WITHOUT a leading space.
  144. FUNCTION Cvdt$ (X#)
  145. Cvdt$ = RIGHT$(STR$(X#), LEN(STR$(X#)) - 1)
  146. END FUNCTION
  147. 'Cvit$:
  148. ' Convert an integer to a string WITHOUT a leading space.
  149. FUNCTION Cvit$ (X)
  150. Cvit$ = RIGHT$(STR$(X), LEN(STR$(X)) - 1)
  151. END FUNCTION
  152. 'Cvst$:
  153. ' Convert a single precision number to a string WITHOUT a leading space
  154. FUNCTION Cvst$ (X!)
  155. Cvst$ = RIGHT$(STR$(X!), LEN(STR$(X!)) - 1)
  156. END FUNCTION
  157. 'EditAccounts:
  158. ' This is the full-screen editor which allows you to change your account
  159. ' titles and descriptions
  160. SUB EditAccounts
  161. 'Information about each column
  162. REDIM help$(4), col(4), Vis(4), Max(4), edit$(19, 3)
  163. 'Draw the screen
  164. COLOR colors(7, ColorPref), colors(4, ColorPref)
  165. Box 2, 1, 24, 80
  166. COLOR colors(5, ColorPref), colors(4, ColorPref)
  167. LOCATE 1, 1: PRINT SPACE$(80)
  168. LOCATE 1, 4: PRINT "Account Editor";
  169. COLOR colors(7, ColorPref), colors(4, ColorPref)
  170. LOCATE 3, 2: PRINT "No� Account Title � Description �A/L"
  171. LOCATE 4, 2: PRINT "������������������������������������������������������������������������������"
  172. u$ = "##�\ \�\ \� ! "
  173. FOR a = 5 TO 23
  174. LOCATE a, 2
  175. X = a - 4
  176. PRINT USING u$; X; account(X).Title; account(X).Desc; account(X).AType;
  177. NEXT a
  178. 'Initialize variables
  179. help$(1) = " Account name | <F2=Save and Exit> <Escape=Abort>"
  180. help$(2) = " Account description | <F2=Save and Exit> <Escape=Abort>"
  181. help$(3) = " Account type (A = Asset, L = Liability) | <F2=Save and Exit> <Escape=Abort>"
  182. col(1) = 5: col(2) = 26: col(3) = 78
  183. Vis(1) = 20: Vis(2) = 50: Vis(3) = 1
  184. Max(1) = 20: Max(2) = 50: Max(3) = 1
  185. FOR a = 1 TO 19
  186. edit$(a, 1) = account(a).Title
  187. edit$(a, 2) = account(a).Desc
  188. edit$(a, 3) = account(a).AType
  189. NEXT a
  190. finished = FALSE
  191. CurrRow = 1
  192. CurrCol = 1
  193. PrintHelpLine help$(CurrCol)
  194. 'Loop until F2 or <ESC> is pressed
  195. DO
  196. GOSUB EditAccountsShowCursor 'Show Cursor
  197. DO 'Wait for key
  198. Kbd$ = INKEY$
  199. LOOP UNTIL Kbd$ <> ""
  200. IF Kbd$ >= " " AND Kbd$ < "~" THEN 'If legal, edit item
  201. GOSUB EditAccountsEditItem
  202. END IF
  203. GOSUB EditAccountsHideCursor 'Hide Cursor so it can move
  204. 'If it needs to
  205. SELECT CASE Kbd$
  206. CASE CHR$(0) + "H" 'Up Arrow
  207. CurrRow = (CurrRow + 17) MOD 19 + 1
  208. CASE CHR$(0) + "P" 'Down Arrow
  209. CurrRow = (CurrRow) MOD 19 + 1
  210. CASE CHR$(0) + "K", CHR$(0) + CHR$(15) 'Left or Shift+Tab
  211. CurrCol = (CurrCol + 1) MOD 3 + 1
  212. PrintHelpLine help$(CurrCol)
  213. CASE CHR$(0) + "M", CHR$(9) 'Right or Tab
  214. CurrCol = (CurrCol) MOD 3 + 1
  215. PrintHelpLine help$(CurrCol)
  216. CASE CHR$(0) + "<" 'F2
  217. finished = TRUE
  218. Save = TRUE
  219. CASE CHR$(27) 'Esc
  220. finished = TRUE
  221. Save = FALSE
  222. CASE CHR$(13) 'Return
  223. CASE ELSE
  224. BEEP
  225. END SELECT
  226. LOOP UNTIL finished
  227. IF Save THEN
  228. GOSUB EditAccountsSaveData
  229. END IF
  230. EXIT SUB
  231. EditAccountsShowCursor:
  232. COLOR colors(8, ColorPref), colors(9, ColorPref)
  233. LOCATE CurrRow + 4, col(CurrCol)
  234. PRINT LEFT$(edit$(CurrRow, CurrCol), Vis(CurrCol));
  235. RETURN
  236. EditAccountsEditItem:
  237. COLOR colors(8, ColorPref), colors(9, ColorPref)
  238. ok = FALSE
  239. start$ = Kbd$
  240. DO
  241. Kbd$ = GetString$(CurrRow + 4, col(CurrCol), start$, end$, Vis(CurrCol), Max(CurrCol))
  242. edit$(CurrRow, CurrCol) = LEFT$(end$ + SPACE$(Max(CurrCol)), Max(CurrCol))
  243. start$ = ""
  244. IF CurrCol = 3 THEN
  245. X$ = UCASE$(end$)
  246. IF X$ = "A" OR X$ = "L" OR X$ = "" OR X$ = " " THEN
  247. ok = TRUE
  248. IF X$ = "" THEN X$ = " "
  249. edit$(CurrRow, CurrCol) = X$
  250. ELSE
  251. BEEP
  252. END IF
  253. ELSE
  254. ok = TRUE
  255. END IF
  256. LOOP UNTIL ok
  257. RETURN
  258. EditAccountsHideCursor:
  259. COLOR colors(7, ColorPref), colors(4, ColorPref)
  260. LOCATE CurrRow + 4, col(CurrCol)
  261. PRINT LEFT$(edit$(CurrRow, CurrCol), Vis(CurrCol));
  262. RETURN
  263. EditAccountsSaveData:
  264. FOR a = 1 TO 19
  265. account(a).Title = edit$(a, 1)
  266. account(a).Desc = edit$(a, 2)
  267. account(a).AType = edit$(a, 3)
  268. NEXT a
  269. SaveState
  270. RETURN
  271. END SUB
  272. 'EditTrans:
  273. ' This is the full-screen editor which allows you to enter and change
  274. ' transactions
  275. SUB EditTrans (item)
  276. 'Stores info about each column
  277. REDIM help$(6), col(6), Vis(6), Max(6), CurrString$(3), CurrFig#(5)
  278. 'Array to keep the current balance at all the transactions
  279. REDIM Balance#(1000)
  280. 'Open random access file
  281. file$ = "money." + Cvit$(item)
  282. OPEN file$ FOR RANDOM AS #1 LEN = 84
  283. FIELD #1, 8 AS IoDate$, 10 AS IoRef$, 50 AS IoDesc$, 8 AS IoFig1$, 8 AS IoFig2$
  284. FIELD #1, 11 AS valid$, 5 AS IoMaxRecord$, 8 AS IoBalance$
  285. 'Initialize variables
  286. CurrString$(1) = ""
  287. CurrString$(2) = ""
  288. CurrString$(3) = ""
  289. CurrFig#(4) = 0
  290. CurrFig#(5) = 0
  291. GET #1, 1
  292. IF valid$ <> "THISISVALID" THEN
  293. LSET IoDate$ = ""
  294. LSET IoRef$ = ""
  295. LSET IoDesc$ = ""
  296. LSET IoFig1$ = MKD$(0)
  297. LSET IoFig2$ = MKD$(0)
  298. PUT #1, 2
  299. LSET valid$ = "THISISVALID"
  300. LSET IoMaxRecord$ = "1"
  301. LSET IoBalance$ = MKD$(0)
  302. PUT #1, 1
  303. END IF
  304. MaxRecord = VAL(IoMaxRecord$)
  305. Balance#(0) = 0
  306. a = 1
  307. WHILE a <= MaxRecord
  308. GET #1, a + 1
  309. Balance#(a) = Balance#(a - 1) + CVD(IoFig1$) - CVD(IoFig2$)
  310. a = a + 1
  311. WEND
  312. GOSUB EditTransWriteBalance
  313. help$(1) = "Date of transaction (mm/dd/yy) "
  314. help$(2) = "Transaction reference number "
  315. help$(3) = "Transaction description "
  316. help$(4) = "Increase asset or debt value "
  317. help$(5) = "Decrease asset or debt value "
  318. col(1) = 2
  319. col(2) = 11
  320. col(3) = 18
  321. col(4) = 44
  322. col(5) = 55
  323. Vis(1) = 8
  324. Vis(2) = 6
  325. Vis(3) = 25
  326. Vis(4) = 10
  327. Vis(5) = 10
  328. Max(1) = 8
  329. Max(2) = 6
  330. Max(3) = 25
  331. Max(4) = 10
  332. Max(5) = 10
  333. 'Draw Screen
  334. COLOR colors(7, ColorPref), colors(4, ColorPref)
  335. Box 2, 1, 24, 80
  336. COLOR colors(5, ColorPref), colors(4, ColorPref)
  337. LOCATE 1, 1: PRINT SPACE$(80);
  338. LOCATE 1, 4: PRINT "Transaction Editor: " + Trim$(account(item).Title);
  339. COLOR colors(7, ColorPref), colors(4, ColorPref)
  340. LOCATE 3, 2: PRINT " Date � Ref# � Description � Increase � Decrease � Balance "
  341. LOCATE 4, 2: PRINT "������������������������������������������������������������������������������"
  342. u$ = "\ \�\ \�\ \�"
  343. u1$ = " � � � � � "
  344. u1x$ = "�������߳�����߳������������������������߳���������߳���������߳��������������"
  345. u2$ = "###,###.##"
  346. u3$ = "###,###,###.##"
  347. u4$ = " "
  348. CurrTopline = 1
  349. GOSUB EditTransPrintWholeScreen
  350. CurrRow = 1
  351. CurrCol = 1
  352. PrintHelpLine help$(CurrCol) + "| <F2=Save and Exit> <F9=Insert> <F10=Delete>"
  353. GOSUB EditTransGetLine
  354. finished = FALSE
  355. 'Loop until <F2> is pressed
  356. DO
  357. GOSUB EditTransShowCursor 'Show Cursor, Wait for key
  358. DO: Kbd$ = INKEY$: LOOP UNTIL Kbd$ <> ""
  359. GOSUB EditTransHideCursor
  360. IF Kbd$ >= " " AND Kbd$ < "~" OR Kbd$ = CHR$(8) THEN 'If legal key, edit item
  361. GOSUB EditTransEditItem
  362. END IF
  363. SELECT CASE Kbd$ 'Handle Special keys
  364. CASE CHR$(0) + "H" 'up arrow
  365. GOSUB EditTransMoveUp
  366. CASE CHR$(0) + "P" 'Down arrow
  367. GOSUB EditTransMoveDown
  368. CASE CHR$(0) + "K", CHR$(0) + CHR$(15) 'Left Arrow,BackTab
  369. CurrCol = (CurrCol + 3) MOD 5 + 1
  370. PrintHelpLine help$(CurrCol) + "| <F2=Save and Exit> <F9=Insert> <F10=Delete>"
  371. CASE CHR$(0) + "M", CHR$(9) 'Right Arrow,Tab
  372. CurrCol = (CurrCol) MOD 5 + 1
  373. PrintHelpLine help$(CurrCol) + "| <F2=Save and Exit> <F9=Insert> <F10=Delete>"
  374. CASE CHR$(0) + "G" 'Home
  375. CurrCol = 1
  376. CASE CHR$(0) + "O" 'End
  377. CurrCol = 5
  378. CASE CHR$(0) + "I" 'Page Up
  379. CurrRow = 1
  380. CurrTopline = CurrTopline - 19
  381. IF CurrTopline < 1 THEN
  382. CurrTopline = 1
  383. END IF
  384. GOSUB EditTransPrintWholeScreen
  385. GOSUB EditTransGetLine
  386. CASE CHR$(0) + "Q" 'Page Down
  387. CurrRow = 1
  388. CurrTopline = CurrTopline + 19
  389. IF CurrTopline > MaxRecord THEN
  390. CurrTopline = MaxRecord
  391. END IF
  392. GOSUB EditTransPrintWholeScreen
  393. GOSUB EditTransGetLine
  394. CASE CHR$(0) + "<" 'F2
  395. finished = TRUE
  396. CASE CHR$(0) + "C" 'F9
  397. GOSUB EditTransAddRecord
  398. CASE CHR$(0) + "D" 'F10
  399. GOSUB EditTransDeleteRecord
  400. CASE CHR$(13) 'Enter
  401. CASE ELSE
  402. BEEP
  403. END SELECT
  404. LOOP UNTIL finished
  405. CLOSE
  406. EXIT SUB
  407. EditTransShowCursor:
  408. COLOR colors(8, ColorPref), colors(9, ColorPref)
  409. LOCATE CurrRow + 4, col(CurrCol)
  410. SELECT CASE CurrCol
  411. CASE 1, 2, 3
  412. PRINT LEFT$(CurrString$(CurrCol), Vis(CurrCol));
  413. CASE 4
  414. IF CurrFig#(4) <> 0 THEN
  415. PRINT USING u2$; CurrFig#(4);
  416. ELSE
  417. PRINT SPACE$(Vis(CurrCol));
  418. END IF
  419. CASE 5
  420. IF CurrFig#(5) <> 0 THEN
  421. PRINT USING u2$; CurrFig#(5);
  422. ELSE
  423. PRINT SPACE$(Vis(CurrCol));
  424. END IF
  425. END SELECT
  426. RETURN
  427. EditTransHideCursor:
  428. COLOR colors(7, ColorPref), colors(4, ColorPref)
  429. LOCATE CurrRow + 4, col(CurrCol)
  430. SELECT CASE CurrCol
  431. CASE 1, 2, 3
  432. PRINT LEFT$(CurrString$(CurrCol), Vis(CurrCol));
  433. CASE 4
  434. IF CurrFig#(4) <> 0 THEN
  435. PRINT USING u2$; CurrFig#(4);
  436. ELSE
  437. PRINT SPACE$(Vis(CurrCol));
  438. END IF
  439. CASE 5
  440. IF CurrFig#(5) <> 0 THEN
  441. PRINT USING u2$; CurrFig#(5);
  442. ELSE
  443. PRINT SPACE$(Vis(CurrCol));
  444. END IF
  445. END SELECT
  446. RETURN
  447. EditTransEditItem:
  448. CurrRecord = CurrTopline + CurrRow - 1
  449. COLOR colors(8, ColorPref), colors(9, ColorPref)
  450. SELECT CASE CurrCol
  451. CASE 1, 2, 3
  452. Kbd$ = GetString$(CurrRow + 4, col(CurrCol), Kbd$, new$, Vis(CurrCol), Max(CurrCol))
  453. CurrString$(CurrCol) = new$
  454. GOSUB EditTransPutLine
  455. GOSUB EditTransGetLine
  456. CASE 4
  457. start$ = Kbd$
  458. DO
  459. Kbd$ = GetString$(CurrRow + 4, col(4), start$, new$, Vis(4), Max(4))
  460. new4# = VAL(new$)
  461. start$ = ""
  462. LOOP WHILE new4# >= 999999.99# OR new4# < 0
  463. a = CurrRecord
  464. WHILE a <= MaxRecord
  465. Balance#(a) = Balance#(a) + new4# - CurrFig#(4) + CurrFig#(5)
  466. a = a + 1
  467. WEND
  468. CurrFig#(4) = new4#
  469. CurrFig#(5) = 0
  470. GOSUB EditTransPutLine
  471. GOSUB EditTransGetLine
  472. GOSUB EditTransPrintBalances
  473. GOSUB EditTransWriteBalance
  474. CASE 5
  475. start$ = Kbd$
  476. DO
  477. Kbd$ = GetString$(CurrRow + 4, col(5), start$, new$, Vis(5), Max(5))
  478. new5# = VAL(new$)
  479. start$ = ""
  480. LOOP WHILE new5# >= 999999.99# OR new5# < 0
  481. a = CurrRecord
  482. WHILE a <= MaxRecord
  483. Balance#(a) = Balance#(a) - new5# + CurrFig#(5) - CurrFig#(4)
  484. a = a + 1
  485. WEND
  486. CurrFig#(4) = 0
  487. CurrFig#(5) = new5#
  488. GOSUB EditTransPutLine
  489. GOSUB EditTransGetLine
  490. GOSUB EditTransPrintBalances
  491. GOSUB EditTransWriteBalance
  492. CASE ELSE
  493. END SELECT
  494. GOSUB EditTransPrintLine
  495. RETURN
  496. EditTransMoveUp:
  497. IF CurrRow = 1 THEN
  498. IF CurrTopline = 1 THEN
  499. BEEP
  500. ELSE
  501. ScrollDown
  502. CurrTopline = CurrTopline - 1
  503. GOSUB EditTransGetLine
  504. GOSUB EditTransPrintLine
  505. END IF
  506. ELSE
  507. CurrRow = CurrRow - 1
  508. GOSUB EditTransGetLine
  509. END IF
  510. RETURN
  511. EditTransMoveDown:
  512. IF (CurrRow + CurrTopline - 1) >= MaxRecord THEN
  513. BEEP
  514. ELSE
  515. IF CurrRow = 19 THEN
  516. ScrollUp
  517. CurrTopline = CurrTopline + 1
  518. GOSUB EditTransGetLine
  519. GOSUB EditTransPrintLine
  520. ELSE
  521. CurrRow = CurrRow + 1
  522. GOSUB EditTransGetLine
  523. END IF
  524. END IF
  525. RETURN
  526. EditTransPrintLine:
  527. COLOR colors(7, ColorPref), colors(4, ColorPref)
  528. CurrRecord = CurrTopline + CurrRow - 1
  529. LOCATE CurrRow + 4, 2
  530. IF CurrRecord = MaxRecord + 1 THEN
  531. PRINT u1x$;
  532. ELSEIF CurrRecord > MaxRecord THEN
  533. PRINT u1$;
  534. ELSE
  535. PRINT USING u$; CurrString$(1); CurrString$(2); CurrString$(3);
  536. IF CurrFig#(4) = 0 AND CurrFig#(5) = 0 THEN
  537. PRINT USING u4$ + "�" + u4$ + "�" + u3$; Balance#(CurrRecord)
  538. ELSEIF CurrFig#(5) = 0 THEN
  539. PRINT USING u2$ + "�" + u4$ + "�" + u3$; CurrFig#(4); Balance#(CurrRecord)
  540. ELSE
  541. PRINT USING u4$ + "�" + u2$ + "�" + u3$; CurrFig#(5); Balance#(CurrRecord)
  542. END IF
  543. END IF
  544. RETURN
  545. EditTransPrintBalances:
  546. COLOR colors(7, ColorPref), colors(4, ColorPref)
  547. FOR a = 1 TO 19
  548. CurrRecord = CurrTopline + a - 1
  549. IF CurrRecord <= MaxRecord THEN
  550. LOCATE 4 + a, 66
  551. PRINT USING u3$; Balance#(CurrTopline + a - 1);
  552. END IF
  553. NEXT a
  554. RETURN
  555. EditTransDeleteRecord:
  556. IF MaxRecord = 1 THEN
  557. BEEP
  558. ELSE
  559. CurrRecord = CurrTopline + CurrRow - 1
  560. MaxRecord = MaxRecord - 1
  561. a = CurrRecord
  562. WHILE a <= MaxRecord
  563. GET #1, a + 2
  564. PUT #1, a + 1
  565. Balance#(a) = Balance#(a + 1) - CurrFig#(4) + CurrFig#(5)
  566. a = a + 1
  567. WEND
  568. LSET valid$ = "THISISVALID"
  569. LSET IoMaxRecord$ = Cvit$(MaxRecord)
  570. PUT #1, 1
  571. GOSUB EditTransPrintWholeScreen
  572. CurrRecord = CurrTopline + CurrRow - 1
  573. IF CurrRecord > MaxRecord THEN
  574. GOSUB EditTransMoveUp
  575. END IF
  576. GOSUB EditTransGetLine
  577. GOSUB EditTransWriteBalance
  578. END IF
  579. RETURN
  580. EditTransAddRecord:
  581. CurrRecord = CurrTopline + CurrRow - 1
  582. a = MaxRecord
  583. WHILE a > CurrRecord
  584. GET #1, a + 1
  585. PUT #1, a + 2
  586. Balance#(a + 1) = Balance#(a)
  587. a = a - 1
  588. WEND
  589. Balance#(CurrRecord + 1) = Balance#(CurrRecord)
  590. MaxRecord = MaxRecord + 1
  591. LSET IoDate$ = ""
  592. LSET IoRef$ = ""
  593. LSET IoDesc$ = ""
  594. LSET IoFig1$ = MKD$(0)
  595. LSET IoFig2$ = MKD$(0)
  596. PUT #1, CurrRecord + 2
  597. LSET valid$ = "THISISVALID"
  598. LSET IoMaxRecord$ = Cvit$(MaxRecord)
  599. PUT #1, 1
  600. GOSUB EditTransPrintWholeScreen
  601. GOSUB EditTransGetLine
  602. RETURN
  603. EditTransPrintWholeScreen:
  604. temp = CurrRow
  605. FOR CurrRow = 1 TO 19
  606. CurrRecord = CurrTopline + CurrRow - 1
  607. IF CurrRecord <= MaxRecord THEN
  608. GOSUB EditTransGetLine
  609. END IF
  610. GOSUB EditTransPrintLine
  611. NEXT CurrRow
  612. CurrRow = temp
  613. RETURN
  614. EditTransWriteBalance:
  615. GET #1, 1
  616. LSET IoBalance$ = MKD$(Balance#(MaxRecord))
  617. PUT #1, 1
  618. RETURN
  619. EditTransPutLine:
  620. CurrRecord = CurrTopline + CurrRow - 1
  621. LSET IoDate$ = CurrString$(1)
  622. LSET IoRef$ = CurrString$(2)
  623. LSET IoDesc$ = CurrString$(3)
  624. LSET IoFig1$ = MKD$(CurrFig#(4))
  625. LSET IoFig2$ = MKD$(CurrFig#(5))
  626. PUT #1, CurrRecord + 1
  627. RETURN
  628. EditTransGetLine:
  629. CurrRecord = CurrTopline + CurrRow - 1
  630. GET #1, CurrRecord + 1
  631. CurrString$(1) = IoDate$
  632. CurrString$(2) = IoRef$
  633. CurrString$(3) = IoDesc$
  634. CurrFig#(4) = CVD(IoFig1$)
  635. CurrFig#(5) = CVD(IoFig2$)
  636. RETURN
  637. END SUB
  638. 'FancyCls:
  639. ' Clears screen in the right color, and draws nice dots.
  640. SUB FancyCls (dots, Background)
  641. VIEW PRINT 2 TO 24
  642. COLOR dots, Background
  643. CLS 2
  644. FOR a = 95 TO 1820 STEP 45
  645. row = a / 80 + 1
  646. col = a MOD 80 + 1
  647. LOCATE row, col
  648. PRINT CHR$(250);
  649. NEXT a
  650. VIEW PRINT
  651. END SUB
  652. 'GetString$:
  653. ' Given a row and col, and an initial string, edit a string
  654. ' VIS is the length of the visible field of entry
  655. ' MAX is the maximum number of characters allowed in the string
  656. FUNCTION GetString$ (row, col, start$, end$, Vis, Max)
  657. curr$ = Trim$(LEFT$(start$, Max))
  658. IF curr$ = CHR$(8) THEN curr$ = ""
  659. LOCATE , , 1
  660. finished = FALSE
  661. DO
  662. GOSUB GetStringShowText
  663. GOSUB GetStringGetKey
  664. IF LEN(Kbd$) > 1 THEN
  665. finished = TRUE
  666. GetString$ = Kbd$
  667. ELSE
  668. SELECT CASE Kbd$
  669. CASE CHR$(13), CHR$(27), CHR$(9)
  670. finished = TRUE
  671. GetString$ = Kbd$
  672. CASE CHR$(8)
  673. IF curr$ <> "" THEN
  674. curr$ = LEFT$(curr$, LEN(curr$) - 1)
  675. END IF
  676. CASE " " TO "}"
  677. IF LEN(curr$) < Max THEN
  678. curr$ = curr$ + Kbd$
  679. ELSE
  680. BEEP
  681. END IF
  682. CASE ELSE
  683. BEEP
  684. END SELECT
  685. END IF
  686. LOOP UNTIL finished
  687. end$ = curr$
  688. LOCATE , , 0
  689. EXIT FUNCTION
  690. GetStringShowText:
  691. LOCATE row, col
  692. IF LEN(curr$) > Vis THEN
  693. PRINT RIGHT$(curr$, Vis);
  694. ELSE
  695. PRINT curr$; SPACE$(Vis - LEN(curr$));
  696. LOCATE row, col + LEN(curr$)
  697. END IF
  698. RETURN
  699. GetStringGetKey:
  700. Kbd$ = ""
  701. WHILE Kbd$ = ""
  702. Kbd$ = INKEY$
  703. WEND
  704. RETURN
  705. END FUNCTION
  706. 'Initialize:
  707. ' Read colors in and set up assembly routines
  708. SUB Initialize
  709. WIDTH , 25
  710. VIEW PRINT
  711. FOR ColorSet = 1 TO 4
  712. FOR X = 1 TO 10
  713. READ colors(X, ColorSet)
  714. NEXT X
  715. NEXT ColorSet
  716. LoadState
  717. P = VARPTR(ScrollUpAsm(1))
  718. DEF SEG = VARSEG(ScrollUpAsm(1))
  719. FOR I = 0 TO 13
  720. READ J
  721. POKE (P + I), J
  722. NEXT I
  723. P = VARPTR(ScrollDownAsm(1))
  724. DEF SEG = VARSEG(ScrollDownAsm(1))
  725. FOR I = 0 TO 13
  726. READ J
  727. POKE (P + I), J
  728. NEXT I
  729. DEF SEG
  730. END SUB
  731. 'Intro:
  732. ' Display introduction screen.
  733. SUB Intro
  734. SCREEN 0
  735. WIDTH 80, 25
  736. COLOR 7, 0
  737. CLS
  738. Center 4, "Q B a s i c"
  739. COLOR 15
  740. Center 5, "� � ���� � � ���� � � � � ���� � � ���� ����� ���� �����"
  741. Center 6, "��� ��� � � �� � � ����� ��� ��� � � �� � � � � � � �"
  742. Center 7, "� � � � � � ��� ���� � � � � ���� � ��� ���� � ��� ���� �����"
  743. Center 8, "� � ���� � � ���� � � � � � � � � � ����� ���� � ��"
  744. COLOR 7
  745. Center 11, "A Personal Finance Manager written in"
  746. Center 12, "MS-DOS QBasic"
  747. Center 24, "Press any key to continue"
  748. SparklePause
  749. END SUB
  750. 'LCenter:
  751. ' Center TEXT$ on the line printer
  752. SUB LCenter (text$)
  753. LPRINT TAB(41 - LEN(text$) / 2); text$
  754. END SUB
  755. 'LoadState:
  756. ' Load color preferences and account info from MONEY.DAT
  757. SUB LoadState
  758. OPEN "money.dat" FOR INPUT AS #1
  759. INPUT #1, ColorPref
  760. FOR a = 1 TO 19
  761. LINE INPUT #1, account(a).Title
  762. LINE INPUT #1, account(a).AType
  763. LINE INPUT #1, account(a).Desc
  764. NEXT a
  765. CLOSE
  766. END SUB
  767. 'Menu:
  768. ' Handles Menu Selection for a single menu (either sub menu, or menu bar)
  769. ' currChoiceX : Number of current choice
  770. ' maxChoice : Number of choices in the list
  771. ' choice$() : Array with the text of the choices
  772. ' itemRow() : Array with the row of the choices
  773. ' itemCol() : Array with the col of the choices
  774. ' help$() : Array with the help text for each choice
  775. ' barMode : Boolean: TRUE = menu bar style, FALSE = drop down style
  776. '
  777. ' Returns the number of the choice that was made by changing currChoiceX
  778. ' and returns the scan code of the key that was pressed to exit
  779. '
  780. FUNCTION Menu (CurrChoiceX, MaxChoice, choice$(), ItemRow(), ItemCol(), help$(), BarMode)
  781. currChoice = CurrChoiceX
  782. 'if in bar mode, color in menu bar, else color box/shadow
  783. 'bar mode means you are currently in the menu bar, not a sub menu
  784. IF BarMode THEN
  785. COLOR colors(7, ColorPref), colors(4, ColorPref)
  786. LOCATE 1, 1
  787. PRINT SPACE$(80);
  788. ELSE
  789. FancyCls colors(2, ColorPref), colors(1, ColorPref)
  790. COLOR colors(7, ColorPref), colors(4, ColorPref)
  791. Box ItemRow(1) - 1, ItemCol(1) - 1, ItemRow(MaxChoice) + 1, ItemCol(1) + LEN(choice$(1)) + 1
  792. COLOR colors(10, ColorPref), colors(6, ColorPref)
  793. FOR a = 1 TO MaxChoice + 1
  794. LOCATE ItemRow(1) + a - 1, ItemCol(1) + LEN(choice$(1)) + 2
  795. PRINT CHR$(178); CHR$(178);
  796. NEXT a
  797. LOCATE ItemRow(MaxChoice) + 2, ItemCol(MaxChoice) + 2
  798. PRINT STRING$(LEN(choice$(MaxChoice)) + 2, 178);
  799. END IF
  800. 'print the choices
  801. COLOR colors(7, ColorPref), colors(4, ColorPref)
  802. FOR a = 1 TO MaxChoice
  803. LOCATE ItemRow(a), ItemCol(a)
  804. PRINT choice$(a);
  805. NEXT a
  806. finished = FALSE
  807. WHILE NOT finished
  808. GOSUB MenuShowCursor
  809. GOSUB MenuGetKey
  810. GOSUB MenuHideCursor
  811. SELECT CASE Kbd$
  812. CASE CHR$(0) + "H": GOSUB MenuUp
  813. CASE CHR$(0) + "P": GOSUB MenuDown
  814. CASE CHR$(0) + "K": GOSUB MenuLeft
  815. CASE CHR$(0) + "M": GOSUB MenuRight
  816. CASE CHR$(13): GOSUB MenuEnter
  817. CASE CHR$(27): GOSUB MenuEscape
  818. CASE ELSE: BEEP
  819. END SELECT
  820. WEND
  821. Menu = currChoice
  822. EXIT FUNCTION
  823. MenuEnter:
  824. finished = TRUE
  825. RETURN
  826. MenuEscape:
  827. currChoice = 0
  828. finished = TRUE
  829. RETURN
  830. MenuUp:
  831. IF BarMode THEN
  832. BEEP
  833. ELSE
  834. currChoice = (currChoice + MaxChoice - 2) MOD MaxChoice + 1
  835. END IF
  836. RETURN
  837. MenuLeft:
  838. IF BarMode THEN
  839. currChoice = (currChoice + MaxChoice - 2) MOD MaxChoice + 1
  840. ELSE
  841. currChoice = -2
  842. finished = TRUE
  843. END IF
  844. RETURN
  845. MenuRight:
  846. IF BarMode THEN
  847. currChoice = (currChoice) MOD MaxChoice + 1
  848. ELSE
  849. currChoice = -3
  850. finished = TRUE
  851. END IF
  852. RETURN
  853. MenuDown:
  854. IF BarMode THEN
  855. finished = TRUE
  856. ELSE
  857. currChoice = (currChoice) MOD MaxChoice + 1
  858. END IF
  859. RETURN
  860. MenuShowCursor:
  861. COLOR colors(8, ColorPref), colors(9, ColorPref)
  862. LOCATE ItemRow(currChoice), ItemCol(currChoice)
  863. PRINT choice$(currChoice);
  864. PrintHelpLine help$(currChoice)
  865. RETURN
  866. MenuGetKey:
  867. Kbd$ = ""
  868. WHILE Kbd$ = ""
  869. Kbd$ = INKEY$
  870. WEND
  871. RETURN
  872. MenuHideCursor:
  873. COLOR colors(7, ColorPref), colors(4, ColorPref)
  874. LOCATE ItemRow(currChoice), ItemCol(currChoice)
  875. PRINT choice$(currChoice);
  876. RETURN
  877. END FUNCTION
  878. 'MenuSystem:
  879. ' Main routine that controls the program. Uses the MENU function
  880. ' to implement menu system and calls the appropriate function to handle
  881. ' the user's selection
  882. SUB MenuSystem
  883. DIM choice$(20), menuRow(20), menuCol(20), help$(20)
  884. LOCATE , , 0
  885. choice = 1
  886. finished = FALSE
  887. WHILE NOT finished
  888. GOSUB MenuSystemMain
  889. subchoice = -1
  890. WHILE subchoice < 0
  891. SELECT CASE choice
  892. CASE 1: GOSUB MenuSystemFile
  893. CASE 2: GOSUB MenuSystemEdit
  894. CASE 3: GOSUB MenuSystemAccount
  895. CASE 4: GOSUB MenuSystemReport
  896. CASE 5: GOSUB MenuSystemColors
  897. END SELECT
  898. FancyCls colors(2, ColorPref), colors(1, ColorPref)
  899. SELECT CASE subchoice
  900. CASE -2: choice = (choice + 3) MOD 5 + 1
  901. CASE -3: choice = (choice) MOD 5 + 1
  902. END SELECT
  903. WEND
  904. WEND
  905. EXIT SUB
  906. MenuSystemMain:
  907. FancyCls colors(2, ColorPref), colors(1, ColorPref)
  908. COLOR colors(7, ColorPref), colors(4, ColorPref)
  909. Box 9, 19, 14, 61
  910. Center 11, "Use arrow keys to navigate menu system"
  911. Center 12, "Press Enter to select a menu item"
  912. choice$(1) = " File "
  913. choice$(2) = " Accounts "
  914. choice$(3) = " Transactions "
  915. choice$(4) = " Reports "
  916. choice$(5) = " Colors "
  917. menuRow(1) = 1: menuCol(1) = 2
  918. menuRow(2) = 1: menuCol(2) = 8
  919. menuRow(3) = 1: menuCol(3) = 18
  920. menuRow(4) = 1: menuCol(4) = 32
  921. menuRow(5) = 1: menuCol(5) = 41
  922. help$(1) = "Exit the Money Manager"
  923. help$(2) = "Add/edit/delete accounts"
  924. help$(3) = "Add/edit/delete account transactions"
  925. help$(4) = "View and print reports"
  926. help$(5) = "Set screen colors"
  927. DO
  928. NewChoice = Menu((choice), 5, choice$(), menuRow(), menuCol(), help$(), TRUE)
  929. LOOP WHILE NewChoice = 0
  930. choice = NewChoice
  931. RETURN
  932. MenuSystemFile:
  933. choice$(1) = " Exit "
  934. menuRow(1) = 3: menuCol(1) = 2
  935. help$(1) = "Exit the Money Manager"
  936. subchoice = Menu(1, 1, choice$(), menuRow(), menuCol(), help$(), FALSE)
  937. SELECT CASE subchoice
  938. CASE 1: finished = TRUE
  939. CASE ELSE
  940. END SELECT
  941. RETURN
  942. MenuSystemEdit:
  943. choice$(1) = " Edit Account Titles "
  944. menuRow(1) = 3: menuCol(1) = 8
  945. help$(1) = "Add/edit/delete accounts"
  946. subchoice = Menu(1, 1, choice$(), menuRow(), menuCol(), help$(), FALSE)
  947. SELECT CASE subchoice
  948. CASE 1: EditAccounts
  949. CASE ELSE
  950. END SELECT
  951. RETURN
  952. MenuSystemAccount:
  953. FOR a = 1 TO 19
  954. IF Trim$(account(a).Title) = "" THEN
  955. choice$(a) = RIGHT$(STR$(a), 2) + ". ------------------- "
  956. ELSE
  957. choice$(a) = RIGHT$(STR$(a), 2) + ". " + account(a).Title
  958. END IF
  959. menuRow(a) = a + 2
  960. menuCol(a) = 19
  961. help$(a) = RTRIM$(account(a).Desc)
  962. NEXT a
  963. subchoice = Menu(1, 19, choice$(), menuRow(), menuCol(), help$(), FALSE)
  964. IF subchoice > 0 THEN
  965. EditTrans (subchoice)
  966. END IF
  967. RETURN
  968. MenuSystemReport:
  969. choice$(1) = " Net Worth Report "
  970. menuRow(1) = 3: menuCol(1) = 32
  971. help$(1) = "View and print net worth report"
  972. FOR a = 1 TO 19
  973. IF Trim$(account(a).Title) = "" THEN
  974. choice$(a + 1) = RIGHT$(STR$(a), 2) + ". ------------------- "
  975. ELSE
  976. choice$(a + 1) = RIGHT$(STR$(a), 2) + ". " + account(a).Title
  977. END IF
  978. menuRow(a + 1) = a + 3
  979. menuCol(a + 1) = 32
  980. help$(a + 1) = "Print " + RTRIM$(account(a).Title) + " transaction summary"
  981. NEXT a
  982. subchoice = Menu(1, 20, choice$(), menuRow(), menuCol(), help$(), FALSE)
  983. SELECT CASE subchoice
  984. CASE 1
  985. NetWorthReport
  986. CASE 2 TO 20
  987. TransactionSummary (subchoice - 1)
  988. CASE ELSE
  989. END SELECT
  990. RETURN
  991. MenuSystemColors:
  992. choice$(1) = " Monochrome Scheme "
  993. choice$(2) = " Cyan/Blue Scheme "
  994. choice$(3) = " Blue/Cyan Scheme "
  995. choice$(4) = " Red/Grey Scheme "
  996. menuRow(1) = 3: menuCol(1) = 41
  997. menuRow(2) = 4: menuCol(2) = 41
  998. menuRow(3) = 5: menuCol(3) = 41
  999. menuRow(4) = 6: menuCol(4) = 41
  1000. help$(1) = "Color scheme for monochrome and LCD displays"
  1001. help$(2) = "Color scheme featuring cyan"
  1002. help$(3) = "Color scheme featuring blue"
  1003. help$(4) = "Color scheme featuring red"
  1004. subchoice = Menu(1, 4, choice$(), menuRow(), menuCol(), help$(), FALSE)
  1005. SELECT CASE subchoice
  1006. CASE 1 TO 4
  1007. ColorPref = subchoice
  1008. SaveState
  1009. CASE ELSE
  1010. END SELECT
  1011. RETURN
  1012. END SUB
  1013. 'NetWorthReport:
  1014. ' Prints net worth report to screen and printer
  1015. SUB NetWorthReport
  1016. DIM assetIndex(19), liabilityIndex(19)
  1017. maxAsset = 0
  1018. maxLiability = 0
  1019. FOR a = 1 TO 19
  1020. IF account(a).AType = "A" THEN
  1021. maxAsset = maxAsset + 1
  1022. assetIndex(maxAsset) = a
  1023. ELSEIF account(a).AType = "L" THEN
  1024. maxLiability = maxLiability + 1
  1025. liabilityIndex(maxLiability) = a
  1026. END IF
  1027. NEXT a
  1028. 'Loop until <F2> is pressed
  1029. finished = FALSE
  1030. DO
  1031. u1$ = "\ \$$###,###,###.##"
  1032. u2$ = "\ \+$$#,###,###,###.##"
  1033. COLOR colors(5, ColorPref), colors(4, ColorPref)
  1034. LOCATE 1, 1: PRINT SPACE$(80);
  1035. LOCATE 1, 4: PRINT "Net Worth Report: " + DATE$;
  1036. PrintHelpLine "<F2=Exit> <F3=Print Report>"
  1037. COLOR colors(7, ColorPref), colors(4, ColorPref)
  1038. Box 2, 1, 24, 40
  1039. Box 2, 41, 24, 80
  1040. LOCATE 2, 16: PRINT " ASSETS "
  1041. assetTotal# = 0
  1042. a = 1
  1043. count1 = 1
  1044. WHILE a <= maxAsset
  1045. file$ = "money." + Cvit$(assetIndex(a))
  1046. OPEN file$ FOR RANDOM AS #1 LEN = 84
  1047. FIELD #1, 11 AS valid$, 5 AS IoMaxRecord$, 8 AS IoBalance$
  1048. GET #1, 1
  1049. IF valid$ = "THISISVALID" THEN
  1050. LOCATE 2 + count1, 3: PRINT USING u1$; account(assetIndex(a)).Title; CVD(IoBalance$)
  1051. assetTotal# = assetTotal# + CVD(IoBalance$)
  1052. count1 = count1 + 1
  1053. END IF
  1054. CLOSE
  1055. a = a + 1
  1056. WEND
  1057. LOCATE 2, 55: PRINT " LIABILITIES "
  1058. liabilityTotal# = 0
  1059. a = 1
  1060. count2 = 1
  1061. WHILE a <= maxLiability
  1062. file$ = "money." + Cvit$(liabilityIndex(a))
  1063. OPEN file$ FOR RANDOM AS #1 LEN = 84
  1064. FIELD #1, 11 AS valid$, 5 AS IoMaxRecord$, 8 AS IoBalance$
  1065. GET #1, 1
  1066. IF valid$ = "THISISVALID" THEN
  1067. LOCATE 2 + count2, 43: PRINT USING u1$; account(liabilityIndex(a)).Title; CVD(IoBalance$)
  1068. liabilityTotal# = liabilityTotal# + CVD(IoBalance$)
  1069. count2 = count2 + 1
  1070. END IF
  1071. CLOSE
  1072. a = a + 1
  1073. WEND
  1074. IF count2 > count1 THEN count1 = count2
  1075. LOCATE 2 + count1, 25: PRINT "--------------"
  1076. LOCATE 2 + count1, 65: PRINT "--------------"
  1077. LOCATE 3 + count1, 3: PRINT USING u2$; "Total assets"; assetTotal#;
  1078. LOCATE 3 + count1, 43: PRINT USING u2$; "Total liabilities"; liabilityTotal#
  1079. COLOR colors(5, ColorPref), colors(4, ColorPref)
  1080. LOCATE 1, 43: PRINT USING u2$; " NET WORTH:"; assetTotal# - liabilityTotal#
  1081. DO: Kbd$ = INKEY$: LOOP UNTIL Kbd$ <> ""
  1082. SELECT CASE Kbd$ 'Handle Special keys
  1083. CASE CHR$(0) + "<" 'F2
  1084. finished = TRUE
  1085. CASE CHR$(0) + "=" 'F3
  1086. GOSUB NetWorthReportPrint
  1087. CASE ELSE
  1088. BEEP
  1089. END SELECT
  1090. LOOP UNTIL finished
  1091. EXIT SUB
  1092. NetWorthReportPrint:
  1093. PrintHelpLine ""
  1094. Box 8, 20, 14, 62
  1095. Center 10, "Prepare printer on LPT1 for report"
  1096. Center 12, "Hit <Enter> to print, or <Esc> to abort"
  1097. DO: Kbd$ = INKEY$: LOOP WHILE Kbd$ <> CHR$(13) AND Kbd$ <> CHR$(27)
  1098. IF Kbd$ = CHR$(13) THEN
  1099. Box 8, 20, 14, 62
  1100. Center 11, "Printing report..."
  1101. u0$ = " \ \ "
  1102. u1$ = " \ \ $$###,###,###.##"
  1103. u2$ = " --------------"
  1104. u3$ = " ============="
  1105. u4$ = " \ \+$$#,###,###,###.##"
  1106. PrintErr = FALSE
  1107. ON ERROR GOTO ErrorTrap ' test if printer is connected
  1108. LPRINT
  1109. IF PrintErr = FALSE THEN
  1110. LPRINT : LPRINT : LPRINT : LPRINT : LPRINT
  1111. LCenter "Q B a s i c"
  1112. LCenter "M O N E Y M A N A G E R"
  1113. LPRINT : LPRINT
  1114. LCenter "NET WORTH REPORT: " + DATE$
  1115. LCenter "-------------------------------------------"
  1116. LPRINT USING u0$; "ASSETS:"
  1117. assetTotal# = 0
  1118. a = 1
  1119. WHILE a <= maxAsset
  1120. file$ = "money." + Cvit$(assetIndex(a))
  1121. OPEN file$ FOR RANDOM AS #1 LEN = 84
  1122. FIELD #1, 11 AS valid$, 5 AS IoMaxRecord$, 8 AS IoBalance$
  1123. GET #1, 1
  1124. IF valid$ = "THISISVALID" THEN
  1125. LPRINT USING u1$; account(assetIndex(a)).Title; CVD(IoBalance$)
  1126. assetTotal# = assetTotal# + CVD(IoBalance$)
  1127. END IF
  1128. CLOSE #1
  1129. a = a + 1
  1130. WEND
  1131. LPRINT u2$
  1132. LPRINT USING u4$; "Total assets"; assetTotal#
  1133. LPRINT
  1134. LPRINT
  1135. LPRINT USING u0$; "LIABILITIES:"
  1136. liabilityTotal# = 0
  1137. a = 1
  1138. WHILE a <= maxLiability
  1139. file$ = "money." + Cvit$(liabilityIndex(a))
  1140. OPEN file$ FOR RANDOM AS #1 LEN = 84
  1141. FIELD #1, 11 AS valid$, 5 AS IoMaxRecord$, 8 AS IoBalance$
  1142. GET #1, 1
  1143. IF valid$ = "THISISVALID" THEN
  1144. LPRINT USING u1$; account(liabilityIndex(a)).Title; CVD(IoBalance$)
  1145. liabilityTotal# = liabilityTotal# + CVD(IoBalance$)
  1146. END IF
  1147. CLOSE #1
  1148. a = a + 1
  1149. WEND
  1150. LPRINT u2$
  1151. LPRINT USING u4$; "Total liabilities"; liabilityTotal#
  1152. LPRINT
  1153. LPRINT
  1154. LPRINT u3$
  1155. LPRINT USING u4$; "NET WORTH"; assetTotal# - liabilityTotal#
  1156. LCenter "-------------------------------------------"
  1157. LPRINT : LPRINT : LPRINT
  1158. END IF
  1159. ON ERROR GOTO 0
  1160. END IF
  1161. RETURN
  1162. END SUB
  1163. 'PrintHelpLine:
  1164. ' Prints help text on the bottom row in the proper color
  1165. SUB PrintHelpLine (help$)
  1166. COLOR colors(5, ColorPref), colors(4, ColorPref)
  1167. LOCATE 25, 1
  1168. PRINT SPACE$(80);
  1169. Center 25, help$
  1170. END SUB
  1171. 'SaveState:
  1172. ' Save color preference and account information to "MONEY.DAT" data file.
  1173. SUB SaveState
  1174. OPEN "money.dat" FOR OUTPUT AS #2
  1175. PRINT #2, ColorPref
  1176. FOR a = 1 TO 19
  1177. PRINT #2, account(a).Title
  1178. PRINT #2, account(a).AType
  1179. PRINT #2, account(a).Desc
  1180. NEXT a
  1181. CLOSE #2
  1182. END SUB
  1183. 'ScrollDown:
  1184. ' Call the assembly program to scroll the screen down
  1185. SUB ScrollDown
  1186. DEF SEG = VARSEG(ScrollDownAsm(1))
  1187. CALL Absolute(VARPTR(ScrollDownAsm(1)))
  1188. DEF SEG
  1189. END SUB
  1190. 'ScrollUp:
  1191. ' Calls the assembly program to scroll the screen up
  1192. SUB ScrollUp
  1193. DEF SEG = VARSEG(ScrollUpAsm(1))
  1194. CALL Absolute(VARPTR(ScrollUpAsm(1)))
  1195. DEF SEG
  1196. END SUB
  1197. 'SparklePause:
  1198. ' Creates flashing border for intro screen
  1199. SUB SparklePause
  1200. COLOR 4, 0
  1201. a$ = "* * * * * * * * * * * * * * * * * "
  1202. WHILE INKEY$ <> "": WEND 'Clear keyboard buffer
  1203. WHILE INKEY$ = ""
  1204. FOR a = 1 TO 5
  1205. LOCATE 1, 1 'print horizontal sparkles
  1206. PRINT MID$(a$, a, 80);
  1207. LOCATE 22, 1
  1208. PRINT MID$(a$, 6 - a, 80);
  1209. FOR b = 2 TO 21 'Print Vertical sparkles
  1210. c = (a + b) MOD 5
  1211. IF c = 1 THEN
  1212. LOCATE b, 80
  1213. PRINT "*";
  1214. LOCATE 23 - b, 1
  1215. PRINT "*";
  1216. ELSE
  1217. LOCATE b, 80
  1218. PRINT " ";
  1219. LOCATE 23 - b, 1
  1220. PRINT " ";
  1221. END IF
  1222. NEXT b
  1223. NEXT a
  1224. WEND
  1225. END SUB
  1226. 'TransactionSummary:
  1227. ' Print transaction summary to line printer
  1228. SUB TransactionSummary (item)
  1229. FancyCls colors(2, ColorPref), colors(1, ColorPref)
  1230. PrintHelpLine ""
  1231. Box 8, 20, 14, 62
  1232. Center 10, "Prepare printer on LPT1 for report"
  1233. Center 12, "Hit <Enter> to print, or <Esc> to abort"
  1234. DO: Kbd$ = INKEY$: LOOP WHILE Kbd$ <> CHR$(13) AND Kbd$ <> CHR$(27)
  1235. IF Kbd$ = CHR$(13) THEN
  1236. Box 8, 20, 14, 62
  1237. Center 11, "Printing report..."
  1238. PrintErr = FALSE
  1239. ON ERROR GOTO ErrorTrap ' test if printer is connected
  1240. LPRINT
  1241. IF PrintErr = FALSE THEN
  1242. PRINT
  1243. LPRINT : LPRINT : LPRINT : LPRINT : LPRINT
  1244. LCenter "Q B a s i c"
  1245. LCenter "M O N E Y M A N A G E R"
  1246. LPRINT : LPRINT
  1247. LCenter "Transaction summary: " + Trim$(account(item).Title)
  1248. LCenter DATE$
  1249. LPRINT
  1250. u5$ = "--------|------|------------------------|----------|----------|--------------"
  1251. LPRINT u5$
  1252. LPRINT " Date | Ref# | Description | Increase | Decrease | Balance "
  1253. LPRINT u5$
  1254. u0$ = "\ \|\ \|\ \|"
  1255. u2$ = "###,###.##"
  1256. u3$ = "###,###,###.##"
  1257. u4$ = " "
  1258. file$ = "money." + Cvit$(item)
  1259. OPEN file$ FOR RANDOM AS #1 LEN = 84
  1260. FIELD #1, 8 AS IoDate$, 10 AS IoRef$, 50 AS IoDesc$, 8 AS IoFig1$, 8 AS IoFig2$
  1261. FIELD #1, 11 AS valid$, 5 AS IoMaxRecord$, 8 AS IoBalance$
  1262. GET #1, 1
  1263. IF valid$ = "THISISVALID" THEN
  1264. Balance# = 0
  1265. MaxRecord = VAL(IoMaxRecord$)
  1266. CurrRecord = 1
  1267. WHILE CurrRecord <= MaxRecord
  1268. GET #1, CurrRecord + 1
  1269. Fig1# = CVD(IoFig1$)
  1270. Fig2# = CVD(IoFig2$)
  1271. LPRINT USING u0$; IoDate$; IoRef$; IoDesc$;
  1272. IF Fig2# = 0 AND Fig1# = 0 THEN
  1273. LPRINT USING u4$ + "|" + u4$ + "|" + u3$; Balance#
  1274. ELSEIF Fig2# = 0 THEN
  1275. Balance# = Balance# + Fig1#
  1276. LPRINT USING u2$ + "|" + u4$ + "|" + u3$; Fig1#; Balance#
  1277. ELSE
  1278. Balance# = Balance# - Fig2#
  1279. LPRINT USING u4$ + "|" + u2$ + "|" + u3$; Fig2#; Balance#
  1280. END IF
  1281. CurrRecord = CurrRecord + 1
  1282. WEND
  1283. LPRINT u5$
  1284. LPRINT : LPRINT
  1285. END IF
  1286. ON ERROR GOTO 0
  1287. END IF
  1288. CLOSE
  1289. END IF
  1290. END SUB
  1291. 'Trin$:
  1292. ' Remove null and spaces from the end of a string.
  1293. FUNCTION Trim$ (X$)
  1294. IF X$ = "" THEN
  1295. Trim$ = ""
  1296. ELSE
  1297. lastChar = 0
  1298. FOR a = 1 TO LEN(X$)
  1299. y$ = MID$(X$, a, 1)
  1300. IF y$ <> CHR$(0) AND y$ <> " " THEN
  1301. lastChar = a
  1302. END IF
  1303. NEXT a
  1304. Trim$ = LEFT$(X$, lastChar)
  1305. END IF
  1306. END FUNCTION