Interpreting IDescriptors - PowerPoint PPT Presentation

1 / 37
About This Presentation
Title:

Interpreting IDescriptors

Description:

An I-Descriptor is exactly a single line of code that creates ... concatenated by combining using a colon X:Y ... code statements separated by semi-colons ... – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 38
Provided by: scottm
Category:

less

Transcript and Presenter's Notes

Title: Interpreting IDescriptors


1
Interpreting I-Descriptors
  • Bridgewater College
  • Information Technology Center
  • Scott A. Moomaw

2
How Do I-Descriptors Work?
  • An I-Descriptor is exactly a single line of code
    that creates a value for a field by using other
    fields, programming logic, and subroutines
  • I-Descriptors do not represent fields that are
    physically stored, they are created on the fly
  • Field 2 of the dictionary contains their code

3
Sample I-Descriptor
  • GRAND.TOTAL I-Descriptor
  • 001 I
  • 002 SUBTOTAL TAX
  • 003 MD2,
  • 004 Total Amt
  • 005 10R
  • 006 S
  • 007

Adds the contents of the two fields, SUBTOTAL and
TAX
4
Other Fields and Constants
  • You can reference the value of others fields
    within an i-descriptor by naming them
  • The example earlier referenced two fields
  • Numerical constants can be included by value
  • String constants must be enclosed in quotes

5
Simple String Operations
  • Strings can be concatenated by combining using a
    colon XY
  • String extraction is possible using the
    operators
  • stringx,y
  • Extract y characters from the string beginning at
    position x

6
Simple Arithmetic Operations
  • Standard mathematical operations are allowed
  • In the example earlier, you will note that two
    fields are added
  • , -, , /
  • or (exponentation)

7
Some Special Variables
  • _at_DATE Todays date in internal format
  • _at_FM represents a field mark
  • _at_ID current records ID
  • _at_RECORD current record
  • _at_SM subvalue mark character
  • _at_VM value mark character

8
Built-in Functions
  • I-descriptors can rely upon numerous built-in
    functions to expand their capabilities
  • Some of the standard functions work only with
    single-valued fields while others work well with
    multi-valued fields
  • Many of the same functions from Unibasic are
    usable in i-descriptors

9
TRANS
  • The TRANS function allows you to take data from
    one file and use it to go get info from another
    file
  • For instance, in file A, you may have a field
    that contains a list of MAJORS for a person. You
    can use a TRANS to go to the MAJORS file to get
    the actual descriptions for the majors.

10
TRANS Syntax
  • TRANS(lookup.file, keys.to.new.file,
    field.to.return, code)
  • lookup.file is the file that you are going to
    in order to get information
  • key.to.new.file is the keys to the records that
    you need info from
  • field.to.return is the field to return
  • code is what to do when failure occurs
  • Often code is x meaning null on failure

11
Example TRANS
  • TRANS(MAJORS, B55.MAJOR, MAJ.DESC, X)
  • From the PERSON file, go to the MAJORS file and
    get the MAJ.DESC field for each of the elements
    in the field named B55.MAJOR

12
Arithmetic Functions
  • ABS(x)
  • Used to compute the absolute value of x
  • ATAN(x), COS(x), SIN(x), TAN(x)
  • Compute proper trigonometric function
  • EXP(x)
  • Raise e to the value of x
  • LN(x)
  • Natural log of x

13
Arithmetic Functions
  • INT(X)
  • Integer portion of x
  • PWR(X,Y)
  • Raise x to the power of y
  • RND(X)
  • Return a random number less than x
  • SQRT(X)
  • Take square root of x

14
Date/Time Functions
  • DATE()
  • System date in internal format
  • TIME()
  • System time in internal format
  • TIMEDATE()
  • External time and date

15
Counting Functions
  • COUNT(A,B)
  • Find the number of occurrences of B in A
  • DCOUNT(A)
  • Count the number of values in A
  • LEN(A)
  • Number of characters in A

16
Character Set Operations
  • CHAR(X)
  • Converts X to the equivalent xth ASCII character
  • SEQ(X)
  • Find ordinal value for the ASCII character X

17
Removing Blanks From Strings
  • TRIM(A)
  • Removes all extra blanks from A (beginning,
    ending, and multiple consecutive in the middle)
  • TRIMB(A)
  • Remove trailing blanks from A
  • TRIMF(A)
  • Remove leading blanks from A

18
Case Conversion In Strings
  • DOWNCASE(A)
  • Change all characters in A to lower case
  • UPCASE(A)
  • Change all characters in A to upper case

19
String Manipulation
  • CONVERT(A,B,C)
  • Convert all occurrences of character A to
    character B in string C
  • A and B are characters, not strings
  • EXTRACT(A,X,Y,Z)
  • Return the appropriate field, value, or subvalue
    from string A

20
String Manipulation
  • FIELD(A,B,X,Y)
  • Using B as a delimiter return X substrings from A
  • If Y is specified start at the Yth substring
    otherwise, start at the beginning of A
  • FMT(A,B)
  • Apply the formatting specified in B to string A

21
String Manipulation
  • ICONV(A,B)
  • Apply the conversion of B to string A to convert
    from external to internal format
  • INDEX(A,B,X)
  • Find the beginning position of string B in string
    A
  • OCONV(A,B)
  • Convert A using conversion B from internal to
    external format

22
String Manipulation
  • SPACE(X)
  • Make a string which contains X spaces
  • STR(A,X)
  • Make a string consisting of X occurrences of
    character A
  • SUM(A)
  • Sum each of the value-mark separated values in A

23
_at_FM, _at_VM, _at_SM
  • Fields, values, and subvalues can be considered
    the same as special delimiters
  • LOWER(X)
  • Lower each delimiter in X by one level
  • RAISE(X)
  • Raise each delimiter in X by one level

24
Quick Peek Record Layouts
  • The individual fields in a record a delimited
    using a special character called a field mark
    (_at_FM), values are delimited by value marks (_at_VM),
    and subvalues by sub-value marks (_at_SM)
  • These special delimiters are physical ASCII
    characters and can be treated as normal
    characters or used as delimiters

25
Multi-valued Processing
  • Some functions only work on single-valued fields,
    but they have multi-valued equivalents
  • When using the MV function, it is invoked as a
    subroutine

26
Single / MV Function Equivalents
  • COUNT(X,Y)
  • SUBR(-COUNTS,X,Y)
  • FIELD(A,B,X,Y)
  • SUBR(-FIELDS,A,B,X,Y)
  • FMT(A,B)
  • SUBR(-FMTS,A,B)
  • ICONV(A,B)
  • SUBR(-ICONVS,A,B)

27
Single / MV Function Equivalents
  • INDEX(A,B,X)
  • SUBR(-INDEXS,A,B,X)
  • LEN(X)
  • SUBR(-LENS,X)
  • OCONV(A,B)
  • SUBR(-OCONVS,A,B)

28
Subroutines
  • You can call custom subroutines from within
    I-descriptors
  • The syntax is
  • SUBR(subrname,arg1,arg2argn)

29
Common SUBR IF.LIST
  • SUBR(IF.LIST,LIST1,VALUES,LIST2)
  • Will return values from LIST2 that are in the
    corresponding rows in LIST1 where the item from
    LIST1 is listed among the VALUES

30
IF.LIST Example
  • SUBR(IF.LIST, A_at_VMB_at_VMA,
  • A,
  • 1_at_VM2_at_VM3)
  • Will return 1 and 3. These values correspond to
    the items in list1 which are in the values being
    sought.

31
Nesting Code
  • You can nest code in an i-descriptor to get more
    flexibility
  • UPCASE(TRANS(STATES, STATE, ST.DESC, X))

32
IF/THEN/ELSE
  • You can perform logic operations with
    IF/THEN/ELSE
  • IF condition1 THEN returnthis ELSE returnthat
  • IF STATE EQ VA THEN UPPERCASE(CITY) ELSE STATE
  • (Will provide an uppercase version of CITY for VA
    residents and STATE for others)

33
Compound Statements
  • Instead of deeply nesting code, you can use
    compound statements to improve readability
  • Simply list multiple code statements separated by
    semi-colons
  • The last statement is responsible for returning
    the fields value

34
Compound Statements
  • You can reference earlier pieces of a compound
    statement by using _at_n notation
  • If you want to reference with first statement
    from within the second statement, use _at_1
  • This can greatly simply the look of an
    I-descriptor by achieve the same function

35
Compound Statement Example
  • TRANS(STATES,STATE, ST.DESC,X)
    UPCASE(CITY) IF STATE EQ VA THEN _at_1 ELSE _at_2
  • Will perform the same thing as the nested example
    earlier

36
Compiling Dictionary Elements
  • Dictionary elements need to be compiled for
    general use
  • Use the CD command
  • CD FILENAME IDESCNAMES
  • CD B55.DRT MYIDESC

37
ExercisesUnderstanding I-Descriptors
Write a Comment
User Comments (0)
About PowerShow.com