If I set up a string STR1:="123";
Then I use MID(STR1,9), it will return the last digit "3", even though it is the 3rd position of the string, I would thought it would have returned "" given that there is nothing in the 9th position.
Using PUREBASIC for example, I get nothing output to terminal.
MID("123",6) on the Prime, returns 3.
Is that normal?
(04-15-2022 09:41 PM)matalog Wrote: [ -> ]If I set up a string STR1:="123";
Then I use MID(STR1,9), it will return the last digit "3", even though it is the 3rd position of the string, I would thought it would have returned "" given that there is nothing in the 9th position.
Using PUREBASIC for example, I get nothing output to terminal.
MID("123",6) on the Prime, returns 3.
Is that normal?
I don't like it but that's the way it works on mine, too.
It doesn't work like that on the 50g, SUB(4,4,"123") doesn't return anything.
Casio CG50 StrMid("123",5,5) doesn't return anything.
I don't know of another language where MID will return something outside of the set range.
(04-15-2022 09:41 PM)matalog Wrote: [ -> ]MID("123",6) on the Prime, returns 3.
With lower-cased mid, bug is gone (at least on the emulator)
CAS> mid("123",6) → ""
(04-16-2022 01:56 PM)Albert Chan Wrote: [ -> ] (04-15-2022 09:41 PM)matalog Wrote: [ -> ]MID("123",6) on the Prime, returns 3.
With lower-cased mid, bug is gone (at least on the emulator)
CAS> mid("123",6) → ""
And confirmed on a G2.
Is there any way to ensure the CAS version of MID will be used from any program?
That should be enough to all it a bug. There is no reason to have MID behave differently in CAS than Home.
This will work in PPL:
ST:="123";
CAS("mid(ST, 6) ");
It also works from CAS home screen - I haven't tried it within a CAS program.
(04-16-2022 05:06 PM)StephenG1CMZ Wrote: [ -> ]This will work in PPL:
ST:="123";
CAS("mid(ST, 6) ");
It also works from CAS home screen - I haven't tried it within a CAS program.
That is the second time this week I have seen a suggestion to use CAS( something) as a work around.
What does that use of CAS do, as it usually contains more quotations that you would usually see?
Is it documented in the manual?
The short answer:
The expression is parsed by CAS and more information is available in CAS help.
I have seen CAS(string) used, and also CAS.function (e.g. CAS.mid(...) ).
It's an alternative to just using mid within a CAS program.
Note that MID is normally the PPL version and mid the CAS version, though their are exceptions.
I am sure the experts can explain it much better.
matalog,
Thanks for posting. And thanks to the others for their comments and confirmation. I filed a bug report for this on the bug tracking site I’ve set up. … and the bug got fixed!
(If anyone reading this would like an account on the bug tracker I’ve set up to help organize matters, just let me know by PM.)