1. Strings

Introduction

CODE
% returns "\n"
% two characters, \ and an n
SAVE
LC 00004 RES.STR
LC 6E5C DAT0=C.4
A=R0.A
LOAD
GOVLNG PUSHA % $03A86
ENDCODE

CODE
% returns "Jon 'Maddog' Orwant"
% literal single quotes
SAVE
LC 00026 RES.STR
C=PC GOINA "STRING"
A+C.A
D1=A
C=DAT1.16 DAT0=C.16 D0+16 D1+16
C=DAT1.16 DAT0=C.16 D0+16 D1+16
C=DAT1.6 DAT0=C.6
A=R0.A
LOAD
GOVLNG PUSHA % $03A86
*STRING
$A4F6E60272D4164646F6767202F4277716E64755 % Jon 'Maddog' Orwant
ENDCODE

CODE
% returns a newline character
SAVE
LC 00002 RES.STR
LC 0A DAT0=C.2
A=R0.A
LOAD
GOVLNG PUSHA % $03A86
ENDCODE

CODE
% returns 'Jon "Maddog" Orwant'
% literal double quotes
SAVE
LC 00026 RES.STR
C=PC GOINA "STRING"
A+C.A
D1=A
C=DAT1.16 DAT0=C.16 D0+16 D1+16
C=DAT1.16 DAT0=C.16 D0+16 D1+16
C=DAT1.6 DAT0=C.6
A=R0.A
LOAD
GOVLNG PUSHA % $03A86
*STRING
$A4F6E60222D4164646F6762202F4277716E647 % Jon "Maddog" Orwant
ENDCODE

Accessing Substrings

CODE
% level 2 : string
% level 1 : offset (binary integer)
% level 1 : count (binary integer)
% returns the substring.
% WARNING : no check done.
SAVE
GOSUB "VALUES" %(count)
R1=C.A
D1+5
GOSUB "VALUES" %(offset)
D1+5
A=DAT1.A %(string)
A+10.A A+C.A R2=A.A %@ where write
C=R1.A RES.STR
CD0EX D1=C
C=R2.A D0=C
C=R1.A GOSBVL MOVEDOWN %$0670C
LOAD
A=R0.A
GOVLNG PUSHA % $03A86
*VALUES
C=DAT1.A C=C+5.A D0=C
A=DAT0.A A=A-6.A %length-1
LC 00005
?A<C.A SKIPYES { LC 4 } % C=max(A,00004)
P=C.0
D0+5 C=DAT0.WP % get datas
P=0 C+C.A
RTN
ENDCODE

Establishing a Default Value

Exchanging Values Without Using Temporary Variables

Converting Between ASCII Characters and Values

Processing a String One Character at a Time

Reversing a String by Word or Character

Expanding and Compressing Tabs

Expanding Variables in User Input

Controlling Case

Interpolating Functions and Expressions Within Strings

Indenting Here Documents

Reformatting Paragraphs

Escaping Characters

Trimming Blanks from the Ends of a String

Parsing Comma-Separated Data

Soundex Matching

Program: fixstyle

Program: psgrep