Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Are sub-strings strings?
#1
I often need to swap two sections of a string, as in the snippet below.
Wiki says "The SWAP statement is used to exchange two variable or array element values".
I find I can only do this by using a temporary variable, so I need 3 lines of code instead of 1.

Is a part of a string a variable? 
If not, maybe the Wiki could clarify this, to save L-Platers like me a lot of time experimenting?

(This is a very simple example, but others can be more significant).
T$ = "ABCDEFG"
Print T$
Swap mid$(T$,2,1) ,mid$(T$,5,1)                   <--   this line is not allowed
Print T$

Tmp$ = Mid$(T$, 2, 1)
Mid$(T$, 2, 1) = Mid$(T$, 5, 1)
Mid$(T$, 5, 1) = Tmp$
Print T$
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, Western Australia.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply


Messages In This Thread
Are sub-strings strings? - by PhilOfPerth - 12-26-2025, 04:14 AM
RE: Are sub-strings strings? - by ahenry3068 - 12-26-2025, 04:34 AM
RE: Are sub-strings strings? - by PhilOfPerth - 12-26-2025, 04:44 AM
RE: Are sub-strings strings? - by ahenry3068 - 12-26-2025, 04:50 AM
RE: Are sub-strings strings? - by SMcNeill - 12-26-2025, 06:01 AM
RE: Are sub-strings strings? - by Petr - 12-26-2025, 10:41 AM
RE: Are sub-strings strings? - by justsomeguy - 12-26-2025, 11:08 AM
RE: Are sub-strings strings? - by Dav - 12-26-2025, 03:56 PM
RE: Are sub-strings strings? - by SMcNeill - 12-26-2025, 05:06 PM
RE: Are sub-strings strings? - by bplus - 12-26-2025, 05:15 PM
RE: Are sub-strings strings? - by SMcNeill - 12-26-2025, 05:20 PM
RE: Are sub-strings strings? - by Petr - 12-26-2025, 05:57 PM
RE: Are sub-strings strings? - by Kernelpanic - 12-26-2025, 06:11 PM
RE: Are sub-strings strings? - by Dav - 12-26-2025, 07:05 PM
RE: Are sub-strings strings? - by bplus - 12-26-2025, 08:43 PM
RE: Are sub-strings strings? - by SMcNeill - 12-26-2025, 09:32 PM
RE: Are sub-strings strings? - by Pete - 12-26-2025, 09:50 PM
RE: Are sub-strings strings? - by Kernelpanic - 12-26-2025, 10:42 PM
RE: Are sub-strings strings? - by SMcNeill - 12-26-2025, 11:24 PM
RE: Are sub-strings strings? - by Kernelpanic - 12-27-2025, 01:57 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Print strings with accents and special chars Ikerkaz 8 678 12-20-2025, 09:28 PM
Last Post: TempodiBasic

Forum Jump:


Users browsing this thread: 1 Guest(s)