Navigation:  Reference > Functions >

GetKeyNumber()

Print this Topic Previous pageReturn to chapter overviewNext page

 

GET_KEY_NUM(1)

 

PURPOSE

This function will return the internal number for a key depending on the key name passed to the function.

 

PARTS

 

1 f/c/eRequired - The name of the key.  Must be the same as what you've specified in the data dictionary.

 

RETURN TYPE - I        

NOTE:  If the key was not found in the FILEKNUM file, the returned value will be 0.

 

COMMENTS

This is a quick and easy way to change the index for a command that uses keys, such as SCAN without using the SRCH command, etc.

 

EXAMPLE

This code is directly out of the print journals in Adv 7.

  define key_num type i

  define by_trans type l

  if from.post.date<>0

    findv g fnum bkgltran_hndl key bkgl.trn.date value from.post.date

    key_num = get_key_num('bkgl.trn.date')

     by_trans = false

  else

    findv g fnum bkgltran_hndl key bkgl.trn.date value from.post.date

    key_num = get_key_num('bkgl.trn.num')

     by_trans = true

  endif

  scan @bkgltran_hndl key @key_num for chk_recs() while .n. fini

       //rest of code here.

  ends

 

func chk_recs

  if thru.post.date<>0 .a. thru.post.date < bkgl.trn.date

       fini=.t.

      ret .f.

  endif

  if post.choice='' then ret .t.

  if bkgl.trn.type <> post.choice then ret .f.

  ret .t.

 

 

 

 

 


Page url: http://www.cassoftware.com/tas/manual/getkeynumber().htm