Author Topic: JadeLib  (Read 25479 times)

Offline jack

  • Contributor
  • Posts: 15
Re: JadeLib
« Reply #15 on: January 08, 2019, 04:36:44 PM »
AIR, often one needs to know if there is no occurrence of the substring, how does your instr function handle that?

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: JadeLib
« Reply #16 on: January 08, 2019, 04:47:12 PM »
undef?

Mike Lobanovsky

  • Guest
Re: JadeLib
« Reply #17 on: January 08, 2019, 04:48:04 PM »
Jade isn't BASIC.  ;D

Probably not but your casual and definitive "Jade is using a "0" based index" raised questions immediately from at least three BASIC-ers. Doesn't that ring the bell? ;D

Mike Lobanovsky

  • Guest
Re: JadeLib
« Reply #18 on: January 08, 2019, 04:49:24 PM »
undef?

John is hopelessly incorrigible. ;D

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: JadeLib
« Reply #19 on: January 08, 2019, 04:53:15 PM »
I'm thinking about changing my last name to Trump.  :)

Offline AIR

  • Moderator
  • Posts: 932
  • Coder
Re: JadeLib
« Reply #20 on: January 08, 2019, 04:57:11 PM »
AIR, often one needs to know if there is no occurrence of the substring, how does your instr function handle that?

If you try this, you will see that it returns a '-1'.

Code: C++
  1. include <jade.hpp>
  2.  
  3. MAIN
  4.     STRING blah("This is a string");
  5.     PRINT(INSTR(blah,"or"));
  6. END

AIR.

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: JadeLib
« Reply #21 on: January 08, 2019, 05:03:41 PM »
Quote
If you try this, you will see that it returns a '-1'.

Sure looks like undef to me.

Offline AIR

  • Moderator
  • Posts: 932
  • Coder
Re: JadeLib
« Reply #22 on: January 08, 2019, 05:05:02 PM »
Jade isn't BASIC.  ;D

Probably not but your casual and definitive "Jade is using a "0" based index" raised questions immediately from at least three BASIC-ers. Doesn't that ring the bell? ;D

I encourage questions like this, but I also encourage you guys/gals to also try addressing your questions by coding.  I want you to find any issues; unfortunately I don't think zero vs one based indexing is one of them.  It's just different for BASIC-ers.  But not for people using other languages.

Mike Lobanovsky

  • Guest
Re: JadeLib
« Reply #23 on: January 08, 2019, 05:14:05 PM »
But not for people using other languages.

Armando, you telling this to me?! There's been nothing else but C/C++ for me to code in for decades! ;D

Never mind though. If there was at least one solid reason behind such a design decision for you as a (the?) project developer then so be it. :)

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: JadeLib
« Reply #24 on: January 08, 2019, 05:17:21 PM »
Code: [Select]
A$ = ""
IF MID(A$,69,3) = "AIR" THEN

TRUE in JADE returning -1.



Mike Lobanovsky

  • Guest
Re: JadeLib
« Reply #25 on: January 08, 2019, 05:23:44 PM »
Code: [Select]
A$ = ""
IF MID(A$,69,3) = "AIR" THEN

TRUE in JADE returning -1.

 ;D ;D ;D ;D

TRUE = -1 is another BASIC oddity that's been making me dizzy for as long as I can remember.

But seriously, it's a good catch John!

Armando, the ball is on your side... ;)

Offline AIR

  • Moderator
  • Posts: 932
  • Coder
Re: JadeLib
« Reply #26 on: January 08, 2019, 05:25:11 PM »
But not for people using other languages.

Armando, you telling this to me?! There's been nothing else but C/C++ for me to code in for decades! ;D

Nah, it was for everyone!!

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: JadeLib
« Reply #27 on: January 08, 2019, 05:31:06 PM »
Actually SB would return an undef for my example. Irritating but something I learned to live with.

Mike Lobanovsky

  • Guest
Re: JadeLib
« Reply #28 on: January 08, 2019, 05:35:58 PM »
John, you don't have to apologize. Armando will have to defend his design decision or admit his defeat.
« Last Edit: January 08, 2019, 05:37:44 PM by Mike Lobanovsky »

Offline AIR

  • Moderator
  • Posts: 932
  • Coder
Re: JadeLib
« Reply #29 on: January 08, 2019, 05:42:36 PM »
Code: [Select]
A$ = ""
IF MID(A$,69,3) = "AIR" THEN

TRUE in JADE returning -1.

Actually, this would throw an out of bounds error.

I updated MID$ to compare string length to start position.  Update and rebuild the lib.