1 / 11

8. Characters and Strings

8. Characters and Strings. HTML version. Properties. Length of every character variable must be specified in advance: CHARACTER STR*10 CHARACTER STRA(20)*10. Assumed Length Declarations. Character constants : CHARACTER STR*(*) PARAMETER ( STR  'This is a string' )

mercia
Télécharger la présentation

8. Characters and Strings

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 8. Characters and Strings HTML version

  2. Properties • Length of every character variable must be specified in advance: CHARACTER STR*10 CHARACTER STRA(20)*10

  3. Assumed Length Declarations • Character constants : CHARACTER STR*(*) PARAMETER ( STR  'This is a string' ) • Dummy character variable : CHARACTER STR*(*) Length of STR = Length of actual argument. STR is a passed-length dummy argument.

  4. Character assignments Padding and chopping are on the right. CHARACTER AUTHOR*30, SHORT*5, EXPAND*10 AUTHOR  'SHAKESPEARE, WILLIAM' SHORT  AUTHOR EXPAND = SHORT  SHORT is ‘SHAKE’ EXPAND is ‘SHAKE ’ ( with 5 trailing blanks )

  5. Character Substrings CHARACTER METAL*10 METAL  'CADMIUM'  METAL(2:4) gives ‘ADM’ METAL(:4) gives ‘CADM’ METAL(4:) gives ‘MIUM ’ ( with 3 trailing blanks ) METAL(8:8) gives ‘ ’ ( 1 blank )

  6. Character Expressions Concatenation operator // : ‘CAD’ // ‘MIUM’ gives ‘CADMIUM’ CHARACTER METAL*10 METAL  'CADMIUM'  METAL(4:) // METAL(2:4) gives ‘MIUM ADM’

  7. Character Intrinsic Functions CHAR ICHAR INDEX LEN LGE LGT LLE LGT

  8. CHAR(I) CHAR(48) gives 0 CHAR(65) gives A CHAR(97) gives a CHAR(1) gives Ctrl-A CHAR(27) gives ESC ICHAR(char) ICHAR(a) gives 106

  9. INDEX( string, pattern ) gives position of the 1st occurrence of pattern in string. Result is 0 if pattern is not in string. LEN(string) gives the length of string.

  10. Relational Expressions String1 .RO. String2 .EQ. .NE. .LT. .LE. .GT. .GE. ‘abc12’ .RO. ‘abcde’  ‘1’ .RO. ‘d’ LGE LGT LLE LGT LGE( ‘a’, ‘1’ ) is always equal to T.

More Related