flibs/strings(n) 1.0 "flibs"
flibs/strings - Manipulate and store strings
TABLE OF CONTENTS
SYNOPSIS
DESCRIPTION
DATA TYPES
ROUTINES
COPYRIGHT
type(TEXT_STRING) |
type(MULITLINE_TEXT) |
use edit_text |
call edit_delete( string, pos, length ) |
call edit_insert( string, pos, substring ) |
use singleline_text |
length = txt_length( text ) |
call txt_cleanup( text ) |
pos = txt_index( text, substring, back ) |
call txt_from_string( text, string ) |
call txt_from_string( text, string ) |
call txt_read_from_file( lun, text, eof ) |
call txt_write_to_file( lun, text ) |
call txt_delete( text, pos, length ) |
call txt_insert( text, pos, substring ) |
use multiline_text |
length = mltxt_length( text ) |
length = mltxt_number( text ) |
call mltxt_cleanup( text ) |
call mltxt_insert( text, pos, line ) |
call mltxt_delete( text, pos ) |
call mltxt_get( text, pos, line ) |
|
The file textstr.f90 contains three fairly small modules,
designed for simple text manipulation and storage:
-
edit_text for simple editing of text strings.
-
singleline_text for storing a string of arbitrary length.
-
multiline_text for storing a set of strings of arbitrary
length, for instance a text file.
The facilities offered by these modules are geared to storage and
some basic manipulations. They are not meant to be a complete module for
arbitrary-length strings.
hence the module.
The modules singleline_text and multiline_text
each a suitable derived type:
- type(TEXT_STRING)
-
Type to hold a string of arbitrary length.
- type(MULITLINE_TEXT)
-
Type to hold a set of strings of arbitrary length.
The module edit_text contains the following routines:
- use edit_text
-
To import the subroutines, use this module.
- call edit_delete( string, pos, length )
-
Delete a substring from a string.
- character(len=*), intent(inout) string
-
String to be modified
- integer, intent(in) pos
-
Position of the first character to be deleted
- integer, intent(in) length
-
Length of the substring to be deleted
- call edit_insert( string, pos, substring )
-
Insert a substring into a string.
- character(len=*), intent(inout) string
-
String to be modified
- integer, intent(in) pos
-
Position after which to insert the substring (use 0
to insert it before the string)
- character(len=*), intent(in) substring
-
Subtring to be inserted
The module singleline_text contains the following routines:
- use singleline_text
-
To import the subroutines, use this module.
- length = txt_length( text )
-
Return the length of the text. As this is a pure function, you
cna use it to define temporary strings of the correct length.
- type(TEXT_STRING), intent(in) text
-
Text string to be examined
- call txt_cleanup( text )
-
Clean up the storage for a previous text string.
The result is an empty string.
- type(TEXT_STRING), intent(inout) text
-
Text string to be examined
- pos = txt_index( text, substring, back )
-
Return the index (position) of a substring in the text.
- type(TEXT_STRING), intent(in) text
-
Text string to be examined
- character(len=*), intent(in) substring
-
Substring to be found
- logical, optional, intent(in) back
-
Search from the start (.false.) or from the back (.true.)
- call txt_from_string( text, string )
-
Store a string in a text_string type. Trailing blanks
in the original string are explicitly stored.
- type(TEXT_STRING), intent(inout) text
-
Text string to be created/filled
- character(len=*), intent(in) string
-
Ordinary string to be copied into the text string
- call txt_from_string( text, string )
-
Store the contents of a text_string type in an ordinary string.
If the string is too short, the result will be a truncated string.
- type(TEXT_STRING), intent(in) text
-
Text string to be copied
- character(len=*), intent(out) string
-
Ordinary string to be filled
- call txt_read_from_file( lun, text, eof )
-
Read a text string from a file (one complete line).
- integer, intent(in) lun
-
The LU-number of the file
- type(TEXT_STRING), intent(out) text
-
Text string to be created/filled
- logical, intent(out) eof
-
Indicates whether end-of-file was reached or not
- call txt_write_to_file( lun, text )
-
Write a text string to a file (as one complete line).
If the LU-number is smaller/equal 0, it is written to
the screen.
- integer, intent(in) lun
-
The LU-number of the file
- type(TEXT_STRING), intent(in) text
-
Text string to be written
- call txt_delete( text, pos, length )
-
Delete a substring from a text string.
- type(TEXT_STRING), intent(inout) text
-
Text string to be modified
- integer, intent(in) pos
-
Position of the first character to be deleted
- integer, intent(in) length
-
Length of the substring to be deleted
- call txt_insert( text, pos, substring )
-
Insert a substring into a string.
- type(TEXT_STRING), intent(inout) text
-
String to be modified
- integer, intent(in) pos
-
Position after which to insert the substring (use 0
to insert it before the string)
- character(len=*), intent(in) substring
-
Subtring to be inserted
The module multiline_text contains the following routines:
- use multiline_text
-
To import the subroutines, use this module.
- length = mltxt_length( text )
-
Return the maximum length of all text strings stored. Useful to define
temporary strings.
- type(MULTILINE_TEXT), intent(in) text
-
Multiline text to be examined
- length = mltxt_number( text )
-
Return the number of text strings stored.
- type(MULTILINE_TEXT), intent(in) text
-
Multiline text to be examined
- call mltxt_cleanup( text )
-
Cleans up a multiline text - all text strings are deleted
temporary strings.
- type(MULTILINE_TEXT), intent(in) text
-
Multiline text to be cleaned up
- call mltxt_insert( text, pos, line )
-
Inserts a text string or an ordinary string as a new line of text after
the given position.
- type(MULTILINE_TEXT), intent(inout) text
-
Multiline text to be modified
- integer, intent(in) pos
-
Position after which to insert the new line (use 0
to make it the first line)
- (...), intent(in) line
-
Ordinary string or text_string variable holding the text that will be
inserted.
- call mltxt_delete( text, pos )
-
Delete the line at the given position.
- type(MULTILINE_TEXT), intent(inout) text
-
Multiline text to be modified
- integer, intent(in) pos
-
Position of the line to be removed.
- call mltxt_get( text, pos, line )
-
Return a pointer (!) to the line at the given position.
Note: no copy is made, but a pointer is returned. This means you can
change the line of text via this pointer.
- type(MULTILINE_TEXT), intent(inout) text
-
Multiline text to be examined
- integer, intent(in) pos
-
Position of the line to be returned
- type(TEXT_STRING), pointer line
-
Variable that will point to the line of text
Copyright © 2005 Arjen Markus <arjenmarkus@sourceforge.net>