![]() |
Hangman - Text - 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: Hangman - Text (/thread-271.html) |
Hangman - Text - johnno56 - 06-07-2025 @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 RE: Hangman - Text - Marcus - 06-07-2025 (06-07-2025, 12:20 AM)johnno56 Wrote: @Marcus 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" The thing is, you can't alter an existing string in n7 (or n6), only create new ones. RE: Hangman - Text - Marcus - 06-07-2025 I had a quick look at your code in an attempt to use the function I gave you, but the game got stuck in a loop with a black screen it seems (maybe shouldn't use 'set redraw off' for this program?) However, I noticed lines like this: Code: Lp = instr(Letters, Choice) Character positions are always 0 based so instr returns -1 if the substring doesn't exist. Use: Code: Lp = instr(Letters, Choice) instead. RE: Hangman - Text - johnno56 - 06-07-2025 I had only just converted the program and the initial run stopped at the mid() statement... "stuck in a loop" and I are no strangers... and was almost anticipated... lol Although the direct conversion was pretty much done... I was fairly certain that there would be more issues to deal with... I will test out your suggestions... I will report back in a little while... Thank you for the assist... I am sure that the black screen is a beast of my own making... lol RE: Hangman - Text - Marcus - 06-07-2025 (06-07-2025, 09:58 AM)johnno56 Wrote: I had only just converted the program and the initial run stopped at the mid() statement... "stuck in a loop" and I are no strangers... and was almost anticipated... lol Although the direct conversion was pretty much done... I was fairly certain that there would be more issues to deal with... I will test out your suggestions... I will report back in a little while... Thank you for the assist... I am sure that the black screen is a beast of my own making... lol Nah, just a missing "redraw". I removed "set redraw off" and got output that looked good. RE: Hangman - Text - johnno56 - 06-07-2025 I figured it might be a 'redraw' issue... I managed to get the display up ok. After I get some sleep I will begin on the 'user input'... Once that's done it will be almost complete.... but first... some sleep... RE: Hangman - Text - 1micha.elok - 06-09-2025 (06-07-2025, 02:48 PM)johnno56 Wrote: I figured it might be a 'redraw' issue... I managed to get the display up ok. After I get some sleep I will begin on the 'user input'... Once that's done it will be almost complete.... but first... some sleep... I'm really excited to see the final version of the Hangman game you're working on! Just curious—does it tie into a Final Destination-style thriller theme where you can’t cheat death, and no matter what, death always finds a way? And are you planning to visualize the man being hanged until death in a funny or lighthearted way ? ... lol ![]() RE: Hangman - Text - johnno56 - 06-09-2025 Final Destination? No. I do not think so... But I like the way you think... Moo Ha Ha Ha... |