I am trying to write a code snippet in XBasic to open a set, update the fields in a parent table (tbl) with calculations based on a field in a child table (ftbl).
The code below fails with an endless loop, after displaying a message box saying that the set is in use. I am not running on a network and there are no files open that I can see. I sometimes will get an error message that the tbl.change_begin() instruction in line 11 failed because a file was in use. Doesn't the set.open_session() command start a completely new session, regardless of what else is going on?
dim wset as p
dim tbl as p
dim ftbl as p
wset = set.open_session("set_final")
if wset.in_use("set_final") then
ui_msg_box("error","set is in use")
else
ui_msg_box("ok","opening the set")
end if
tbl = wset.get_primary()
ftbl = wset.followup
tbl.change_begin()
tbl.dof = ftbl.dof
wks = tbl.wksfu
select
case wks < 4
tbl.p2 = "c"
interval = "2 weeks"
case wks <= 7
tbl.p6 = "c"
interval = "6 weeks"
case wks <=14
tbl.p12 = "c"
interval = "12 weeks"
case wks <=30
tbl.p26 = "c"
interval = "26 weeks"
case wks <= 60
tbl.p52 = "c"
interval = "52 weeks"
case wks <= 120
tbl.p104 = "c"
interval = "2 years"
case wks <= 162
tbl.p156 = "c"
interval = "3 years"
case wks <= 215
tbl.p208 = "c"
interval = "4 years"
case wks <= 270
tbl.p260 = "c"
interval = "5 years"
text = "Weeks = " + wks + "Interval = " + interval
ui_msg_box("Interval and Weeks",text)
end select
while .not. tbl.eof()
while .not. ftbl.eof()
tbl.dof = ftbl.dof
wks = tbl.wksfu
select
case wks < 4
tbl.p2 = "c"
interval = "2 weeks"
case wks <= 7
tbl.p6 = "c"
interval = "6 weeks"
case wks <=14
tbl.p12 = "c"
interval = "12 weeks"
case wks <=30
tbl.p26 = "c"
interval = "26 weeks"
case wks <= 60
tbl.p52 = "c"
interval = "52 weeks"
case wks <= 120
tbl.p104 = "c"
interval = "2 years"
case wks <= 162
tbl.p156 = "c"
interval = "3 years"
case wks <= 215
tbl.p208 = "c"
interval = "4 years"
case wks <= 270
tbl.p260 = "c"
interval = "5 years"
text = "Weeks = " + wks + "Interval = " + interval
ui_msg_box("Interval and Weeks",text)
end select
end while
end while
tbl.change_end()
The code below fails with an endless loop, after displaying a message box saying that the set is in use. I am not running on a network and there are no files open that I can see. I sometimes will get an error message that the tbl.change_begin() instruction in line 11 failed because a file was in use. Doesn't the set.open_session() command start a completely new session, regardless of what else is going on?
dim wset as p
dim tbl as p
dim ftbl as p
wset = set.open_session("set_final")
if wset.in_use("set_final") then
ui_msg_box("error","set is in use")
else
ui_msg_box("ok","opening the set")
end if
tbl = wset.get_primary()
ftbl = wset.followup
tbl.change_begin()
tbl.dof = ftbl.dof
wks = tbl.wksfu
select
case wks < 4
tbl.p2 = "c"
interval = "2 weeks"
case wks <= 7
tbl.p6 = "c"
interval = "6 weeks"
case wks <=14
tbl.p12 = "c"
interval = "12 weeks"
case wks <=30
tbl.p26 = "c"
interval = "26 weeks"
case wks <= 60
tbl.p52 = "c"
interval = "52 weeks"
case wks <= 120
tbl.p104 = "c"
interval = "2 years"
case wks <= 162
tbl.p156 = "c"
interval = "3 years"
case wks <= 215
tbl.p208 = "c"
interval = "4 years"
case wks <= 270
tbl.p260 = "c"
interval = "5 years"
text = "Weeks = " + wks + "Interval = " + interval
ui_msg_box("Interval and Weeks",text)
end select
while .not. tbl.eof()
while .not. ftbl.eof()
tbl.dof = ftbl.dof
wks = tbl.wksfu
select
case wks < 4
tbl.p2 = "c"
interval = "2 weeks"
case wks <= 7
tbl.p6 = "c"
interval = "6 weeks"
case wks <=14
tbl.p12 = "c"
interval = "12 weeks"
case wks <=30
tbl.p26 = "c"
interval = "26 weeks"
case wks <= 60
tbl.p52 = "c"
interval = "52 weeks"
case wks <= 120
tbl.p104 = "c"
interval = "2 years"
case wks <= 162
tbl.p156 = "c"
interval = "3 years"
case wks <= 215
tbl.p208 = "c"
interval = "4 years"
case wks <= 270
tbl.p260 = "c"
interval = "5 years"
text = "Weeks = " + wks + "Interval = " + interval
ui_msg_box("Interval and Weeks",text)
end select
end while
end while
tbl.change_end()
Comment