A Sample INPUT ARRAY Hack
Posted in 1992
To in some small way echo the sentiments of Don Bolton on the intricacies
of INPUT ARRAY, I hold up for show and tell this frag of an INPUT ARRAY
that supposedly will allow a user to back out of deleting a row in the
array. If the user does not confirm delete then the while loop continues
with a new INPUT ARRAY. I think this even works but look how complicated it
gets. I modified ideas given to me by a couple of helpful readers of this
newsgroup. It uses a backup array and "skip fields" on the form.
call set_count(arrcount)
display form items
let reverse_delete = "y"
let oldrow = 1
while reverse_delete = "y"
call set_count(arrcount)
let reverse_delete = "n"
let shadow = "n"
let int_flag = 0
input array p_items without defaults from s_items.*
before row
if shadow = "y" then
for counter = arr_curr() to arr_count()
let p_items2[counter].* = p_items2[counter + 1].*
end for
end if
let arrcurr = arr_curr()
let arrcount = arr_count()
let scrline = scr_line()
if arrcurr <= arrcount then
display p_items[arrcurr].* to s_items[scrline].*
end if
before field number
let newrow = arr_curr()
if oldrow > newrow then
next field dummy
end if
if oldrow = newrow then
let oldrow = null
end if
before insert
display p_items[arrcurr].* to s_items[scrline].*
for counter = arr_count() to arr_curr() step -1
let p_items2[counter + 1].* = p_items2[counter].*
end for
initialize p_items2[arrcurr].* to null
let p_items2[arrcurr].selected = "N"
let shadow = "y"
after row
display p_items[arrcurr].* to s_items[scrline].*
let shadow = "n"
before delete
call confirm_item_delete() returning answer
if answer matches "[N|n]" then
let reverse_delete = "y"
let oldrow = arr_curr()
let arrcount = arr_count()
exit input
else
insert into del_table values (p_items2[arrcurr].itemnum)
for counter = arr_curr() to arr_count()
let p_items2[counter].* = p_items2[counter + 1].*
end for
end if
end input
end while