Re: Budget Builder file register.e part 5, edit 1
- Posted by Senator Oct 05, 2020
- 1577 views
-- register.e part 5, edit 1 public constant AUTOLOG_DAT = "AUTOLOG.DAT" public procedure check_AUTOLOG_DAT() integer FILE, val if file_exists(AUTOLOG_DAT) then puts(1, "\n\tAUTOLOG.DAT file located...\n") FILE = open(AUTOLOG_DAT,"rb") if FILE = -1 then any_key("\n\t...Error opening AUTOLOG.DAT!\n\tPress any key...") else val = get_integer16(FILE) printf(1, "\ntAUTOLOG.DAT = %d", val) any_key("\n\n") end if end if end procedure -- automatically log transactions to table: register public procedure check_autolog_flag() datetime dtnow = now() integer LAST_MONTH, THIS_MONTH = dtnow[2], autolog = 0, FILE -- if db_compress() != DB_OK then -- any_key("\n\tDB compress failed!\n") -- end if if file_exists("AUTOLOG.DAT") then FILE = open("AUTOLOG.DAT", "ub") if FILE = -1 then any_key("\n\taborting autolog...Error opening AUTOLOG.DAT!\n\tPress any key...") return end if LAST_MONTH = get_integer16(FILE) if LAST_MONTH != THIS_MONTH then -- autolog budget data autolog = prompt_number("\n\tAuto-Log Budget data? Enter 0 = no, 1 = yes : ",{0,1}) if autolog then if autolog_budget() then put_integer16(FILE,THIS_MONTH) any_key("\n\tAutolog complete, AUTOLOG.DAT file updated\n\tPress any key to continue...") end if end if end if else -- FILE AUTOLOG.DAT does not exist -- create initial "AUTOLOG.DAT" file: FILE = open("AUTOLOG.DAT", "wb") if autolog_budget() then put_integer16(FILE,THIS_MONTH) -- update AUTOLOG.DAT end if end if close(FILE) end procedure public procedure select_cash_table() if db_select_table(CASH) != DB_OK then display("\n\t\t\tCould not select: ",0) hilite(sprintf("\n\t\t\t%s",{CASH})) end if update_tables() end procedure -- end register.e part 5, edit 1 -- end register.e
Regards, Ken