You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Pike mailinglist
Hello everyone, I started this email because I initially had a question, but I was able to figure it out. I'm learning PIke and for practice I have written this simple IO program in half a dozen plus languages especially C-based languages, D being one of my favorites, as seen here:
importstd.stdio;
importstd.string; // strip(), toLower();
importcore.thread; // sleep();
voidmain() {
stringuserInput;
do {
write("> ");
userInput=readln.strip();
writeln("You wrote '",userInput,"'");
} while (toLower(userInput) !="q");
writeln("Goodbye!");
Thread.sleep(2.seconds);
}
The program outputs whatever the user inputs and exits when the user inputs "q" or 'Q'. It's always interesting to see how various programs differ. For example, some languages will capture the newline char in the IO stream and strip or trim functions are needed, not so in Pike. Although I'm a beginner-to-intermediate programmer, it didn't take me long to figure out the Pike syntax and I find it to be very pleasant to code in. Also I'm testing if formatted code is visible within this mailing list - if not, then the attached image shows partially what I'm seeing on my end. :)
intmain() {
string userInput;
do {
write("> ");
userInput = Stdio.stdin->gets();
write("You wrote '" +userInput+ "'\n");
} while (lower_case(userInput) != "q");
write("Goodbye!\n");
sleep(2); // 2 seconds
return0;
}
Thank you, Gary
William Welliver
unread,
Jul 14, 2022, 11:48:34 AM7/14/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to chikega, Pike mailinglist
Hi Gary, and welcome!
I’ve always felt that D would have been “my” language if I hadn’t found pike first, all those years ago. The two seem to share a good deal of spiritual commonality.
Something that’s been said about pike over the years is that it tries to produce the best (fastest, does what you want) result when you write the most straightforward code to implement it. That’s certainly not true of all languages (I’m looking at you, Java!)
For extra credit, you might look at the Readline module, which has some nice features for reading input. Sadly the documentation for it is poor to nonexistent… though I can point to examples of it in use if anyone is interested. Maybe I’ll even find some time to document the bits I understand if I get a few free moments!
Anyhow, welcome again and don’t hesitate to post a message if you have any questions in the future. We’re always happy to help!
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to William Welliver, Pike mailinglist
Hi William,
I really gave it a go trying to figure out how to use Stdio.Readline using every language syntax permutation that I'm familiar with such as D and Object Pascal(readln), C#: (Console.ReadLine), etc..
The documentation as you've mentioned appears to be incomplete concerning Readline(). Well, I even copied this entire program with the use of readline, but I just get a bunch of errors. So yes, it would be really cool if you could point me in the right direction :)