I’m not sure duplicating the last character will ever come back to haunt you 
but you might be better off simply adding a character that you know will never 
need to be searched for.

Other advantages: you always add the same character so saving looking for the 
last one first and you don’t have to ignore it when SLOCP gives you zero for 
the duplicated one.

Regards,
Alastair.



From: Michael J. Sinclair 
Sent: Sunday, August 19, 2012 1:07 PM
To: RBASE-L Mailing List 
Subject: [RBASE-L] - RE: Syntax with SLOCP

Hi John,
Thanks for the response!
Dr. Razaak provided samples that work perfectly.
The special case of a single character string placed at the very last position 
within the sources string appears to be the issue where the function returns a 
0 rather than the position of the single character string.
In my code, the source string is parsed and shortened within a while loop until 
each string between the desired single characters is processed. It works 
perfectly until there is only 1 string left to find. That's when SLOCP tries to 
find the final character in the source string and returns a 0. 

My workaround is to duplicate the last character in the source string and 
ignore any strings that have 0 characters.
Mike


--------------------------------------------------------------------------------
From: John Docherty <[email protected]>
To: RBASE-L Mailing List <[email protected]> 
Sent: Sunday, August 19, 2012 2:25 AM
Subject: [RBASE-L] - RE: Syntax with SLOCP


Mike,

I tried your code with the same result. As you say if the ‘c’ is not the last 
character in the string the correct value is returned, however if it is you get 
a 0.  Maybe this is an ‘issue’ ? 

I am sure RBTI will sort this out, (or put us ‘straight’), if you report this. 

Regards,

John Docherty

From: [email protected] [mailto:[email protected]] On Behalf Of Michael J. 
Sinclair
Sent: Sunday, 19 August 2012 4:31 p.m.
To: RBASE-L Mailing List
Subject: [RBASE-L] - Syntax with SLOCP

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?
Thanks
Mike


Reply via email to