Simple Progress Code

nate100

Member
Hello,
I know this may be easy but I want to find the easiest way to code this. I have a temp table that is populated.
I like to use the up and down arrrow to navigate through the records.
I like to use the F5 key to delete the record I am on. On F4, I like to exit out of the loop. Once I am out of the loop (For each), I am showing what the table looks like after the update/delete, etc.

Here is the code I have:

def var i as int.
def temp-table temptb
FIELD temp_addr as char
FIELD temp_domain as char
FIELD temp_name as char.
do i = 1 to 5:
create temptb.
assign temp_addr = string(i)
temp_domain = "villi"
temp_name = string(i) + "Name".
end.
FORM
temp_addr label 'ID' skip(1)
temp_domain label 'Domain' skip(1)
temp_name label 'Name' skip(1)
with frame framea row 5 title 'Business Info'.

/* updating, deleting the record. I would also like to navigate to the next and previous records*/
for each temptb no-lock with side-labels frame framea :
update temp_addr.
display temp_domain temp_name.
/* F5 to delete the current record, F4 to exit from the loop Use the up arrow
to go to the previous record, use the down arrow to to go the next record*/
end.

/* look at the updated records */
for each temptb no-lock:
display temptb.
end.
 
You can't really use a for-each loop if you want to move around the list.

What we do is to set up a query, find the first one, display the information, then wait-for a particular keypress.

We have a statement:

on cursor-up, cursor-down anywhere run p_cursor.

p_cursor checks the field concerned (if self:name = ??? then ???) and finds the prev/next field in the query, displays it and allows the user to view/update it.

So, on a basic level, not using queries, you might have:

procedure p_cursor:
def var self_name as char no-undo.
def var this_lastkey as int no-undo.
this_lastkey = lastkey.
self_name = self:name. /* To stop self changing and messing up */
case self_name:
when "temp_addr" then do:
case keyfunc (this_lastkey):
when "cursor-up" then find prev temptb no-lock no-error.
when "cursor-down" then find next temptb no-lock no-error.
end case.
if not available temptb then do:
case keyfunc (this_lastkey):
when "cursor-up" then find first temptb no-lock no-error.
when "cursor-down" then find last temptb no-lock no-error.
end case.
end.
end.
end case.
end procedure.
 
Back
Top