I thought I would ask those who know ALOT MORE about Xbasic than I do ...
I am going to have to parse at least 8 different values from a field and make decisions from that.
In the Code I have so far I have 8 IF statements ... the program multiplies 2 different numbers based on the 2 pairs of 2 chars it decodes. I am going to end up with at least 12 - 16 IF by the time I finish decoding all the values.
What has your experience been on SPEED?? This loop will have to be executed 1 time for every record in this customer database (7000 records and growing)? And this program will run 1 time per day.
I was wondering CASE / IF / SOMETHING ELSE / what executes faster? Or is it all about the same?
Below I have included 2/3 of the loop decoding but I have 1/3 left to do. I looked at the coding for CASE and it didn't seem to save me anything ... I am wanting to do it the best way. I also considered doing a FOR I = 1 to recno ... but I didn't really see that helping much either.
p.s. my code was indented correctly I am new here and forgot this window flattens my code if I don't put it in the special window.
Thanks for Your Help in Advance!!
Jim Coyle
Code here ...........
ptr = table.open("people")
recno = ptr.records_get()
while .not. ptr.fetch_eof()
ptr.change_begin()
ph_prg = ptr.ph_code
last_p = ptr.last_ph
con_prg = ptr.con_code
last_c = ptr.last_con
times = val(right(ph_prg,1))
if left(ph_prg,1)="S" then
call_p = 1
end if
if left(ph_prg,1)="W" then
call_p = times/7
end if
if left(ph_prg,1)="M" then
call_p = times/30
end if
if left(ph_prg,1)="Y" then
call_p = times/365
end if
ph_flg = (date()-last_p)*call_p
if ph_flg >= 1 then
ptr.ph_flg=.t.
else
ptr.ph_flg=.f.
end if
times = val(right(con_prg,1)) ' caution I reassign (REUSE) TIMES here ...
if left(con_prg,1)="W" then
call_c = times/7
end if
if left(con_prg,1)="M" then
call_c = times/30
end if
if left(con_prg,1)="Y" then
call_c = times/365
end if
con_flg = (date()-last_c)*call_c
if con_flg >= 1 then
ptr.con_flg=.t.
else
ptr.con_flg=.f.
end if
ptr.change_end(.t.)
ptr.fetch_next()
end while
ptr.close()
ui_msg_box("PEOPLE Records have been Updated-",recno)
end
I am going to have to parse at least 8 different values from a field and make decisions from that.
In the Code I have so far I have 8 IF statements ... the program multiplies 2 different numbers based on the 2 pairs of 2 chars it decodes. I am going to end up with at least 12 - 16 IF by the time I finish decoding all the values.
What has your experience been on SPEED?? This loop will have to be executed 1 time for every record in this customer database (7000 records and growing)? And this program will run 1 time per day.
I was wondering CASE / IF / SOMETHING ELSE / what executes faster? Or is it all about the same?
Below I have included 2/3 of the loop decoding but I have 1/3 left to do. I looked at the coding for CASE and it didn't seem to save me anything ... I am wanting to do it the best way. I also considered doing a FOR I = 1 to recno ... but I didn't really see that helping much either.
p.s. my code was indented correctly I am new here and forgot this window flattens my code if I don't put it in the special window.
Thanks for Your Help in Advance!!
Jim Coyle
Code here ...........
ptr = table.open("people")
recno = ptr.records_get()
while .not. ptr.fetch_eof()
ptr.change_begin()
ph_prg = ptr.ph_code
last_p = ptr.last_ph
con_prg = ptr.con_code
last_c = ptr.last_con
times = val(right(ph_prg,1))
if left(ph_prg,1)="S" then
call_p = 1
end if
if left(ph_prg,1)="W" then
call_p = times/7
end if
if left(ph_prg,1)="M" then
call_p = times/30
end if
if left(ph_prg,1)="Y" then
call_p = times/365
end if
ph_flg = (date()-last_p)*call_p
if ph_flg >= 1 then
ptr.ph_flg=.t.
else
ptr.ph_flg=.f.
end if
times = val(right(con_prg,1)) ' caution I reassign (REUSE) TIMES here ...
if left(con_prg,1)="W" then
call_c = times/7
end if
if left(con_prg,1)="M" then
call_c = times/30
end if
if left(con_prg,1)="Y" then
call_c = times/365
end if
con_flg = (date()-last_c)*call_c
if con_flg >= 1 then
ptr.con_flg=.t.
else
ptr.con_flg=.f.
end if
ptr.change_end(.t.)
ptr.fetch_next()
end while
ptr.close()
ui_msg_box("PEOPLE Records have been Updated-",recno)
end
Comment