Author Topic: New _TRIM$ function  (Read 6555 times)

0 Members and 1 Guest are viewing this topic.

FellippeHeitor

  • Guest
New _TRIM$ function
« on: August 15, 2018, 07:48:33 pm »
Oh hey! there is a _Trim$ keyword! I never thought to check a _version.

It's only in development builds so far; it'll become official in the next release of QB64 as outlined here: https://www.qb64.org/forum/index.php?topic=304.msg2554#msg2554

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: New _TRIM$ function
« Reply #1 on: August 15, 2018, 07:59:20 pm »
  • Best Answer
  • Oh hey! there is a _Trim$ keyword! I never thought to check a _version.

    It's only in development builds so far; it'll become official in the next release of QB64 as outlined here: https://www.qb64.org/forum/index.php?topic=304.msg2554#msg2554

    I don't think it likes to play with +
    Code: QB64: [Select]
    1. PRINT _TRIM$("                   hello world      ")
    2. PRINT "*" + _TRIM$("                   hello world      ") + "*"
    3. PRINT "*"; _TRIM$("                   hello world      "); "*"
    4.  
    For my system the middle line is blank.

    FellippeHeitor

    • Guest
    Re: New _TRIM$ function
    « Reply #2 on: August 15, 2018, 09:18:27 pm »
  • Best Answer
  • That's the type of pushing the limits we need when we announce we're beta testing a new version. Thanks. I'll look into the issue.

    PS: Although it does work for me as expected, both on Windows (32bit) and macOS (64bit):

      [ You are not allowed to view this attachment ]  

      [ You are not allowed to view this attachment ]  

    Anything we should know about your setup?
    « Last Edit: August 15, 2018, 09:23:40 pm by FellippeHeitor »

    Offline SMcNeill

    • QB64 Developer
    • Forum Resident
    • Posts: 3972
      • View Profile
      • Steve’s QB64 Archive Forum
    Re: New _TRIM$ function
    « Reply #3 on: August 15, 2018, 09:58:35 pm »
  • Best Answer
  • That's the type of pushing the limits we need when we announce we're beta testing a new version. Thanks. I'll look into the issue.

    PS: Although it does work for me as expected, both on Windows (32bit) and macOS (64bit):

    Anything we should know about your setup?

    Windows 64bit performs as bplus indicates above, for me, along with a secondary issue:

    Code: QB64: [Select]
    1. a$ = "*" + _TRIM$("                   hello world      ") + "*"
    2.  

    The above compiles, runs, and instantly self-destructs and closes before GL can even render a screen for us.  A program of "SYSTEM" would have a more noticeable effect than the above does, on my machine.  NO GL window opens.  There's no error messages -- not even a "C++ failed blah blah blah" message.  No "Press Any key to continue" message...   

    https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

    FellippeHeitor

    • Guest
    Re: New _TRIM$ function
    « Reply #4 on: August 15, 2018, 10:05:47 pm »
  • Best Answer
  • Can both of you please confirm you're running the latest development build tagged 6fde149?
    « Last Edit: August 15, 2018, 10:19:36 pm by odin »

    Offline bplus

    • Global Moderator
    • Forum Resident
    • Posts: 8053
    • b = b + ...
      • View Profile
    Re: New _TRIM$ function
    « Reply #5 on: August 15, 2018, 10:20:12 pm »
  • Best Answer
  • Hi Fellippe,

    Here is what I am running:
    'QB64 X 64 version 1.2 20180228/86  from git b301f92

    maybe fixed now?

     

    FellippeHeitor

    • Guest
    Re: New _TRIM$ function
    « Reply #6 on: August 15, 2018, 10:26:22 pm »
  • Best Answer
  • That's at least 11 builds behind. Please try the latest.

    For reference: https://github.com/flukiluke/qb64/commits/development (where build numbers come from).

    Offline bplus

    • Global Moderator
    • Forum Resident
    • Posts: 8053
    • b = b + ...
      • View Profile
    Re: New _TRIM$ function
    « Reply #7 on: August 15, 2018, 10:41:28 pm »
  • Best Answer
  • OK extracting now, is this 64 x 64?

    append:
      [ You are not allowed to view this attachment ]  

    No not 64 x 64.  ;(
    « Last Edit: August 15, 2018, 10:46:26 pm by bplus »

    Offline SMcNeill

    • QB64 Developer
    • Forum Resident
    • Posts: 3972
      • View Profile
      • Steve’s QB64 Archive Forum
    Re: New _TRIM$ function
    « Reply #8 on: August 15, 2018, 10:45:17 pm »
  • Best Answer
  • OK extracting now, is this 64 x 64?

    Only 32-bit.  You have to build the x64 version yourself.
    https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

    Offline bplus

    • Global Moderator
    • Forum Resident
    • Posts: 8053
    • b = b + ...
      • View Profile
    Re: New _TRIM$ function
    « Reply #9 on: August 15, 2018, 10:49:09 pm »
  • Best Answer
  • OK extracting now, is this 64 x 64?

    Only 32-bit.  You have to build the x64 version yourself.

    Oh boy! I think I got the 64 x64 version from you Steve. ;)

    FellippeHeitor

    • Guest
    Re: New _TRIM$ function
    « Reply #10 on: August 15, 2018, 10:59:44 pm »
  • Best Answer
  • It'll make sense for you 64bitcrazy guys to convert the last stable version to 64bit and wait for the current dev build to become stable before you convert it again, especially considering it can be buggy and it is constantly being updated until stable is reached.

    Offline codeguy

    • Forum Regular
    • Posts: 174
      • View Profile
    Re: New _TRIM$ function
    « Reply #11 on: August 17, 2018, 12:49:29 pm »
  • Best Answer
  • Pretty much the simplest and fastest for extracting substrings cleared of leading and trailing spaces. I would modify this for eliminating anything below ascii 33.
    « Last Edit: August 17, 2018, 12:53:06 pm by codeguy »

    FellippeHeitor

    • Guest
    Re: New _TRIM$ function
    « Reply #12 on: August 17, 2018, 01:18:14 pm »
  • Best Answer
  • Agree to disagree, codeguy. Fastest is RTRIM$(LTRIM$(text$)), which is what _TRIM$ does internally.

    Offline codeguy

    • Forum Regular
    • Posts: 174
      • View Profile
    Re: New _TRIM$ function
    « Reply #13 on: August 17, 2018, 04:59:54 pm »
  • Best Answer
  • Indeed much faster. Does yours offer flexibility to do more than just eliminating padding characters <= ascii 32?

    FellippeHeitor

    • Guest
    Re: New _TRIM$ function
    « Reply #14 on: August 17, 2018, 05:04:12 pm »
  • Best Answer
  • Nope, it does just what it promises: work as a macro to RTRIM$(LTRIM$(text$)). It's available in the latest dev build you can get from the homepage and will come in the next version of QB64 as soon as it's made available. It'll likely be called 1.3.