Discussion:
MID$() = variable
(too old to reply)
Stan Helton
2007-04-23 18:28:05 UTC
Permalink
Using PB/DOS 3.5 in MS-DOS 6.22 environment.

The MID$() statement does not appear to work as described in the manual.

Syntax as follows:

MID$(DataRecord$, Offset%, Length%) = StringVariable$

is supposed to insert Length% characters of StringVariable$ into DataRecord$
at Offset%, but it doesn't work. It seems to return a NULL string. Offset%
and Length% are NonZero Positive integers.

Is there a problem with this syntax? So far, I've been using a FOR/NEXT loop
as a workaround, but I would really like to be able to use this syntax as
described in the manual.

Thanks,
Stan
Michael Mattias
2007-04-23 19:32:42 UTC
Permalink
Post by Stan Helton
Using PB/DOS 3.5 in MS-DOS 6.22 environment.
The MID$() statement does not appear to work as described in the manual.
MID$(DataRecord$, Offset%, Length%) = StringVariable$
is supposed to insert Length% characters of StringVariable$ into DataRecord$
at Offset%, but it doesn't work. It seems to return a NULL string. Offset%
and Length% are NonZero Positive integers.
MID$ has worked correctly forever. Show allegedely failing code. Also which
compiler? Windows or DOS? (Looks like MS-DOS from use of integer vars?)

Also, if you are gettring NUL string back in DataRecords$, ERR should be
set, you can test that.
--
Michael C. Mattias
Tal Systems Inc.
Racine WI
***@talsystems.com
usablevirus
2007-04-23 23:56:11 UTC
Permalink
Post by Stan Helton
Using PB/DOS 3.5 in MS-DOS 6.22 environment.
The MID$() statement does not appear to work as described in the manual.
MID$(DataRecord$, Offset%, Length%) = StringVariable$
is supposed to insert Length% characters of StringVariable$ into
DataRecord$ at Offset%, but it doesn't work. It seems to return a NULL
string. Offset% and Length% are NonZero Positive integers.
Is there a problem with this syntax? So far, I've been using a
FOR/NEXT loop as a workaround, but I would really like to be able to
use this syntax as described in the manual.
LEN(StringVariable$) must equal Length%
also (Offset% + Length%)-1 must not exceed the LEN(DataRecord$)
Stan Helton
2007-04-24 14:56:43 UTC
Permalink
Post by usablevirus
Post by Stan Helton
Using PB/DOS 3.5 in MS-DOS 6.22 environment.
The MID$() statement does not appear to work as described in the manual.
MID$(DataRecord$, Offset%, Length%) = StringVariable$
is supposed to insert Length% characters of StringVariable$ into
DataRecord$ at Offset%, but it doesn't work. It seems to return a NULL
string. Offset% and Length% are NonZero Positive integers.
Is there a problem with this syntax? So far, I've been using a
FOR/NEXT loop as a workaround, but I would really like to be able to
use this syntax as described in the manual.
LEN(StringVariable$) must equal Length%
also (Offset% + Length%)-1 must not exceed the LEN(DataRecord$)
Thanks. I will test that this afternoon and let you know what happens.
Question -- Is it not possible to use this statement to insert only a
portion
of StringVariable$ into DataRecord$ by specifying
a Length% < LEN(StringVariable$) ?
Michael Mattias
2007-04-24 15:04:19 UTC
Permalink
Post by Stan Helton
Thanks. I will test that this afternoon and let you know what happens.
Question -- Is it not possible to use this statement to insert only a
portion
of StringVariable$ into DataRecord$ by specifying
a Length% < LEN(StringVariable$) ?
Sure, just use MID$ function in addition to MID$ startement...

MID$(string, pos, len) = MID$(Otherstring, pos, length)

???


MCM
Stan Helton
2007-04-24 17:21:59 UTC
Permalink
Post by Michael Mattias
Post by Stan Helton
Thanks. I will test that this afternoon and let you know what happens.
Question -- Is it not possible to use this statement to insert only a
portion
of StringVariable$ into DataRecord$ by specifying
a Length% < LEN(StringVariable$) ?
Sure, just use MID$ function in addition to MID$ startement...
MID$(string, pos, len) = MID$(Otherstring, pos, length)
???
MCM
Thanks, that pretty well solves my delimma and cleans up the code I was
trying use also.

Stan

Tom Lake
2007-04-24 04:55:46 UTC
Permalink
Post by Stan Helton
Using PB/DOS 3.5 in MS-DOS 6.22 environment.
The MID$() statement does not appear to work as described in the manual.
MID$(DataRecord$, Offset%, Length%) = StringVariable$
is supposed to insert Length% characters of StringVariable$ into DataRecord$
at Offset%, but it doesn't work. It seems to return a NULL string. Offset%
and Length% are NonZero Positive integers.
cls
a$="This ir a statement."
print a$
mid$(a$,7,1)="s"
print a$

does this:

This ir a statement.
This is a statement.

This is how MID$ works.

Tom Lake
Loading...