(06-07-2025, 12:20 AM)johnno56 Wrote: @Marcus
I had a free morning to spare (I know... How rare, right?) and decided to convert a simple (as in appearance) text version of hangman from QB64pe to N7.
In the compressed file I have included: The font files; current N7 listing; hangman word listing (hangman.txt) and the QB64pe hangman2.bas listing (reference)
I have ironed out the usual obvious code difference; added functions to replicate the "Locate" and "String" commands but I am having an annoying problem with "mid$(" (I know, N7 uses mid() ... lol)
The mid() function seems to be used to replace text in a string. Cool... Use the replace command, right? The only problem is that the replace command uses strings in all of it parameters - replace(main string, string to replace, replacement string). mid() uses: mid(main string, start position, length)
Line #55 states: mid(Letters, Lp, 1) = "_" and produces a syntax error... I even tried mid(Letters, Lp)
Obviously, mid(), is used to replace a single character at position 'Lp' of the string 'Letters' with "_".
I cannot see a way to exchange mid() for replace()... or am I going about this in the wrong way? lol
J
In a rush, here, so answering without looking at your source code, sorry

mid just returns the character at a given position in a string. replace replaces all occurrences of a substring in a string and returns the result as a new string. Both of them have to be used in expressions (a = mid(txt, 4), a = replace("fart", "art", "oo")) or you get a syntax error.
Here is a function that replaces the character at a given position in a string with a new character and returns the result as a new string:
Code:
a = "This is cool"
a = ReplaceCharAt(a, 5, "B")
pln a
system "pause"
function ReplaceCharAt(string, pos, newChar)
return left(string, pos) + newChar + right(string, pos + 1)
endfunc
The thing is, you can't alter an existing string in n7 (or n6), only create new ones.