basic.swap

Function/BASIC Program, Releases: AP 6.2 and R91

Searches the 'string.expression' for the 'start'-th instance of the 'search.string', then replaces 'search.string' with 'replacement.string' for the next 'occurances' instances. If occurances is not specified, all occurances are replaced. If start is miss

Syntax

swap(string.expression,search.string,replacement.string{,occurances{,start}})

Description

searchs a 'string.expression' for the 'search.string' and then, if at the 'start' occurrence, will replace 'search.string' with 'replacement.string' for 'occurrences' occurrences. If 'start' or 'occurrences' are omitted, they will default to 1 and 0 respectively. An 'occurrence' setting of 0 will replace all occurrences of 'search.string' with 'replacement.string'.

Example

nstring = swap('The new time','new','old')
The assigns the value 'The old time' to nstring.

print swap('---','-','+',2,1)
This will output '-+-'. The 'swap' function will replace
one occurrence of '-' starting at the second occurrence.

See Also

Command Name Type Description
basic.statements Definition Definition of statements and functions.
basic.string.expression Definition An expression which evaluates to a string.
basic.$options Statement Sets compatibility options for the BASIC compiler.
basic.ereplace Function
basic.change Function

User Comments

What do you think?

Share your experience or ask a question by using the form below.

Login to leave your comments.