Like Tic-Tac-To, Hangman is a game that almost everybody has played at some point in their life. The basic premise behind the game is that two people alternate turns, with one person picking a word, and then the second person trying to guess the word by selecting letters until they have either gotten the word or run out of chances.

This game features some rather advanced string manipulation, as well as some good compression for storing the different pieces of the hangman character. Again, try out the game and try to understand and think through the code.

Table of Contents

The Code

:Repeat 33>length(Str1
:Disp "WORD? (32 CHARS)
:Input "",Str1
:If inString(Str0,Ans:"-
:While Str1≠Str2 and T
:Output(iPart(Ans(T)),10fPart(Ans(T)),sub("^^I--IO ",T,1
:Repeat 30<Ans and Ans<94
:If Ans=45:Goto Q
:While I
:sub(sub(" "+Str2,1,I)+Str3+sub(Str2+" ",I+1,length(Str2)-I+1),2,length(Str2→Str2
:Lbl Q
:Pause "YOU "+sub("LOSE!WIN! ",1+5(Str1=Str2),5

The Download

In case you want to try the program on your calculator, you can download the program in .8xp format.


Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License