Download presentation
Presentation is loading. Please wait.
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
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. Assumed Length Declarations
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 CHARICHARINDEXLEN LGELGTLLELGT
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
10
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.
11
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.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.