Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
35
Task/User-input-Text/Neko/user-input-text.neko
Normal file
35
Task/User-input-Text/Neko/user-input-text.neko
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
User input/Text, in Neko
|
||||
Tectonics:
|
||||
nekoc userinput.neko
|
||||
neko userinput
|
||||
*/
|
||||
|
||||
var stdin = $loader.loadprim("std@file_stdin", 0)()
|
||||
var file_read_char = $loader.loadprim("std@file_read_char", 1)
|
||||
|
||||
/* Read a line from file f into string s returning length without any newline */
|
||||
var NEWLINE = 10
|
||||
var readline = function(f, s) {
|
||||
var len = 0
|
||||
var ch
|
||||
while true {
|
||||
try ch = file_read_char(f) catch a break;
|
||||
if ch == NEWLINE break;
|
||||
if $sset(s, len, ch) == null break; else len += 1
|
||||
}
|
||||
return $ssub(s, 0, len)
|
||||
}
|
||||
|
||||
$print("Enter a line of text, then the number 75000\n")
|
||||
|
||||
try {
|
||||
var RECL = 132
|
||||
var str = $smake(RECL)
|
||||
var userstring = readline(stdin, str)
|
||||
$print(":", userstring, ":\n")
|
||||
|
||||
var num = $int(readline(stdin, str))
|
||||
if num == 75000 $print("Rosetta Code 75000, for the win!\n")
|
||||
else $print("Sorry, need 75000\n")
|
||||
} catch problem $print("Exception: ", problem, "\n")
|
||||
Loading…
Add table
Add a link
Reference in a new issue