At 12:31 AM 8/19/2012, Michael J. Sinclair wrote:
Hi All,
When I have this statement in a command file...
SET VAR vtest INTEGER
SET VAR vtest = (SLOCP('abc','c',1))
I get a result of 0
I am trying to use the command to let me know that the 1st instance
of the character 'c' is at position 3.
Why am I gettting a 0?
The command works fine if the string is not in the last position.
What am I doing wrong?
Try the following three examples and see what results you get.
-- Syntax:
(SLOCP(TextNoteVarcharValue,string,occurrence))
SLOCP locates the exact position of a given string and occurrence
in a TEXT, NOTE or VARCHAR value.
-- Example 01:
SET VARIABLE v1 VARCHAR = 'ABCDEABC_AB'
SET VARIABLE vSLoc1 = (SLOCP(.v1,'AB',1))
Resulting variable vSloc1 will return the integer value of 1.
-- Example 02:
SET VARIABLE v1 VARCHAR = 'ABCDEABC_AB'
SET VARIABLE vSLoc2 = (SLOCP(.v1,'AB',2))
Resulting variable vSloc2 will return the integer value of 6.
The above two examples will locate the exact position of a
given string and occurrence. However, if you wish to find
the LAST occurrence in the value of your string, use the "-1".
Here's how:
-- Example 03:
SET VARIABLE v1 VARCHAR = 'ABCDEABC_AB'
SET VARIABLE vSLocLast = (SLOCP(.v1,'AB',-1))
Resulting variable vSlocLast will return the integer value of 10.
Have fun!
Very Best R:egards,
Razzak.
--- RBASE-L
================================================
TO POST A MESSAGE TO ALL MEMBERS:
Send a plain text email to [email protected]
(Don't use any of these words as your Subject:
INTRO, SUBSCRIBE, UNSUBSCRIBE, SEARCH,
REMOVE, SUSPEND, RESUME, DIGEST, RESEND, HELP)
================================================
TO SEE MESSAGE POSTING GUIDELINES:
Send a plain text email to [email protected]
In the message SUBJECT, put just one word: INTRO
================================================
TO UNSUBSCRIBE:
Send a plain text email to [email protected]
In the message SUBJECT, put just one word: UNSUBSCRIBE
================================================
TO SEARCH ARCHIVES:
Send a plain text email to [email protected]
In the message SUBJECT, put just one word: SEARCH-n
(where n is the number of days). In the message body,
place any
text to search for.
================================================