Terminal control/Cursor positioning: Difference between revisions
(→Tcl: Added implementation) |
(Graduate to a task; there's enough implementations) |
||
Line 1: | Line 1: | ||
{{ |
{{task}} |
||
Move the cursor to column 3, row 6 and display the word "Hello", so that the letter H is in column 3 on row 6. |
Move the cursor to column 3, row 6 and display the word "Hello", so that the letter H is in column 3 on row 6. |
||
Line 6: | Line 6: | ||
=== {{header|Locomotive Basic}} === |
=== {{header|Locomotive Basic}} === |
||
<lang basic> 10 LOCATE 3,6 |
<lang basic> 10 LOCATE 3,6 |
||
20 PRINT "Hello"</lang> |
20 PRINT "Hello"</lang> |
||
=== {{header|ZX Spectrum Basic}} === |
=== {{header|ZX Spectrum Basic}} === |
||
<lang basic> 10 REM The top left corner is at position 0,0 |
<lang basic> 10 REM The top left corner is at position 0,0 |
||
20 REM So we subtract one from the coordinates |
20 REM So we subtract one from the coordinates |
||
Line 35: | Line 33: | ||
{{incorrect|REXX|There is no code that actually does the task; assertions of possibility are insufficient.}} |
{{incorrect|REXX|There is no code that actually does the task; assertions of possibility are insufficient.}} |
||
The Rexx programming language does not include terminal control as part of the language. However, it might be possible to output ANSI control sequences, and there are various workarounds which are platform specific: |
The Rexx programming language does not include terminal control as part of the language. However, it might be possible to output ANSI control sequences, and there are various workarounds which are platform specific: |
||
{{libheader|rexxcurses}} |
{{libheader|rexxcurses}} |
||
<br> |
|||
{{works with|regina}} |
{{works with|regina}} |
||
The [[regina]] interpreter supports the [[rexxcurses]] plugin, which provides the facility to set the cursor position: |
The [[regina]] interpreter supports the [[rexxcurses]] plugin, which provides the facility to set the cursor position: |
||
<!-- still need code demonstrating this. Either that, or remove this section. The task seems fine for being non-draft, otherwise. --> |
<!-- still need code demonstrating this. Either that, or remove this section. The task seems fine for being non-draft, otherwise. --> |
||
Revision as of 00:05, 17 October 2010
You are encouraged to solve this task according to the task description, using any language you may know.
Move the cursor to column 3, row 6 and display the word "Hello", so that the letter H is in column 3 on row 6.
BASIC
Locomotive Basic
<lang basic> 10 LOCATE 3,6
20 PRINT "Hello"</lang>
ZX Spectrum Basic
<lang basic> 10 REM The top left corner is at position 0,0
20 REM So we subtract one from the coordinates 30 PRINT AT 5,2 "Hello"</lang>
Forth
<lang forth>2 5 at-xy ." Hello"</lang>
Logo
<lang logo>setcursor [2 5] type "Hello</lang> You can also draw positioned text on the turtle graphics window. <lang logo>setpos [20 50] setxy 20 30 ; alternate way to set position label "Hello</lang>
PureBasic
<lang PureBasic>EnableGraphicalConsole(#True) ConsoleLocate(3,6) Print("Hello")</lang>
REXX
The Rexx programming language does not include terminal control as part of the language. However, it might be possible to output ANSI control sequences, and there are various workarounds which are platform specific:
The regina interpreter supports the rexxcurses plugin, which provides the facility to set the cursor position:
Retro
<lang Retro>with console'
- hello 3 6 at-xy "Hello" puts ;</lang>
Tcl
<lang tcl>exec tput cup 6 3 >/dev/tty puts "Hello"</lang>