Cursor Positioning

Is the cursor positiong internal number in an ascending order?
I am trying to determine where to place my cursor depending on whether a field is open and where the input cursor was.

I am finding that for 10 fields on a map, from top to bottom, left to right, are in a haphazard number order.

I wanted to build a matrix of the fields, put in the cursor positioning number (i.e. POS (FIELD) and whether this field was open.

THen I wanted to compare if the cursor was ge field 1 position and less than filed 2 position. But on my map in debug, the physical progression of the fields is not ascending>

How can I code this? :?:

The POS function returns a value based on a field’s position in memory, not the position on a map. Think about it. What if a field was placed on two maps in the same program? What would POS return?

It doesn’t make sense to compare one field’s position to that of another field, but it does make sense to compare a field’s position to the cursor position. Here’s an example, tested with Natural 6.3.4.

DEFINE DATA LOCAL
1 #FLD-A (A5)
1 #FLD-B (A5)
1 #FLD-C (A5)
1 #FLD-A-POS (I4)
1 #FLD-B-POS (I4)
1 #FLD-C-POS (I4)
1 #MSG (A75)
1 #CURSOR (I4)
END-DEFINE
*
ASSIGN #FLD-A-POS = POS(#FLD-A)
ASSIGN #FLD-B-POS = POS(#FLD-B)
ASSIGN #FLD-C-POS = POS(#FLD-C)
*
DISPLAY #FLD-A-POS
        #FLD-B-POS
        #FLD-C-POS
*
REPEAT
  INPUT (AD=MDL) WITH TEXT #MSG
                      MARK #CURSOR
        #FLD-A
      / #FLD-B
      / #FLD-C
  ASSIGN #CURSOR = *CURS-FIELD
  DECIDE ON FIRST #CURSOR
    VALUE #FLD-A-POS
          ASSIGN #MSG = 'Cursor in #FLD-A'
    VALUE #FLD-B-POS
          ASSIGN #MSG = 'Cursor in #FLD-B'
    VALUE #FLD-C-POS
          ASSIGN #MSG = 'Cursor in #FLD-C'
    NONE
          IGNORE
  END-DECIDE
END-REPEAT
END

Of course you could create an array of position values, as you suggested, but I used elementary fields for simplicity.

Ralph: Thank you for your quick reply.

What you told me I knew and have already coded, but as my program has 4 screens all with many fields, I wanted a simpler ‘executing’ design.

My question is two fold:

Is there a Natural system value for next open field? If not, then I can load boolean switches as I open or close a field.

If you press enter in the middle of a field, such as a long name field, would *Cursor represent the beginning of the name field?

This would be important.

I was delighted that the POS returned a position in memory. SO that explains why I could not do what I wanted. I could have a matrix of field values and attributes, but if I use the 'common ’ coding it would be easier to maintain.

Yes, I thought about it, it makes sense that the positions reflect memory.

I am looking forward to your comments.

Michele;

What is it you are trying to accomplish? Are you trying to create a screen which basically does not tab geographically (left to right, top to bottom) but according to some predetermined sequence?

steve

Steve:

Yes I wanted to create a screen, that would tab geographically from top to bottom, from left to right. However if I discover an blank input field, and they pressed enter on this field. (I.e. input cursor is equal to this blank field) I wanted to position (mark) my cursor on next ‘open’ field on the screen. I predetermine by some business rules which field is open and that can vary according to the data that is loaded from the database.

So I was wondering if there was anyway to select the next open field? Is there a system variable? Right now I use BOolean switches and I also derived a matrix way of doing it, with boolean switches and POS, but both are complex.

I was hoping for a simpler way.

Thanks for your help.
Michele

Hi Michelle;

My guess, from your description, is that you are trying to “simulate” a PC interface using a Natural screen. The problem with this (assuming that is what you are trying to do), is that the “unit of I/O” for Natural is an entire screen, whereas for the Natural on the PC, for example, using Dialogs and Controls, the “unit of I/O” is a small as a keystroke.

Your solution sounds like a “classic” way around the difference in functionality. You let the user enter some data, then position the cursor and hit enter. You determine where the cursor was, then use MARK, either with REINPUT, or INPUT in a dummy REPEAT loop, to generate a “new” Map with the cursor at a position determined by what the user did and your program’s knowledge of the Map layout.

Yes, the code is ugly (complex, hard to document, etc), but it does work. I know, I have implemented similar code.

I will post (in a few minutes), a copy of Vol 12 No 4 of Inside Natural on the thread Natural General/Inside Natural. There is an article in this issue on Page 27 entitled “Scrolling through the park, vertically”. This might give you some ideas of how to approach coming up with a simpler solution to your problem.

steve

This is a follow-up and a NEW QUESTION on same subject.

ON the curser positionining, I discovered that if I set a variable (I4) to 1 and call it #mark,it goes to the first open (modifiable) field on a map. If I increase this by +1 it goes to the Next modifiable field on the map.

Is there anyway I can jump out of the map , indicating that I have checked all fields, ? When I add +1 to the bottom field’s check, I get sent back to the top of the Map, i.e. the First Open Field.

ANy help would be appreciated.

THanks Michele

Hi Michelle;

I am probably wrong about this, so please explain if the following is not correct:

It sounds to me that what you want to do is show the user a screen with say six modifiable fields. You want only field1 to be accessible. The user enters data in field1 and hits enter. You “analyze” what the user entered and now show the user the same screen but with field1 “locked” and, say, field4 accessible, and so forth.

Is this what you are trying to do? If so, it is quite simple to do with Control Variables.

There is an even easier approach, depending on what you want to do. The REINPUT statement has an option where you could code:

      REINPUT (AD=VP CD=PI) 'change pink fields' MARK FIELD #FIELDS (*)

#FIELDS (*) is an array. Suppose you want the third and fifth fields to be accessible and the other fields protected. You could have a three in fields (3) and a five in fields(5). Yes they could be in fields(1) and (2), but the coding is easier as shown.

Is this approximately what you are trying to do; or have i simply misread what you posted? If the latter, please clarify by a screen with say five fields and a description of how you want to interact with the user.

steve

Hi Steve, thank you for taking the time with this posting.

I have a screen with 5 fields. All fields are closed(display only) at beginning of program. As I read the database and discover that the ‘user’ sent us the information for their account’ , I determine which fields to open(modifiable), so that the operate can update the record.

Then I check the fields according to which ones I opened (boolean switch for each field). I process these switches in a logical order. If it passes the test at the first open field, I want the cursor to be positioned on the Next open field, which could be any of the remaining. At the bottom of the list, I want it to go to the next screen. I have a sample of my coding here. I have tried many ways of coding this.
The one that worked was if I used an array that held the boolean switch and its correspoding POS value of that field. HOWEVER that way is hard coding. You would always have to change the array if you have changed the map.
This program puts out 4 different maps for input all in the way manner.

I only want the operator to be shown the error once.

This is a high input data entry job, so we want to make sure that the operator checked that each ‘open’ field was examined.

Any help would be appreciated.

Field 1
FIeld 2
Field 3
Field 4
Field 5

One time FIeld 2 is open
Another time Field 1 and 5 is open.
Another time Field 2 and 4 are open.
etc.

The number of fields open is determined before the map is put out.

I know it is too much reading! :oops:

but thanks for getting thi far! :smiley:
Position Cursor Coding.txt (4.94 KB)

Oops, I forgot a picture of the map,
Here is one of the 4 maps, I have. :oops:
Map cursor positioning.txt (2.22 KB)

Hi Michelle;

Okay, now I have a LOT of questions. Suggest we take this offline, then, assuming we come up with a better approach, post the resultant code back online.

My e-mail is below

steve