Re: Budget Builder file: register.e part 4, edit 1
- Posted by Senator
Oct 05, 2020
-- register.e part 4, edit 1
public procedure display_header()
sequence hpos
integer col, hline
init_text_formatter()
clear_screen()
set_foreground_color(HLC)
center_display(current_table,rightMargin-10)
set_foreground_color(FGC)
puts(1, "\n")
col = note_col
if equal(current_table, BUDGET) then
col = budget_note_col
key_col -= 1
else
col = note_col
end if
hpos=get_position()
hline = hpos[1]
position(hline,1) hilite("#",HLC,0)
position(hline,key_col) hilite("Day",HLC,0)
position(hline,col) hilite("Transaction", HLC,0)
position(hline,amt_col) hilite("Amount", HLC,0)
position(hline, bal_col) hilite("Balance",HLC,1)
draw_line()
puts(1,"\n")
end procedure
public constant ALL=13
public procedure list(integer only_year = 0, integer only_month = 0,
integer start = 1, integer stop = db_table_size())
object key
reset_columns()
init_text_formatter()
update_tables()
if only_year = 13 then only_year = select_year() end if
if only_month = 13 then only_month = select_month() end if
display_header()
pos = get_position()
-- line = pos[1]
for rec = start to stop do
key = db_record_key(rec)
if only_year and only_month then
if equal(key[MONTH],only_month) then
display_full_note(rec)
end if
else
display_full_note(rec)
end if
end for
puts(1,"\n\n")
set_foreground_color(FGC)
end procedure
global object brd, sourceDir, BACKUPDIR
include xbackup.e
public procedure backup_prj_files()
sequence file_name = "/home/ken/euprogs/bank_book/register.prj"
sourceDir = dirname(file_name)
brd = backupfiles(file_name)
display(brd[2])
end procedure
public function autolog_budget(sequence TARGET_TABLE = REGISTER)
sequence key, data
datetime dt = datetime:now()
backup_prj_files()
if db_select_table(BUDGET) != DB_OK then
display("\n\t\t\tCould not select: ",0)
hilite(sprintf("\n\t\t\t%s",{BUDGET}))
else
current_table = db_current_table()
if equal(current_table, BUDGET) then
for rec = 1 to db_table_size() do
key = db_record_key(rec) -- budget
data = db_record_data(rec) -- budget
if db_select_table(TARGET_TABLE) != DB_OK then
display("\n\t\t\tCould not select: ",0)
hilite(sprintf("\n\t\t\t%s",{TARGET_TABLE}))
any_key("\n")
else -- table = TARGET_TABLE
if key[1] > days_in_month(dt) then -- edit 9/1/2020
key[1] = days_in_month(dt)
end if
dt[DAY] = key[1]
dt[HOUR] = 4 -- 4 a.m.
dt[MINUTE] = 1
dt = add(dt, rec, MINUTES)
if db_insert(dt,data) != DB_OK then
display("\n\t\tCould not insert Autolog Budget data into ",0)
hilite(sprintf("\n\t\t\t%s",{TARGET_TABLE}))
any_key(" ")
return 0
else -- switch to BUDGET table to select next autolog entry
db_select_table(BUDGET)
end if
end if
end for
end if
end if
db_select_table(TARGET_TABLE)
return 1
end function
-- end register.e part 4, edit 1
Not Categorized, Please Help
|
|