StartsWith, EndsWith Functions

Requires: GfaWinx.lg32

Purpose

Determines whether a sting begins or ends with a certain character.

Syntax

bool = EndsWith(source$, strcmp$ [, ignorecase? = False])
bool = StartsWith(source$, strcmp$ [, ignorecase? = False])

source$, strcmp$: string
ignorecase?: boolean

Description

These functions can be used to compare the start and end characters of a string with either a specific string or one stored in another variable. The third optional parameter determines whether case should be ignored in the comparison; this defaults to FALSE.

Example

Local a$ = "GFABasic with gfawinx", b$ = "nx"

Debug StartsWith(a$, "g")       // False - case sensitive

Debug StartsWith(a$, "g", True) // True - ignore case

Debug EndsWith(a$, b$)          // True - case sensitive

Debug EndsWith(a$, b$, True)    // True - ignore case

Debug.Show

See Also

FindFirstOf, FindLastOf, InStr, Left$, Mid$, Right$, RInStr.

{Created by James Gaite; Last updated: 18/12/2022 by James Gaite}