|
DEL$
Apr 9, 2020 12:09:25 GMT 1
Post by alexfish on Apr 9, 2020 12:09:25 GMT 1
Hi Peter
DEL$(string$ , pos [, delimiter$]) Type: function Deletes a member at position <pos> from a delimited string$ split by delimiter$. The delimiter$ is optional. If it is omitted, then the definition from OPTION DELIM is assumed. When specified, it may consist of multiple characters.
eg
LOCAL A$ = "THIS TEXT" TYPE STRING
DEL$(A$,2)
produces
Syntax error: could not parse line 98 in file 'utf.bac': "DEL__b2c__string_var(A__b2c__string_var,2)" Error code recieved : 256
BR Alex
|
|
|
DEL$
Apr 9, 2020 13:55:09 GMT 1
Post by Pjot on Apr 9, 2020 13:55:09 GMT 1
Dear Alex,
The DEL$ function is a function and not a statement. E.g.:
LOCAL A$ = "THIS TEXT" TYPE STRING
A$ = DEL$(A$,2)
HTH Peter
|
|
|
DEL$
Apr 9, 2020 18:25:51 GMT 1
Post by alexfish on Apr 9, 2020 18:25:51 GMT 1
Hi Peter
it certainly does
BR Alex
|
|
|
DEL$
Apr 10, 2020 11:07:30 GMT 1
Post by alexfish on Apr 10, 2020 11:07:30 GMT 1
Hi Peter
still got a problem
LOCAL A$ = "THIS TEXT" TYPE STRING
A$ = DEL$(A$,2)
bacon 3.6 will show text as is
then from 3.6+ to bacon m4 does not show any text
ADDED APPOLLS
the above does work IE a delimited text in above example
but "THIS" as a string will not. however I think this statement is possibly misleading and should be updtated with sample code
it may consist of multiple characters.
Deletes a member at position <pos> from a delimited string$ split by delimiter$. The delimiter$ is optional. If it is omitted, then the definition from OPTION DELIM is assumed. When specified, it may consist of multiple characters.
also tried demo's of sqlite from bacon website
these do not show all the records
PS would it be possible to have a Function to delete a char from a position x
IE Delete char("this is a string",1) = "his is a string" BR Alex
|
|
|
DEL$
Apr 10, 2020 12:14:57 GMT 1
Post by alexfish on Apr 10, 2020 12:14:57 GMT 1
Hi Again Peter
I am curious about global or declared strings and function
the below produces an error
SUB TEST_IN_MID()
A$ = MID$(A$,1)
PRINT A$
END SUB
DECLARE A$ ="TEST THIS"
A$ = MID$(A$,1)
PRINT A$
A$ ="TEST THIS"
where as declares at top of page work
has this always been the case
DECLARE A$ ="TEST THIS"
SUB TEST_IN_MID()
A$ = MID$(A$,1)
PRINT A$
END SUB
A$ = MID$(A$,1)
PRINT A$
A$ ="TEST THIS"
|
|
|
DEL$
Apr 10, 2020 15:06:09 GMT 1
Post by Pjot on Apr 10, 2020 15:06:09 GMT 1
still got a problem LOCAL A$ = "THIS TEXT" TYPE STRING
A$ = DEL$(A$,2)
bacon 3.6 will show text as is then from 3.6+ to bacon m4 does not show any text ADDED APPOLLS the above does work IE a delimited text in above example but "THIS" as a string will not. however I think this statement is possibly misleading and should be updtated with sample code Hi Alex, this code works fine for me. LOCAL A$ = "THIS TEXT" TYPE STRING PRINT DEL$(A$,2)
But also: LOCAL A$ = "THIS" TYPE STRING PRINT DEL$(A$,1) PRINT DEL$(A$,2)
The second PRINT only shows "THIS" because there is no second member in the delimited string. So as far as I can see all works, can you provide a code example which demonstrates that DEL$ is not working? PS would it be possible to have a Function to delete a char from a position x IE Delete char("this is a string",1) = "his is a string" You can use RIP$ for this. It is the complement of MID$. Regarding your question about global or declared strings and function: the error you see in the first code snippet is correct, because the function will implicitly declare the the variable "A$" as a global string, before the actual DECLARE statement will declare it. BR Peter
|
|
|
DEL$
Apr 10, 2020 16:11:54 GMT 1
Post by alexfish on Apr 10, 2020 16:11:54 GMT 1
Thanks Peter
had not notice RIP$ , that one fulfils what I have been looking for in BaCon.
Is latest bacon 4 on downloads or the fossil.
BR Alex
|
|