AppCtrlScript

MAY Computer

Help

STRWHICHPART

Applies to  

AppCtrlScript (Module: wmACScr1.dll)

Group  

String

See also  

STRPART,STRPARTS, STRFIRSTPART, STRLASTPART, STRSTRIPFIRSTPART, STRSTRIPLASTPART

Retrieves the index of the first subitem/substring that can be found in a given source string or matches a pattern by using the given separation string.

The result is a number that can be used for calculations and retrieving other parts of the source string using STRPART .

If item cannot be found in source string the result is 0 (zero).

 

Syntax

STRWHICHPART <VariableName>, <String>, <Pattern>[, <SepStr>][, <UsePattern>][, <StripSpaces>]

Part

Description

<VariableName> Name of the script variable where to store the result.
<String> Source string.
<Pattern> Search substring or pattern to search for in string parts.
<SepStr> Optional substring that separates the different items. If missing the program tries to find a fitting character like |, /, \, ., ,, ; (the first of these that can be found somewhere in the string is assumed to be the separation character).
<UsePattern> 1|0; Flag if passed pattern is a fix substring or a pattern (containing * and ? for example). If case should be ignored than use 1. Default is 1. If 0 then subitem must match completely the given pattern (not only pattern being a substring).
<StripSpaces> 0|1; Flag if all spaces should be ignored/removed for string/pattern comparison. Default is 0.

 

Sample

SETVAR FileName, "F:\Data\Department5\MyProject\MySubProject\TechDoc\Draft\FirstSpecification.pdf"
STRWHICHPART IsTechDoc, "%SCR.FileName%", "TechDoc", "\"
;Result in "MyItem" will be "6".
CALC DocType=%SCR.IsTechDoc%+1
STRPART DocType, "%SCR.FileName%", %SCR.DocType%
;Result in "DocType" will be "Draft".