求fortran中scan的用法,之前搜到一点介绍但是没明白。。。
发布网友
发布时间:2022-06-14 12:37
我来回答
共1个回答
热心网友
时间:2023-10-18 21:28
各家编译器都会带有帮助信息,其中就有语法内函数的介绍。
SCAN
Elemental Intrinsic Function (Generic): Scans a string for any character in a set of characters.
Syntax
result = SCAN (string, set [, back])
string
(Input) Must be of type character.
set
(Input) Must be of type character with the same kind parameter as string.
back
(Input) Must be of type logical.
Results:
The result type is default integer.If back is omitted (or is present with the value false) and string has at least one character that is in set, the value of the result is the position of the leftmost character of string that is in set.If back is present with the value true and string has at least one character that is in set, the value of the result is the position of the rightmost character of string that is in set.If no character of string is in set or the length of string or set is zero, the value of the result is zero.Compatibility
CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB
See Also: VERIFY
Examples
SCAN ('ASTRING', 'ST') has the value 2.SCAN ('ASTRING', 'ST', BACK=.TRUE.) has the value 3.SCAN ('ASTRING', 'CD') has the value zero.The following shows another example: INTEGER i
INTEGER array(2)
i = SCAN ('FORTRAN', 'TR') ! returns 3
i = SCAN ('FORTRAN', 'TR', BACK = .TRUE.) ! returns 5
i = SCAN ('FORTRAN', 'GHA') ! returns 6
i = SCAN ('FORTRAN', 'ora') ! returns 0
array = SCAN ((/'FORTRAN','VISUALC'/),(/'A', 'A'/))
! returns (6, 5)
! Note that when using SCAN with arrays, the string
! elements must be the same length. When using string
! constants, blank pad to make strings the same length.
! For example:
array = SCAN ((/'FORTRAN','MASM '/),(/'A', 'A'/))
! returns (6, 2)
END
求fortran中scan的用法,之前搜到一点介绍但是没明白。。。
SCAN ('ASTRING', 'ST') has the value 2.SCAN ('ASTRING', 'ST', BACK=.TRUE.) has the value 3.SCAN ('ASTRING', 'CD') has the value zero.The following shows another example: INTEGER i INTEGER array(2)i = SCAN ('FORTRAN', 'TR') ! returns 3 i = SCAN ('FORTRAN...