Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 23:42 25 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : MID$ - two uses

Author Message
BobDevries

Senior Member

Joined: 08/06/2011
Location: Australia
Posts: 266
Posted: 12:41am 26 Apr 2012
Copy link to clipboard 
Print this post

... but one is missing in MMBASIC. :(

Our MMBASIC has one version of MID$, and that is to grab a sub-string from an existing string variable. However, mid$ should also be able to be used to put a sub-string INTO an existing string variable, like this:

MID$(A$,5,3) = "BOB"

I can't remember offhand if the new substring inserts, or replaces existing characters. I'll need to RTFM :P

And yes, I know code could be written in BASIC to get around this lack....

Regards,

Bob Devries
Dalby, QLD, Australia
 
BobDevries

Senior Member

Joined: 08/06/2011
Location: Australia
Posts: 266
Posted: 12:49am 26 Apr 2012
Copy link to clipboard 
Print this post

Hi all,

According to the GWBASIC User's guide, the MID$ statement prototype is:

QUOTE:
MID$(stringexp1,n[,m]) = stringexp2

Both n and m are integer expressions
string exp1 and stringexp2 are string expressions

The characters in stringexp1, beginning at position n, are replaced by the characters in stringexp2.

The optional m refers to the number of characters from stringexp2 that are used in the replacement. If m is omitted, all of stringexp2 is used.

Whether m is omitted or included, the replacement of characters never goes beyond the original length of stringexp1.
ENDQUOTE:

Regards,

Bob Devries
Dalby, QLD, Australia
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3801
Posted: 08:02am 26 Apr 2012
Copy link to clipboard 
Print this post

It's not intuitive :(

You'd expect stringexp1 to grow or shrink automatically. You'd expect all of stringexp2 to be used. And so on.

John
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 08:24pm 12 May 2012
Copy link to clipboard 
Print this post

It is one of those nasty BASIC statements.
Pretty powerful though. If compatibility is needed it should be implemented.
I am not sure if MID$ can be on the left side of a "=" in the current parser.
I can give it a try...

Microblocks. Build with logic.
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024