Author Topic: JadeLib  (Read 25459 times)

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: JadeLib
« Reply #45 on: January 13, 2019, 11:02:08 AM »
I've leaned to live with undef not being equal to FALSE.

This is the best way to test if a variable is defined or not.

Code: ScriptBasic
  1. IF ISUNDEF(A$) THEN
  2.   PRINT "TRUE\n"
  3. ELSE
  4.   PRINT "FALSE\n"
  5. END IF
  6.  


$ scriba t_undef.sb
TRUE
$



Code: ScriptBasic
  1. IF a THEN
  2.   PRINT "undef = FALSE\n"
  3. ELSE
  4.   PRINT "undef = TRUE\n"
  5. END IF
  6.  


$ scriba t_undef.sb
undef = TRUE
$


A good reason to turn declaring variables on in SB. This prevents weird bugs due to an unexpected undef creeping into the code.

Code: ScriptBasic
  1. declare option DeclareVars
  2. declare option AutoVars
  3.  

If I can live with that, JADE's zero starting string reference is a walk the park.  ;D
« Last Edit: January 13, 2019, 07:09:43 PM by John »

Offline AIR

  • Moderator
  • Posts: 932
  • Coder
Re: JadeLib
« Reply #46 on: January 13, 2019, 08:17:55 PM »
John, this thread is about JadeLib.  Please stay on topic.  Thanks.

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: JadeLib
« Reply #47 on: January 13, 2019, 08:28:35 PM »
Okay

Just sharing I'm no stranger to pain.

Offline AIR

  • Moderator
  • Posts: 932
  • Coder
Re: JadeLib
« Reply #48 on: January 13, 2019, 08:37:20 PM »
Commit 53004c5ded Added LPAD$, RPAD$, and PAD$ Functions.

Code: C++
  1. #include <jade.hpp>
  2.  
  3. MAIN
  4.     STRING str = "abcd";
  5.  
  6.     PRINT(LPAD$(str,10,'*'));
  7.     PRINT(RPAD$(str,10,'*'));
  8.     PRINT(PAD$(str,10,'*'));
  9. END
  10.  

$ ./pad
**********abcd
abcd**********
**********abcd**********


If the third parameter (padding character) is omitted, spaces are used.

Note that the padding character is a CHAR (single quotes) in this example.  You can also pass the ASCII numeric value instead, without the quotes.

AIR.

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: JadeLib
« Reply #49 on: January 14, 2019, 10:38:35 PM »
AIR,

Would it be possible to use JADE to create a SB extension module?

Offline AIR

  • Moderator
  • Posts: 932
  • Coder
Re: JadeLib
« Reply #50 on: January 14, 2019, 11:29:56 PM »
I don't think you can just compile and go, because SB is compiled using C via the build system.





Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: JadeLib
« Reply #51 on: January 14, 2019, 11:41:17 PM »
You're right.

I was just thinking JADE might be a nice way to quickly turn a CPU intensive function into an extension module. I think I should put my efforts in this area to C BASIC and attach Peter's existing API macros to BASIC keywords. I do plan to follow much of your JADE flow and style.

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: JadeLib
« Reply #52 on: January 03, 2021, 01:32:37 AM »
AIR,

Your last post about JADELIB didn't make it in my last offline backup before the AWS instance crashed. Please post it again when you have time.