Usage of MID()
|
04-15-2022, 09:41 PM
Post: #1
|
|||
|
|||
Usage of MID()
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-16-2022, 12:18 PM
Post: #2
|
|||
|
|||
RE: Usage of MID()
(04-15-2022 09:41 PM)matalog Wrote: If I set up a string STR1:="123"; I don't like it but that's the way it works on mine, too. Tom L Cui bono? |
|||
04-16-2022, 01:30 PM
Post: #3
|
|||
|
|||
RE: Usage of MID()
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-16-2022, 01:56 PM
Post: #4
|
|||
|
|||
RE: Usage of MID() | |||
04-16-2022, 03:30 PM
(This post was last modified: 04-16-2022 03:35 PM by matalog.)
Post: #5
|
|||
|
|||
RE: Usage of MID()
(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. 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. |
|||
04-16-2022, 05:06 PM
(This post was last modified: 04-16-2022 06:40 PM by StephenG1CMZ.)
Post: #6
|
|||
|
|||
RE: Usage of MID()
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. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
04-16-2022, 07:10 PM
Post: #7
|
|||
|
|||
RE: Usage of MID()
(04-16-2022 05:06 PM)StephenG1CMZ Wrote: This will work in PPL: 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? |
|||
04-16-2022, 07:35 PM
Post: #8
|
|||
|
|||
RE: Usage of MID()
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. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
01-12-2023, 01:54 AM
Post: #9
|
|||
|
|||
RE: Usage of MID()
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.) |
|||
01-19-2023, 08:37 AM
Post: #10
|
|||
|
|||
RE: Usage of MID()
Unfortunately, the fix has broken at least one program; see https://www.hpmuseum.org/forum/thread-11...#pid168494. Luckly, there, a quick patch to the game’s source code (for loading “sayings”) seems to do the trick. (E.g., changing “DIM(str)==1” to “DIM(str)<2”.)
|
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)