A trivial Pliant text mode applicationWarningsBe warned: nobody want's to develop a text mode application nowdays, and one more reason is that the Pliant graphical user interface (called Pliant UI) has been designed not with jukebox like looking in mind like most other modern graphical toolkits, but with user productivity in mind, so that users that like old text mode interfaces because they find them more productive should feel at home with Pliant UI. The next point is that a text mode Pliant application can be developped only using the command line development environment, neither the interpreter, nor the integrated development environment. You are still reading ! So, let's start. A trivial text mode applicationWe are going to write an application to convert inches to centimeters. Whoo. Let's create a /pliant/myorg/appli1/converter.pli file with: module "/pliant/language/ui/ansi_terminal.pli" Now we can run our application through the following command: pliant module /myorg/appli1/converter.pli Note: You might need to type /pliant/binary/pliant-debug1.exe or \pliant\binary\pliant-debug1.exe instead of just pliant. See command line development for details. More text mode user interface related instructionsWe need to include an optional module to get access to text mode user interface specific instructions: module "/pliant/language/ui/ansi_terminal.pli" 'keyboard_input' displays the label provided as a parameter, then waits for the user to type a value then press enter key, and returns as a string value what has been typed: gvar Str input := keyboard_input "Inches: " If something else than a string is expeced, we have to use 'parse' to get it converted, just like in the trivial sample application. If what is typed in must not be displayed for security reasons, we can use: gvar Str secret := keyboard_input_password "Please enter the secret phrase: " We can also pick a single character through: gvar Int code := keyboard_readchar Special values are defined in /pliant/language/ui/ansi_terminal.pli, such as keyboard_left, keyboard_right, keyboard_up, keyboard_down, keyboard_backspace, keyboard_enter, keyboard_escape, etc. If you want a 5 seconds timeout, try: gvar Int code := keyboard_readchar 5 If the timeout is reached, the returned character code will be 'undefined' (undefined is special integer value, 80000000h on a 32 bits plateform). Now, the text mode output is even simpler. We have the already seen 'console' instruction. The only extra one is 'console_move' that receives the x and y coordinates of the position to move the curset to. The top left of the screen is 0 0: console_move 0 0 The dirty way to clear a line before writing a new content might be: console (repeat 79 " ") "[cr]" '[cr]' character moves the cursor back to the beginning of the line as opposed to '[lf]' (or eol parameter in a 'console' instruction) that moves it back to the beginning of next line. The last word is from Boby Lapointe: C'est beaucoup, mais ce n'est pas trop. |