![]() |
Confused about mid() command - Printable Version +- NaaLaa (https://www.naalaa.com/forum) +-- Forum: NaaLaa (https://www.naalaa.com/forum/forum-1.html) +--- Forum: NaaLaa 7 Questions (https://www.naalaa.com/forum/forum-3.html) +--- Thread: Confused about mid() command (/thread-142.html) |
Confused about mid() command - johnno56 - 06-11-2024 Hi Marcus, I was tinkering with string manipulation and came across a bit of a 'poser' in regards to the mid() command. Here is a short example.... Code: ' Open a window and enable double buffering. Defining a string then assigning a variable to a "portion" of the string, using mid(), works fine... But, trying to replace a character, using mid() causes the compilation to fail with a syntax error. There is no rush on this one... Whenever you are able... Present situation understood... We will "keep an eye on the store" during your break... J RE: Confused about mid() command - 1micha.elok - 06-11-2024 Perhaps like this one ... ? Code: 'Console Mode RE: Confused about mid() command - johnno56 - 06-11-2024 Cool... Worked like a charm... Thank you! RE: Confused about mid() command - 1micha.elok - 06-12-2024 (06-11-2024, 12:25 PM)johnno56 Wrote: Cool... Worked like a charm... Thank you! The mid() function may be used as collision detection. Let's try this one ! Code: '===================================================== RE: Confused about mid() command - johnno56 - 06-12-2024 Cool... Thanks for the demo... What? No ghosts? lol Chunk text. Very retro... RE: Confused about mid() command - Marcus - 06-14-2024 Sorry, you can't really modify strings, only construct new ones. RE: Confused about mid() command - johnno56 - 06-14-2024 hmm... Interesting response... I am receiving mixed messages... On one hand, "can't" (cannot) implies a "No"... But, "can't really" implies a measure of doubt and conveys a possible interpretation of... "No. But I dare you to try". I enjoy a good puzzle, but when it comes to coding, I find myself at the shallow end of the "smart" pool... lol Not a problem... Time for new train of thought... The only problem is that I do not have a ticket... Boom Boom.... lol Thank you for responding... ![]() RE: Confused about mid() command - Marcus - 06-15-2024 (06-14-2024, 08:34 PM)johnno56 Wrote: hmm... Interesting response... I am receiving mixed messages... On one hand, "can't" (cannot) implies a "No"... But, "can't really" implies a measure of doubt and conveys a possible interpretation of... "No. But I dare you to try". I enjoy a good puzzle, but when it comes to coding, I find myself at the shallow end of the "smart" pool... lol Haha ![]() Strings are like numbers. You can't change a string without getting a new string. That's why mid/left/right/replace all return new strings. It doesn't really matter. There's no simple way of replacing a character at a certain index in a string with another character. If you know what character it is, you could probably use 'replace' to get a new string: Code: foo = "ABCDEF" Output: foo = ABCDEF foo = ABZDEF |