Standard Input Example.

 

Source file

Either copy and paste this behavior into a file named StandardInputTest.salsa or click below to download the file. StandardInputTest.salsa must be placed in a directory named demo/.

 

Source Code

module demo;

 
/*
   This behavior simply prints out a string,
   reads a line from the Standard Input,
   combines the return value of the Standard Input with other strings,
   and then prints out the combined string.
*/

behavior StandardInputTest{

   public StandardInputTest() {}

   String mergeString(String str1, String str2, String str3) {
       return str1+str2+str3;
    }

   void act(String[] args) {
      standardOutput<-println("What's your name?")@
      standardInput<-readLine()@
      self<-mergeString("Hi, ",token, ". Nice to meet you!" )@
      standardOutput<-println(token);
   }
}

 

return to the salsa home page