This is part of the HicEst documentation
CHARACTER: Specify and Initialize Character Strings
A character string is a contiguous sequence of bytes in memory. It must be specified before it is used in the script.
⇾Home
⇾Contents
⇾more Strings
⇾ Examples
Bookmarks:
⇾defining_a_string
⇾dynamically_change_string_length
⇾rename_or_shrink_a_string
⇾string_delimiters
⇾substring_definitions
see also
Strings
for more examples
defining_a_string
:
CHARACTER [::] string[*length] [/"inistring"/] [="inistring"]
! [ ] optional
length = a numerical constant known at compile time (
"Init
,
"Defi
) to assign the byte count to string, default is 1
inistring = a string constant like "hello world"
examples:
REAL
, PARAMETER :: n=100
! predefines a symbolic constant
CHARACTER :: StringName*n
CHARACTER StringName='initialization string defines length'
CHARACTER StringName * n /"initialization string of length n"/
CHARACTER StringName*123 = "initialization string of length 123"
CHARACTER :: a, b*2, c='xyz', d*n
! lengths are 1, 2, 3, 100 resp.
CHARACTER zoo*n, fish='eel', bird*20/'eagle'/
string_delimiters
: almost all non-alfanumeric and non-operator characters, e.g.:
CHARACTER a="double quote", b='single quote', c=%percent%, d=#number_sign#, e=.period.
CHARACTER special = ;string with "double and ' embedded single ' quotes" like this;
dynamically_change_string_length
:
ALLOCATE
(string, new_string_length)
ALLOCATE
is to
expand
a string only
to
rename_or_shrink_a_string
use the
ALIAS
function
ALLOCATE
(String, 2*
LEN
(String))
! this doubles current length
substring_definitions
:
substring = string(byte_nr)
! to reference a single character of a string
substring = string(start : [end])
substring = string(4:z)
! starts at byte 4 and extends to the current value of z
substring = string(start : )
! extends to end of string
ALIAS
(string,start, substring,
LEN
(string)-start+1)
! substring shares memory with string byte start to byte end
substring =
CHAR
(2, 4, 'ABC DEF GHI JKL ')
! substring 2 out of 4 equal length substrings is "DEF "
EDIT
(Text=string, Right='x', Mark1, Right='y', Parse=SubStringName)
more examples:
string = 'ABC..xyz'
! assign a constant, fill with trailing blanks
textA(i : i+8) = textB
i =
INDEX
(OtherString, "Hello")
! find the location of "Hello"
length_of_string =
Lengt
(string)
trimmed_length_of_string =
LEN_TRIM
(string)
⇾
Support HicEst
⇾
Impressum
©2000-2019 Georg Petrich, HicEst Instant Prototype Computing. All rights reserved.