×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Displaying specific elements of a program array in a screen array.

Displaying specific elements of a program array in a screen array.

Displaying specific elements of a program array in a screen array.

(OP)
Hi everyone,
I'm having lots of trouble with this one (I'm new to Informix 4gl).

Situation.
  There is a screen with 2 screen arrays in the middle display some budget information (group / $amount added) and (group / $amount subtracted).

Steps leading to the problem.
  1. I have a screen array loaded by a program array.
  2. I select a row in either of the arrays.
  3. I delete the row (F2).

Problem.
  The index that becomes selected after the deletion is the very 1st one in the program array.  This is a big problem when you want to delete rows say... 100 lines down, as it keeps sending you back up to the 1st row after each deletion.. forcing you to scroll down every time.

Question.
  How can I keep the elements of the program array around the one I was deleting as the ones being currently displayed in the screen arrays?

There doesn't seem to be a function for setting the "view" of the screen arrays to any particular elements in the program array.

Thanks!

RE: Displaying specific elements of a program array in a screen array.

In the older versions of Informix 4GL, what you described - deleting a row and sending the cursor back to row 1 - actually was an issue.  I'm using 7.3UC7 and it appears to work.  Perhaps you are using an older version.

In the old days, I dreamed up a kludge to get around this problem:  Create a dummy_char NOENTRY on the screen field.  When you press delete, set variable cur_ptr to the current row numer, exit input and re-enter the input array statement.  In the BEFORE ROW section send the cursor to the noentry field and decreate the row number until cur_ptr = 0 and that puts the user at the point was delete was executed.

This is defintely a kludge.  If you have a lot of rows, you'll see screen flicker.  Sorry, can't help it.

Let's look at an example:  Given this test table:

CODE

create table ttest      
  (
    col1 char(10),
    col2 char(10)
  );

and this screen form xx_ttest.per (note the noentry column):

CODE

database mytest
screen
{
   col 1        col2
[f000       |f001        |e]
[f000       |f001        |e]
[f000       |f001        |e]
[f000       |f001        |e]
[f000       |f001        |e]
}
end
tables
ttest
attributes
f000 = FORMONLY.col1 TYPE CHAR;
f001 = FORMONLY.col2 TYPE CHAR;
e    = FORMONLY.dummy_char TYPE CHAR, NOENTRY;
INSTRUCTIONS
DELIMITERS " "
SCREEN RECORD sa_ttest [5] (col1, col2, dummy_char)
end

Here is the test 4GL code.  Let me know if you have any questions:

CODE


DATABASE mytest

MAIN

   DEFINE
      p_ttest RECORD LIKE ttest.*,
      pa_ttest ARRAY[20] OF RECORD
         col1 LIKE ttest.col1,
         col2 LIKE ttest.col2,
         dummy_char CHAR(1)
      END RECORD,
      exit_flag,i SMALLINT,
      cur_ptr SMALLINT,
      curr_pa, curr_sa, cur_row SMALLINT

   DEFER INTERRUPT
   WHENEVER ERROR CONTINUE

   INITIALIZE pa_ttest[1].* TO NULL
   FOR i = 2 TO 20
      LET pa_ttest[i].* = pa_ttest[1].*
   END FOR

   DECLARE open_eds CURSOR FOR
      SELECT * FROM ttest
   LET i = 0
   FOREACH open_eds INTO p_ttest.*
      LET i = i + 1
      LET pa_ttest[i].col1 = p_ttest.col1
      LET pa_ttest[i].col2 = p_ttest.col2
   END FOREACH

   OPEN WINDOW w_ttest AT 3,3 WITH FORM "xx_ttest"
      ATTRIBUTE (BORDER,FORM LINE 1,MESSAGE LINE last)
      OPTIONS NEXT KEY F32, PREVIOUS KEY F33,ACCEPT KEY CONTROL-B,
         INSERT KEY F34, DELETE KEY F2

   LET exit_flag = FALSE
   LET int_flag = FALSE
   CALL set_count(i)
   WHILE exit_flag = FALSE
      LET exit_flag = TRUE
      INPUT ARRAY pa_ttest WITHOUT DEFAULTS FROM sa_ttest.*

         ON KEY (interrupt)
            LET exit_flag = TRUE
            EXIT INPUT

         BEFORE ROW
            # go to next row until the "deleted row" is reached
            LET curr_pa = ARR_CURR()
            LET curr_sa = SCR_LINE()
            IF cur_ptr > 1
            THEN
               IF curr_pa = cur_row
               THEN
                  LET cur_ptr = 0
                  NEXT FIELD col2
               ELSE
                  LET cur_ptr = cur_ptr -1
                  NEXT FIELD dummy_char
               END IF
            END IF

         AFTER DELETE
            IF curr_pa > 1
            THEN
               LET exit_flag = FALSE
               LET cur_ptr = curr_pa
               LET cur_row = curr_pa - 1
               EXIT INPUT
            END IF

         BEFORE FIELD col1
            LET curr_pa = ARR_CURR()
            LET curr_sa = SCR_LINE()
            IF int_flag = TRUE
            THEN
               IF curr_pa > 1
               THEN
                  LET exit_flag = FALSE
                  LET cur_ptr = curr_pa
                  LET cur_row = curr_pa - 1 # previous row
                  INITIALIZE pa_ttest[curr_pa].* TO NULL
                  EXIT INPUT
               END IF
            END IF

      END INPUT

   END WHILE

   LET exit_flag = FALSE

END MAIN





Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close