I know the stdin.read_line() function, but I wanted to make my code less verbose via the use or something more in line to raw_input() in python.
So I found out about GNU ReadLine in this discussion about vala, however I can`t reproduce it in Genie.
The python code that I want to mimic is:
loop = 1
while loop == 1:
response = raw_input("Enter something or 'quit' to end => ")
if response == 'quit':
print 'quitting'
loop = 0
else:
print 'You typed %s' % response
The far I could get was:
[indent=4]
init
var loop = 1
while loop == 1
// print "Enter something or 'quit' to end => "
var response = ReadLine.read_line("Enter something or 'quit' to end => ")
if response == "quit"
print "quitting"
loop = 0
else
print "You typed %s", response
And tried to compile with:
valac --pkg readline -X -lreadline loopwenquiry.gs
But I am getting the error:
loopwenquiry.gs:7.24-7.31: error: The name `ReadLine' does not exist in the context of `main'
var response = ReadLine.read_line("Enter something or 'quit' to end => ")
^^^^^^^^
loopwenquiry.gs:7.22-7.81: error: var declaration not allowed with non-typed initializer
var response = ReadLine.read_line("Enter something or 'quit' to end => ")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
loopwenquiry.gs:8.12-8.19: error: The name `response' does not exist in the context of `main'
if response == "quit"
^^^^^^^^
loopwenquiry.gs:12.35-12.42: error: The name `response' does not exist in the context of `main'
print "You typed %s", response
^^^^^^^^
Compilation failed: 4 error(s), 0 warning(s)
What am I doing wrong?
Thanks.