Page 1 of 1
Scan of rules not returning what I am expecting
Posted: Mon Sep 16, 2024 11:26 pm
by JohnO
This should be a simple one. The following is not returning a positive number. I am being blind to something?
sExisting_Rule = CubeRuleGet('INP Capital Planning');
nTargetCommaPosition = scan(sExisting_Rule,char(39)) ;
asciioutput('Test_Scan_Rule_File.csv',numbertostring(nTargetCommaPosition) );
nTargetCommaPosition is returning 0.
I have checked:
1) that the full rule string is being referenced
2) that the ' characters in the rule file are Ascii code 39 as you would expect
Re: Scan of rules not returning what I am expecting
Posted: Tue Sep 17, 2024 2:58 am
by Andy Key
Switch the order of your Scan parameters. You're currently looking for the text of the existing rule inside a string that only contains an apostrophe.
Re: Scan of rules not returning what I am expecting
Posted: Tue Sep 17, 2024 4:50 am
by JohnO
Andy Key wrote: ↑Tue Sep 17, 2024 2:58 am
Switch the order of your Scan parameters. You're currently looking for the text of the existing rule inside a string that only contains an apostrophe.
How obvious.
Thank you.
Re: Scan of rules not returning what I am expecting
Posted: Wed Sep 18, 2024 1:30 pm
by Steve Rowe
scribe, subscribe !
Re: Scan of rules not returning what I am expecting
Posted: Fri Sep 20, 2024 12:39 am
by JohnO
Steve Rowe wrote: ↑Wed Sep 18, 2024 1:30 pm
scribe, subscribe !
? Too cryptic for me.
Re: Scan of rules not returning what I am expecting
Posted: Fri Sep 20, 2024 5:10 am
by gtonkin
My cheat sheet just has it as: Scan(substring, string)
And don't forget that it is case sensitive.
Or maybe try remember something like "submarine"
Scan('sub', 'submarine');
A different take on Steve's approach but maybe his example would have worked better with 'sub' as the substring instead of 'scribe'
Re: Scan of rules not returning what I am expecting
Posted: Fri Sep 20, 2024 10:35 am
by Wim Gielis
I have more problems with INSRT and FILL. To name just a few. Luckily PAW helps us.
Re: Scan of rules not returning what I am expecting
Posted: Fri Sep 20, 2024 4:05 pm
by MarenC
I must admit that I always think scan means the whole word, so I would expect the full string to be the first argument. I.e. I am scanning this to see if I can find that.
That said, the fact checking the order was missing from this is a bit of an oversight
1) that the full rule string is being referenced
2) that the ' characters in the rule file are Ascii code 39 as you would expect
Maren
Re: Scan of rules not returning what I am expecting
Posted: Tue Sep 24, 2024 8:17 am
by Steve Rowe
Steve Rowe wrote: ↑Wed Sep 18, 2024 1:30 pm
scribe, subscribe !
Pretty sure this was the example quoted in the help document at one time, just stuck in my brain....