This is a bit of a general question, but I'm using in my web app, so...
Is there any functional limit I'm not aware of regarding for each..next loops? Is there any problem nesting them? I don't see why either should be problematic, but I can't figure it out.
I'm only cycling through about 57 records, so it should be able to handle it. Hopefully someone will see something I'm missing.
Is there any functional limit I'm not aware of regarding for each..next loops? Is there any problem nesting them? I don't see why either should be problematic, but I can't figure it out.
I'm only cycling through about 57 records, so it should be able to handle it. Hopefully someone will see something I'm missing.
PHP Code:
dim spend_table as p
dim bank_table as p
dim CompDiscInfo as c
dim EmployeeIDList as c
dim EmployeeCompDisc as c
dim hours_remaining as n
dim hours_to_post as n
dim hours_available as n
dim hour_check as n
DIM bank_list AS C
DIM find_result AS N
DIM indx AS P
DIM result AS N
spend_table = table.open("[PathAlias.ADB_Path]\compspent")
bank_table = table.open("[PathAlias.ADB_Path]\compbank")
EmployeeIDList = word_unique(table.external_record_content_get("[PathAlias.ADB_Path]\workhours","emp_id","emp_id","work_type='Comp Disc'.and.work_date>{3/11/2008}"),crlf())
CompDiscInfo = table.external_record_content_get("[PathAlias.ADB_Path]\workhours","work_id+'|'+work_date+'|'+work_hrs+'|'+emp_id","emp_id+work_date","work_type='Comp Disc'.and.work_date>{3/11/2008}")
for each EmployeeID in EmployeeIDList
EmployeeCompDisc = filter_string(CompDiscInfo,EmployeeID)
for each Discharge in EmployeeCompDisc
hour_check = tablesum("[PathAlias.ADB_Path]\compbank", "hrs_earned>hrs_spent.and.between(comp_date, (addmonths({" + word(Discharge,2,"|") + "},-3)+1), {" + word(Discharge,2,"|") + "}-1).and.emp_id='" + EmployeeID + "'.and..not.is_del", "hrs_earned")
hours_remaining = val(word(Discharge,3,"|"))
if hours_remaining <= hour_check then
bank_list = table.external_record_content_get("[PathAlias.ADB_Path]\compbank","comp_id+'|'+comp_date+'|'+hrs_earned+'|'+hrs_spent","comp_date","hrs_earned>hrs_spent.and.between(comp_date, (addmonths({" + word(Discharge,2,"|") + "},-3)+1), {" + word(Discharge,2,"|") + "}-1).and.emp_id='" + EmployeeID + "'.and..not.is_del")
for each entry in bank_list
hours_available = val(word(entry,3,"|")) - val(word(entry,4,"|"))
if hours_remaining <= hours_available then
hours_to_post = hours_remaining
hours_remaining = 0
else
hours_to_post = hours_available
hours_remaining = hours_remaining - hours_available
end if
spend_table.enter_begin()
spend_table.Comp_id = alltrim(word(entry,1,"|"))
spend_table.Work_id = alltrim(word(Discharge,1,"|"))
spend_table.Emp_id = alltrim(EmployeeID)
spend_table.Spent_date = ctod(alltrim(word(Discharge,2,"|")))
spend_table.Hrs_spent = hours_to_post
spend_table.Is_chg = .t.
spend_table.Chg_by_id = currentReviewer
spend_table.Chg_date = date()
spend_table.Doc = now()
spend_table.enter_end()
bank_table.index_primary_put("comp_id")
find_result = bank_table.fetch_find(word(entry,1,"|"))
if find_result > 0 then
bank_table.change_begin()
bank_table.Is_chg = .t.
bank_table.Chg_by_id = currentRviewer
bank_table.Chg_date = date()
bank_table.Hrs_spent = bank_table.Hrs_spent + hours_to_post
bank_table.change_end()
else
result = ui_msg_box("ERROR", "Error posting to COMPBANK (" + ut(str(find_result)) + ")",UI_OK_CANCEL)
if result = UI_CANCEL_SELECTED then
end
end if
end if
if hours_remaining = 0 then
exit for
end if
statusbar.Set_Text(EmployeeID + "|" + Discharge + "|" + entry)
next entry
else
result = ui_msg_box("Lack of hours","There are not enough hours to use.\n\nMissing " + ut(str(hours_remaining - hour_check)) + "hours.",UI_OK_CANCEL)
if result = UI_CANCEL_SELECTED then
end
else
continue
end if
end if
next Discharge
next EmployeeID
spend_table.close()
bank_table.close()
statusbar.clear()
ui_msg_box("Complete","The compAction routine has completed.")
Comment