PDA

View Full Version : What about Strings & implicit operations?



ReneMiner
01-10-2022, 02:38
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.

ErosOlmi
04-10-2022, 12:14
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.