Results 1 to 2 of 2

Thread: What about Strings & implicit operations?

  1. #1
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,525
    Rep Power
    170

    What about Strings & implicit operations?

    So far there are some math symbols that perform some operations as +=, *=, -=, /= and \=.
    I miss an OR-operative assignement as "|=" and by that logical "&=" with numbers would be AND.

    Confusing &= and += does the same to strings and only in one direction...

    Were this XOR "~=" with numbers
    then the same symbols i woul suggest to reverse concatenate
    while

    A$ &= B$
    equals
    A$ = A$ & B$
    and also
    A$= A$ + B$

    there could be some more implicit assignements that allow fast string operations as:

    A$ ~= B$..........A$ = B$ & A$
    would mean to put B$ in front of A$


    A$ -= B$............ A$ = Remove$(A$, B$)
    remove all occurences of B$ from A$


    A$ /= B$ ....... A$ = LeftF$(A$, Instr(-1, A$, B$)-1 ): A$ = RightF$(A$, Lenf(A$) -( Instr(1, A$, B$) + Lenf(B$)-1))
    divide A$ into the part between first and last occurence of B$
    e.g.
    A$ = "C:\myPath\myFile.ext"
    B$ = ""
    A$ /= B$ results in A$ = "myPath"

    A$ \= B$..........A$ = TRIM$(A$, B$)
    integer divison has something in common with Trim$ anyway. The truncation.

    A$ *= x ............. A$ = Repeat$(x, A$)
    Obvious that x must be a number
    (thinkable also Strings valid for x as "ONE", "TWO", "FIVE", "SEVEN", "THREEHUNDREDFORTYFIVE")


    The "!=" from other languages known logical NOT is no operator by itself and the "!"-symbol seems to be occupied for power basic alike asm-implementation but not functional. Since it should be "AND NOT", "OR NOT" & "XOR NOT" maybe it makes sense to use the ! instead of "=" as "&!", "|!" & "~!" for numeric logic ops

    the strings to trim <~, >~
    A$ <- B$......A$ = LTrim$( A$, B$ )
    A$ >- B$......A$ = RTrim$(A$, B$ )

    to truncate Strings incl. B$ <!, >!

    A$ >! B$........A$ = Rightf$(A$, Lenf(A$)-(Instr(-1, A$, B$)+Lenf(B$)-1))
    truncate everything incl. the last contained occurence of B$ (keep the right part)

    A$ <! B$........A$ = Leftf$(A$, Instr(1, A$, B$) - 1)
    truncate all of A$ that starts at the first occurence of B$ (keep the left part)

    e.g.
    A$= "c:\mypath\myFile.ext"
    >! .... result "ext" when B$ = "." , result "myFile.ext" when B$ = "\"

    A$>!"" : A$ >!"." : Print A$ .... will print out "myFile"

    <! ..... result "C:" when B$=""

    A$-=(A$>!""): Print A$ .... will print out "C:\myPath"

    A$ >& B$ ...... A$ = UCASE$(A$ & B$)
    A$ <& B$ ...... A$ = LCASE$(A$ & B$)
    A$ >~ B$ .......A$ = UCASE$(B$ & A$)
    A$ <~ B$ ........A$ =LCASE$(B$ & A$)

    IMO .Net died from Lack of overview caused long "snakes" of code that span across the screen with many hundred chars per line so nobody was ever able to read a full row without to scroll it left and right.
    Last edited by ReneMiner; 01-10-2022 at 02:43.
    I think there are missing some Forum-sections as beta-testing and support

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    You sure have great imagination Renč!
    Will study your suggestions, I like many of them but it depends if I will corrupt any back compatibility.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

Similar Threads

  1. asynchronous file operations
    By DirectuX in forum File
    Replies: 19
    Last Post: 28-03-2020, 19:38
  2. 64 bit strings
    By John Spikowski in forum Shout Box Area
    Replies: 2
    Last Post: 09-09-2013, 22:19
  3. Freebasic Strings again
    By Michael Clease in forum Module SDK (Freebasic version)
    Replies: 7
    Last Post: 20-05-2013, 03:27
  4. Demonstration of matrix operations
    By Petr Schreiber in forum TBGL Tutorials
    Replies: 4
    Last Post: 30-03-2009, 16:24

Members who have read this thread: 1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •