Concatenate-UNCONCATENATE
Concatenate-UNCONCATENATE
Dim As String a,b,c,d
a="hello"
b="world"
Print a 'hello
Print b 'world
c=a+b 'Concatenate
Print c 'helloworld
d=c-b 'UNCONCATENATE
Print d 'hello
a="hello"
b="world"
Print a 'hello
Print b 'world
c=a+b 'Concatenate
Print c 'helloworld
d=c-b 'UNCONCATENATE
Print d 'hello
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
Re: Concatenate-UNCONCATENATE
Code: Select all
Dim As String a,b,c,d
a="hello"
b="world"
Print a
Print b
c = a & b
Print c
d = left(c,len(c)-len(b))
Print d
sleep
Re: Concatenate-UNCONCATENATE
Because of QBasic history, the "+" operator is also defined for strings (and not only for numeric values addition), but the good syntax for concatenation of strings is the "&" operator (as BasicCoder2 shows above).
None operator for the "unconcatenation" of strings exists.
None operator for the "unconcatenation" of strings exists.
Last edited by fxm on Sep 23, 2017 13:37, edited 1 time in total.
Re: Concatenate-UNCONCATENATE
Operator + (String Concatenation)
Operator - (String UnConcatenation)?
Operator - (String UnConcatenation)?
Re: Concatenate-UNCONCATENATE
In what language? Also, what is "unconcatenation" supposed to be?
Re: Concatenate-UNCONCATENATE
I am thinking about adding strings to fbcadcam-macro and oh boy is is a lot of work.
Until I started looking into this idea this morning, I never knew the difference between the string operators + and &.
It really goes to show how much thought went into creating the freebasic compiler.
Until I started looking into this idea this morning, I never knew the difference between the string operators + and &.
It really goes to show how much thought went into creating the freebasic compiler.
Re: Concatenate-UNCONCATENATE
What is the opposite operator for &
Re: Concatenate-UNCONCATENATE
"Unconcatenation" could be defined as the suppression of a sub-string inside another string (if sub-string exists)!
Re: Concatenate-UNCONCATENATE
After all these years I only know a fraction of freebasic's features. So I have a lot to learn.
I'm thinking the solution is an operator overload?
But because I am unfamiliar with what it means to overload an operator, perhaps I'll learn a bit more today.
I'm thinking the solution is an operator overload?
But because I am unfamiliar with what it means to overload an operator, perhaps I'll learn a bit more today.
Re: Concatenate-UNCONCATENATE
The only stuff I could find online was talks specific to excel.In what language? Also, what is "unconcatenation" supposed to be?
So It's still undefined.
As basichCoder2 defined it.
Or perhaps
"Hello World. Welcome to the Freebasic World"
UnConcatenated could be
"Hello . Welcome to the Freebasic "
Re: Concatenate-UNCONCATENATE
fxm wrote:"Unconcatenation" could be defined as the suppression of a sub-string inside another string (if sub-string exists)!
Code: Select all
#define unconcatenate(str, substr) Iif(Instr(str, substr), _
Left(str, Instr(str, substr) - 1) & Mid(str, Instr(str, substr) + Len(substr)), _
str)
Dim As String a, b, c, d, e
a= "hello"
b= "world"
c= "!"
Print a
Print b
Print c
d = a & b & c
Print d
e = unconcatenate(d, b)
Print e
Sleep
- macro corrected on dodicat's remark below.
Last edited by fxm on Sep 23, 2017 14:52, edited 1 time in total.
Re: Concatenate-UNCONCATENATE
yup it could be like that.
i was thinking it would be part of the compiler in the future using operators - and whatever the opposite of & is.
i was thinking it would be part of the compiler in the future using operators - and whatever the opposite of & is.
Re: Concatenate-UNCONCATENATE
hellow! is left, shouldn't it be hello!
(One place to left to include)
(One place to left to include)
Code: Select all
#define unconcatenate(str, substr) Iif(Instr(str, substr), _
Left(str, Instr(str, substr)-1) & Mid(str, Instr(str, substr) + Len(substr)), _
str)
Re: Concatenate-UNCONCATENATE
Thanks.
I corrected my above post.
I corrected my above post.
-
- Posts: 564
- Joined: Sep 27, 2016 18:20
- Location: Valencia, Spain
Re: Concatenate-UNCONCATENATE
> Also, what is "unconcatenation" supposed to be?
This is usually called Remove.
This is usually called Remove.