1*c29d5175SchristosThe following is a demonstration of the guess.d script, 2*c29d5175Schristos 3*c29d5175Schristos 4*c29d5175Schristosguess.d is a guessing game written in DTrace. It goes like this, 5*c29d5175Schristos 6*c29d5175Schristos # ./guess.d 7*c29d5175Schristos guess.d - Guess a number between 1 and 100 8*c29d5175Schristos 9*c29d5175Schristos Enter guess 1: 50 10*c29d5175Schristos Lower... 11*c29d5175Schristos Enter guess 2: 25 12*c29d5175Schristos Higher... 13*c29d5175Schristos Enter guess 3: 37 14*c29d5175Schristos Higher... 15*c29d5175Schristos Enter guess 4: 44 16*c29d5175Schristos Higher... 17*c29d5175Schristos Enter guess 5: 48 18*c29d5175Schristos Lower... 19*c29d5175Schristos Enter guess 6: 46 20*c29d5175Schristos Lower... 21*c29d5175Schristos Enter guess 7: 45 22*c29d5175Schristos Correct! That took 7 guesses. 23*c29d5175Schristos 24*c29d5175Schristos Please enter your name: Brendan Gregg 25*c29d5175Schristos 26*c29d5175Schristos Previous high scores, 27*c29d5175Schristos Fred Nurk 7 28*c29d5175Schristos Brendan Gregg 7 29*c29d5175Schristos 30*c29d5175SchristosIt was written as a demonstration of the same code written in dozens of 31*c29d5175Schristoslanguages. It makes a good demonstration, as it covers integer and string 32*c29d5175Schristosvariables, conditional statements, loops, keyboard input, screen output, 33*c29d5175Schristosand file input and output. 34*c29d5175Schristos 35*c29d5175SchristosWritten in DTrace however, is not such a good demonstration! DTrace doesn't 36*c29d5175Schristoshave loops (it doesn't really need them either) which made the code a 37*c29d5175Schristoslittle odd. DTrace also doesn't have keyboard input... So this script is 38*c29d5175Schristossomewhat amusing as an example, but not terribly useful. 39*c29d5175Schristos 40