Re: Question regarding positioning within "input array"
Posted in 1998
Ken Vaughn wrote: > OK, I was tired and in a hurry to go to bed when I posted the original > reply. Here is a bit more sensible code fragment that will actually > work: Ken, How do you adapt this code to go back to row 63 from row 97? Your code works to get the first row to the specified target row, but not (I think) for general motion within the array. Also, as you mention, it imposes a scrolling overhead. D4GL provides a function which displays a specified program array record on a specified screen array line, without scrolling everything in between. I accept that there are contorted mechanisms which can be made to work in at least some contexts -- I was too casual in stating it can't be done. But it is never elegant or easy. > define > p_items array[10] of record > field1 smallint, > field2 smallint, > next_row char[1] > end record > > let DesiredRow = 5 (or whatever row you want to go to) > input array p_items from s_items.* > before row > let CurrentRow=arr_curr() > if CurrentRow < DesiredRow > then > next field next_row > end if > Your field edits, etc. here. > end input > > In the form: > > database formonly > screen > { > [f001 ] [f002 ] [a] > [f001 ] [f002 ] [a] > [f001 ] [f002 ] [a] > [f001 ] [f002 ] [a] > } > attributes > f001 = formonly.field1; > f002 = formonly.field2; > a = formonly.next_row, noentry, noupdate; > > instructions > delimiters " " > screen record s_items[4](field1, field2, next_row) > > Note the delimiters clause in the instructions. If you don't do this, you > are going to have four pairs of brackets hanging around on the screen that > the cursor will never land in. This is what I meant by 'invisible' in last > nights abortive attempt at being helpful. The example below would also work, > assuming you fixed it initialize the counter to 0, not 1, in the before > input clause and to also increment the row counter before checking it in the > before row clause instead of assuming it is going to magically increment > itself for you, but the above is probably more intuitive and less prone to > being broken in subsequent modifications since all of the relevant code is > within one conditional block. > > Ken Vaughn wrote: > > > I would have to disagree with Jonathan on this one. It is possible, it's > > just not pretty. What you need to do is as follows: > > > > 1) Define an invisible field on your form. This field should be the last > > field in the access path for a row and be defined as no-entry/noupdate. > > > > 2) In your input array statement, you need to do the following. In the > > before input clause, you need to initialize a counter to 1. > > > > 3) In your before row clause, check the value of your counter against > > the value of the row that you want to go to. If it is less, do a next > > field <invisible field>. Since this is a noentry/noupdate field, the > > cursor will automatically skip to the next row in the array, activating > > the before row clause again, etc. until you reach your desired row. See > > the code fragment below for a short (syntactically incorrect) example. > > > > input array p_array > > before input > > let CurrentRow=1 > > before row > > if CurrentRow < DesiredRow > > then > > next field skip_field > > end if > > end input > > > > This can also be adapted to allow a conditional delete of an input > > array row. I will see if I can dig up the code and post it here if > > anybody is interested. One word of warning: If you have a lot of > > elements in your array and the row you want to go to is near the > > end, there is a very noticable scrolling effect and you may have > > more than one user get sick on their keyboard from watching it. > > > > Jonathan Leffler wrote: > > > On Thu, 9 Jul 1998, Denis Cloutier wrote: > > > > I'm on I-4GL version 6.05 and was wondering if [...] there's a > > > > way to position myself at an array element that I designate > > > > within an "input array" control block. > > > > > > This is not possible in Classic I4GL. > > > > > > On the other hand, it is possible in the new Dynamic 4GL. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix -- see http://www.perl.com/CPAN #include <disclaimer.h>