[comp.lang.pascal] Fields on the screen for a DataBase

mshah@zodiac.rutgers.edu (12/03/90)

I am desiginig a database and I have a litte problem.  I hope that someone
out there can help me!  I need to know how I can use the direction keys to
identify different fields.  For example I have have 5 fields on the screen and
if the cursor is on field 3, and if the key read is Up how would I program it
so that it moves to the prevous field.

If someone has a source code of something semilar or any suggestions I would
appriciate you mailing them to me at:
MSHAH@ZODIAC
or
MSHAH@ZODIAC.RUTGERS.EDU

P.S.>  I am a beginner at programmer and I don't know how to use pointers.

Thanks in advance!!!!

einstein@quiche.cs.mcgill.ca (Michael CHOWET) (12/05/90)

In article <259.275a4a92@zodiac.rutgers.edu> mshah@zodiac.rutgers.edu writes:

>I need to know how I can use the direction keys to identify different fields.
>[etc..]

  I did something similar; I did a menu-driven security program for my
home PC, and the choices available through the managing utility had me up
against this same thing. ( I WAS going to do exactly what you are looking for,
but my parents decided that their company wasn't quite ready to computerize
their inventory/accounting/invoicing. But enough of that...

  About the fields... First, you need to know how to interpret the arrow
keys. I'll assume you know how, if not, just post back.

  Next, I suggest you keep an array, [ 0..Number_Of_Fields-1 ] of Record.
This record will store your X and Y coordintes (two integers, or bytes if 
memory's tight). 

  Now, before you hide under your bed at the sight of the upcoming word, give 
me chance. Now, keep a pointer (Arrrrrrgh! The P word! :-) to where you are. 
(Which field you're at). This would simply be an integer, not the built in 
pointer type. 

  Say you're at the first field, your pointer would hold 0. Hit the 
down-arrow, and the pointer jumps to 1, and you call GotoXY
with the parameters stored in your record (arr[pointer].X or .Y). 

  Now comes something a little tricky for beginners to Pascal. How do you
jump from the last field to the first? You could use an IF, but that isn't
elegant, and would probably go slower (but hey, who'd notice on a 
Cray, anyways?? :-). Instead, have you incrementer make use of a mod 
statement. The use would be something like 
  Point := ( Point + 1 ) Mod Number_Of_Fields ;

  You will probably need an if for a decrement, though.

>P.S.>  I am a beginner at programmer and I don't know how to use pointers.

  Now then, that wasn't so bad, was it?
-- 
==============================================================================
Today's message was brought to you by the letter 'S', the number 6, and

  		    =====> Einstein@cs.mcgill.ca  <====
             =====> Mike CHOWET | McGill CSUS VP External <=====

			Post back soon, now y'hear...
==============================================================================

eli@smectos.gang.umass.edu (Eli Brandt) (12/15/90)

In article <95@bart.cs.mcgill.ca> einstein@quiche.cs.mcgill.ca (Michael CHOWET) writes:
>In article <259.275a4a92@zodiac.rutgers.edu> mshah@zodiac.rutgers.edu writes:
>

 [discussion of fields stored in array deleted]

>  Now comes something a little tricky for beginners to Pascal. How do you
>jump from the last field to the first? You could use an IF, but that isn't
>elegant, and would probably go slower (but hey, who'd notice on a 
>Cray, anyways?? :-). Instead, have you incrementer make use of a mod 
>statement. The use would be something like 
>  Point := ( Point + 1 ) Mod Number_Of_Fields ;
>
>  You will probably need an if for a decrement, though.
>

One problem with using _mod_ here is that it's slower than _if_.  Relative
elegance is, I suppose, a matter of taste.  When you use _if_ it's a little
clearer what you're trying to do, though.