docs.roxen.comBack to normal mode
DocsPike7.0TutorialFirst Steps
Copyright © 2012, Roxen Internet Software
Suggestions, comments & compliments
manuals@roxen.com

Interactive Pike

You can use Pike interactively, which means that you type a line at a time, letting Pike execute it immediately. Just start Pike by giving the command pike, without any arguments. Then type a statement, for example:

# pike
Pike v7.0 release 37 running Hilfe v2.0 (Incremental Pike Frontend)
> write("hello!\n");

Pike will then do what you told it to do, i. e. print "hello!" on a line:

# pike
Pike v7.0 release 37 running Hilfe v2.0 (Incremental Pike Frontend)
> write("hello!\n");
hello!

Similar to main, the built-in function write returns a value, which happens to be the number of characters it has written. Interactive Pike will also show you this return value:

# pike
Pike v7.0 release 37 running Hilfe v2.0 (Incremental Pike Frontend)
> write("hello!\n");
hello!
Result: 7
> 

(Seven characters: h, e, l, l, o, the exclamation mark, and the newline character.)

Running Pike interactively like this can be very useful when testing things, for example when you are following this tutorial. It can also be used as a very advanced calculator. But beware! Some things don't work the same way in interactive mode as they do when you run a Pike program from a file! For example, type checking is turned off.