Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changes between Version 3 and Version 4 of IoWithMangoExample

Show
Ignore:
Author:
teqdruid (IP: 129.2.217.216)
Timestamp:
04/27/06 01:21:48 (18 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • IoWithMangoExample

    v3 v4  
    55== Description == 
    66 
    7 Shows you how to use the Mango library for I/O. 
     7Shows you how to use the Mango library for console I/O. 
    88 
    99== Example == 
    1010 
    11 The following example uses Mango's "Whisper" syntax: 
    12  
    1311{{{ 
    1412#!d 
    15 import mango.io.Stdout; 
    16 import mango.io.Stdin; 
     13import mango.io.Console; 
    1714 
    18 int main() 
     15void main() 
    1916{ 
    20     Stdout ("MANGO I/O EXAMPLE 1"c) (CR) (CR); //The 'c' postfix is necessary to identify the string as UTF8 
    21      
    22     char[] name; 
     17        char[] name; 
    2318 
    24     Stdout ("NAME: "c) (); //Usually a flush only occurs with a line feed, so we trigger it manually with () 
    25     Stdin (name); 
    26  
    27     Stdout (CR) (CR) ("Hello, "c) (name) ("; how are you?"c) (CR); 
    28  
    29     return 0; 
     19        Cout ("mango IO example #1").newline.newline; 
     20        Cout ("What is your name? "); 
     21        Cin  (name); 
     22        Cout ("Hello, ") (name); 
    3023} 
    3124 
    32 }}} 
    33  
    34 This next example uses Mango's original method syntax: 
    35  
    36 {{{ 
    37 #!d 
    38 import mango.io.Stdout; 
    39 import mango.io.Stdin; 
    40  
    41 int main() 
    42 { 
    43     Stdout.put("MANGO I/O EXAMPLE 1"c).put(CR).put(CR); //The 'c' postfix is necessary to identify the string as UTF8 
    44      
    45     char[] name; 
    46  
    47     Stdout.put("NAME: "c).flush; //Usually a flush only occurs with a line feed, so we trigger it manually 
    48     Stdin.get(name); 
    49  
    50     Stdout.put(CR).put(CR).put("Hello, "c).put(name).put("; how are you?"c).put(CR); 
    51  
    52     return 0; 
    53 } 
    5425}}} 
    5526