if !EMPTY(cFrecast) ADD COLUMN TO xbrowse oBrw data {|| trans(oBrw:oDbf:gl:trend, '@Z 999.9') }; SIZE 40 COLOR CLR_BLACK, CLR_WHITE LEFT HEADER "TrendIt"
ADD COLUMN TO xbrowse oBrw DATA {|| if(gl->gst == 1, "Yes", if(gl->gst == 0, " ",)) }; SIZE 25 COLOR CLR_BLACK, CLR_WHITE LEFT HEADER "GST" // blank cursor colm else ADD COLUMN TO xbrowse oBrw DATA {|| if(gl->gst == 1, "Yes", if(gl->gst == 0, " ",)) }; SIZE 25 COLOR CLR_BLACK, CLR_WHITE LEFT HEADER "GST" // blank cursor colm endif else if !EMPTY(cFrecast) ADD COLUMN TO xbrowse oBrw data {|| trans(oBrw:oDbf:gl:trend, '@Z 999.9') }; SIZE 40 COLOR CLR_BLACK, CLR_WHITE LEFT HEADER "TrendIt" else //oBrw:hBmpCursor := LoadBitmap( GetResources(), "Z_Finger" ) ADD TO xbrowse oBrw DATA {|| if(gl->gst == 1, " ", if(gl->gst == 0, " ",)) }; SIZE 20 COLOR CLR_BLACK, CLR_WHITE LEFT HEADER " " // blank cursor colm endif endif
gl->(dbGoTop())
oBrw:bLDblClick := { | nRow,nCol |if (nNewVar == 1,msginfo("Editing is not available while vewing this report."),(odlg:hide(),apicard( oBrw, nRow, nCol, odlg))),oBrw:refresh(); ,oBrw:setfocus(),odlg:show(),needCalc(oDlg),oBrw:refresh(),oBrw:setfocus(),mPassMess := .t.}
oBrw:bKeyChar := { | nKey,nRow,nCol | if(nKey=VK_RETURN,; (IF(nNewVar == 1,msginfo("Editing is not available while in this report."); ,(odlg:hide(),apicard( oBrw, nRow, nCol, odlg))),whatUsing(oDlg),oDlg:update(),oBrw:refresh(),oBrw:setfocus(),odlg:show(),needCalc(oDlg)),),.t.}
REDEFINE SAY ID 12 OF ODLG COLOR CLR_WHITE, CLR_RED
// DISPALAY SENSITIVITY
redefine button obtn1 id 14 of oDlg ; ACTION(oDlg:hide(),setcalc(),lsetmess := .t.,whatifi(),oDlg:show(),openfilter := .f., asetfilter(.f.,obrw),setcalc2(obrw,odlg,2),oBrw:setfocus())
if !EMPTY(cFrecast) REDEFINE SAY oSay10 prompt alltrim(cFrecast) ID 51 OF ODLG COLOR CLR_WHITE, CLR_RED //COLOR CLR_RED, CLR_WHITE else REDEFINE SAY oSay10 ID 51 OF ODLG endif
* if viewingMulti == 0
REDEFINE SAY oSay35 ID 412 OF ODLG COLOR CLR_WHITE,CLR_BLUE REDEFINE SAY oSay36 ID 413 OF ODLG COLOR CLR_WHITE,CLR_BLUE REDEFINE SAY oSay37 ID 414 OF ODLG COLOR CLR_WHITE,CLR_BLUE REDEFINE SAY oSay11 ID 200 OF ODLG COLOR CLR_WHITE,CLR_BLUE REDEFINE SAY oSay12 ID 201 OF ODLG COLOR CLR_WHITE,CLR_BLUE
* endif
//REDEFINE SAY oSay13 prompt cWhatView ID 400 OF ODLG update COLOR CLR_WHITE,CLR_RED
* if viewingMulti == 0
REDEFINE SAY oSay20 prompt cWhichSales ID 75 OF ODLG update COLOR CLR_WHITE,CLR_BLUE REDEFINE SAY oSay21 prompt cWhichCost ID 23 OF ODLG update COLOR CLR_WHITE,CLR_BLUE
* endif
// RUN MULTI YEAR redefine button obtn9 id 17 of oDlg ; action(toCalcOrNot(obrw,oDlg),isMultiYear(),msgwait("Multi year forecast updated.","Please Wait",1))
redefine button obtn2 id 4002 of odlg ; action(toCalcOrNot(obrw,oDlg),toExitPrint(oDlg,oBrw,nNewVar,nIndex,msize))
redefine button obtn13 id 20 of odlg ; action(find2(2,oBrw," ",.f.,oDlg,oDbf,2))
redefine button obtn3 id 103 of oDlg ; action(nRecNo := gl->(recno()),oDlg:hide(),openfilter := .t.,addnewaccounts(obrw,odlg,msendtitle,nNewVar),asetfilter(.t.,obrw),gl->(dbgoto(nRecno)),oDlg:show(),oBrw:refresh(),oBrw:setfocus())
* redefine button obtn4 id 105 of oDlg ; * action(asetcalc(obrw,ODLG),setTheOrder(),gl->(dbgoto(1)),obrw:refresh(),obrw:setfocus())
redefine button obtn5 prompt cCaption id 106 of oDlg ; action(oDlg:hide(),addexp(obrw,odlg,.f.,.f.,nNewVar),goforward := .t.,odlg:show(),gl->(dbgotop()),oBrw:refresh(),oBrw:setfocus(),mPassMess := .t.,setMess(oDlg,oBrw),cPrompt := "Select accounts to display", oDlg:update(),.t.)
// new 1/25/2009
redefine button obtn7 prompt cPrompt id 16 of oDlg ; action(if(nWhichDisp == 1,(openfilter := .f., asetfilter(.f.,obrw),gl->(dbgoto(1)),oBtn7:setText("Select accounts to display"), nWhichDisp := 0),; (nRecNo := gl->(recno()),oDlg:hide(),openfilter := .t.,addnewaccounts(obrw,odlg,msendtitle,nNewVar),asetfilter(.t.,obrw),gl->(dbgoto(nRecno),oDlg:show(),oBtn7:setText("Display only accounts being used"),nWhichDisp := 1)) ),oBrw:setFocus())
* redefine button obtn7 id 16 of oDlg ; * action(openfilter := .f., asetfilter(.f.,obrw),gl->(dbgoto(1)),oBrw:setfocus(),oBrw:refresh(),oBrw:setfocus())
if lusingOnehr == .f.
if nfp == .T. cPandl1 := " < Other Activity Items >"
REDEFINE COMBOBOX OCBX1 VAR cPandl1 ITEMS { " < Other Activity Items >",; "Credit line financing and Interest expense" ,; "Amortization of prepaid expenses" ,; "Due to from owners/affiliate and Interest owners" ,; "Expense as a percent of change in net assets" ,; "Interest on cash balances" ,; "Investment activity and Revenue From Investments" ,; "Notes rec'able amortization and Interest income" ,; "Sale of equipment and Gain or loss on the sale of assets" ,; "Service contracts receivable and Service income" ,; "Start up expenses" ,; "Term loan amortization and Interest expense" }; ID 19 OF oDlg on change(asetfilter(.f.,obrw),setup1(cPandl1,10,oDlg,nNewVar),mmcurrec := gl->(recno()),openfilter := .f.,; asetfilter(.f.,obrw),oDlg:show() ,; setcalc2(obrw,odlg,2) ,; fixIt(oDlg,oBrw,oCbx1),setTheOrder(),WhatUsing(oDlg),gl->(dbgotop()),oBrw:setfocus()) ; UPDATE
else
cPandl1 := " < Other Profit And Loss Items >"
REDEFINE COMBOBOX OCBX1 VAR cPandl1 ITEMS { " < Other Profit And Loss Items >",; "Amortization of prepaid expenses" ,; "Credit line financing and Interest expense" ,; "Due to from owners/affiliate and Interest owners" ,; "Expense as a percent of net income" ,; "Income tax expense and estimated tax payments" ,; "Interest on cash balances" ,; "Investment activity and Income From Investments" ,; "Notes rec'able amortization and Interest income" ,; "Sale of equipment and Gain or loss on the sale of assets" ,; "Service contracts receivable and Service income" ,; "Start up expenses" ,; "Term loan amortization and Interest expense" }; ID 19 OF oDlg on change(asetfilter(.f.,obrw),setup1(cPandl1,10,oDlg,nNewVar),mmcurrec := gl->(recno()),openfilter := .f.,; asetfilter(.f.,obrw),oDlg:show() ,; setcalc2(obrw,odlg,2) ,; fixIt(oDlg,oBrw,oCbx1),setTheOrder(),WhatUsing(oDlg),gl->(dbgotop()),oBrw:setfocus()) ; UPDATE endif
if nfp == .T. REDEFINE COMBOBOX OCBX4 VAR cPandl4 ITEMS { " < Reports >",; "Cash Flow" ,; "Financial Position" ,; "Program Analysis" ,; "Activities" }; ID 50 OF oDlg on change(getCash(oBtn12,oBtn10,oBrw,oDlg,aCol,oBtn4),; oBrw:refresh(),oDlg:update(),oBrw:setfocus(),oCbx4:refresh(),.t.)
else
REDEFINE COMBOBOX OCBX4 VAR cPandl4 ITEMS { " < Reports >",; "Cash Flow" ,; "Balance Sheets" ,; "Prod./cust. analysis" ,; "Profit and Loss" ,; "Credit line analysis"} ; ID 50 OF oDlg on change(getCash(oBtn12,oBtn10,oBrw,oDlg,aCol,oBtn4),; oBrw:refresh(),oDlg:update(),oBrw:setfocus(),oCbx4:refresh(),.t.) endif
if lusingOnehr == .f.
if nfp == .T.
//whatUsing(oDlg)
cPandl2 := " < Revenue >"
REDEFINE COMBOBOX OCBX2 VAR cPandl2 ITEMS { " < Revenue >",; "Revenue by program" ,; "Miscellaneous income"}; ID 15 OF oDlg on change(asetfilter(.f.,obrw),setup1(cPandl2,10,oDlg,nNewVar),setTheOrder(),oDlg:show(),setcalc2(obrw,odlg,2),openfilter := .f.,asetfilter(.f.,obrw),; fixIt(oDlg,oBrw,oCbx1),setTheOrder(),WhatUsing(oDlg),gl->(dbgotop()),oBrw:setfocus()); Update else
//whatUsing(oDlg)
cPandl2 := " < Sales/Income >"
REDEFINE COMBOBOX OCBX2 VAR cPandl2 ITEMS { " < Sales/Income >",; "Annual, monthly, collections",; "By product/customer/employee etc.",; "% completion method",; "Miscellaneous income"}; ID 15 OF oDlg on change(asetfilter(.f.,obrw),setup1(cPandl2,10,oDlg,nNewVar),setTheOrder(),oDlg:show(),setcalc2(obrw,odlg,2),openfilter := .f.,asetfilter(.f.,obrw),; fixIt(oDlg,oBrw,oCbx1),setTheOrder(),WhatUsing(oDlg),gl->(dbgotop()),oBrw:setfocus()); Update endif
if nfp == .T.
cPandl3 := " < Program Costs >" REDEFINE COMBOBOX OCBX3 VAR cPandl3 ITEMS { " < Program Costs >",; "As a percentage of revenue",; "In detail (33 items)",; "By program"}; ID 13 OF oDlg on change(asetfilter(.f.,obrw),setup1(cPandl3,9,oDlg,nNewVar),oDlg:show(),setTheOrder(),setcalc2(obrw,odlg,2),openfilter := .f.,asetfilter(.f.,obrw),; fixIt(oDlg,oBrw,oCbx1),setTheOrder(),WhatUsing(oDlg),gl->(dbgotop()),oBrw:setfocus()); Update
else cPandl3 := " < Cost Of Sales >" REDEFINE COMBOBOX OCBX3 VAR cPandl3 ITEMS { " < Cost Of Sales >",; "As a percentage of sales",; "In detail (33 items)",; "By product/customer/employee etc."}; ID 13 OF oDlg on change(asetfilter(.f.,obrw),setup1(cPandl3,9,oDlg,nNewVar),oDlg:show(),setTheOrder(),setcalc2(obrw,odlg,2),openfilter := .f.,asetfilter(.f.,obrw),; fixIt(oDlg,oBrw,oCbx1),setTheOrder(),WhatUsing(oDlg),gl->(dbgotop()),oBrw:setfocus()); Update endif
cPandl := " < Cash Flow And Other Items >"
if nfp == .T. REDEFINE COMBOBOX OCBX VAR cPandl ITEMS { " < Cash Flow And Other Items >",; "Adjust other assets" ,; "Beginning financial position" ,; "Beginning payables-payment of same" ,; "Customer deposits" ,; "Deposits to be made" ,; "Loans due to/from owners/affiliates" ,; "Loans from others" ,; "Loans to others" ,; "Name, fiscal period, plan year " ,; "New borrowings and investor activities" ,; "Purchase of equipment",; "Sales tax collection and payment"}; ID 18 OF oDlg on change(asetfilter(.f.,obrw),setup1(cPandl,9,oDlg,nNewVar),oDlg:show(),setcalc2(obrw,odlg,2),openfilter := .f.,asetfilter(.f.,obrw),; fixIt(oDlg,oBrw,oCbx1),setTheOrder(),WhatUsing(oDlg),gl->(dbgotop()),oBrw:setfocus()); Update
else
REDEFINE COMBOBOX OCBX VAR cPandl ITEMS { " < Cash Flow And Other Items >",; "Adjust other assets",; "Beginning balance sheet",; "Beginning payables-payment of same",; "Customer deposits" ,; "Deposits to be made", ; "Dividends to be paid",; "Enter actual products sold", ; "Loans due to/from owners/affiliates",; "Loans from others",; "Loans to others",; "Name, fiscal period, plan year ",; "New borrowings and investor activities",; "Preferred stock/Treasury stock",; "Proprietors draw",; "Purchase of equipment",; "Sales tax collection and payment"}; ID 18 OF oDlg on change(asetfilter(.f.,obrw),setup1(cPandl,9,oDlg,nNewVar),oDlg:show(),setcalc2(obrw,odlg,2),openfilter := .f.,asetfilter(.f.,obrw),; fixIt(oDlg,oBrw,oCbx1),setTheOrder(),WhatUsing(oDlg),gl->(dbgotop()),oBrw:setfocus()); Update endif endif
//REDEFINE BTNBMP OBMP1 ID 116 OF ODLG file "TESTBMP2.BMP"
oCbx:cToolTip := "To set a trend for an item double click on "+CRLF+"the 'TrendIt' column and"+; "enter the amount (%)"+CRLF+" you wish to have the item trend by to future years."
//REDEFINE BTNBMP OBMP5 ID 21 OF ODLG file "TESTBMP2.BMP"
oBtn3:cToolTip := "Select expense departments to be displayed."+CRLF+; "Edit a standard payment assumption for all expenses."
oBtn5:cTooltip := "All planning options available and a program map"
* oBmp5:cToolTip := "To edit an expense (cell) left double click on the expense."+CRLF+; * "Left click, the following is available: eleven methods for developing the expense. "+CRLF+; * "For additional options highlight the expense (cell) then right click on the expense."+CRLF+; * "Right click, the following is available:"+CRLF+; * "Remove an expense, edit notes, move an expense from one department to another,"+CRLF+; * "expense Driver Calculator, allocate the expense to a product, customer etc."
I know you are thinking, "if it isn't broke, then don't fix it." Perhaps a good philosophy, but less is more is also a good one. Less code makes the code easier to read and understand and less likely to contain bugs. If you do find a bug in a function, one fix is all that is needed.
James thanks for the good advice. And code. The code that you want to reduce was suggested by you many years ago. But as life goes on we hopefully get better. You do me sometimes.
An clue how i can color a cell. Always get bound array acess.
OK, I have recreated your error. This will happen if the column has not yet been defined. When it has not been defined, there is no corresponding array in oBrw, thus the array access error.
So make sure the column you are coloring has been defined, then use this line: