From: Robert Klemme Date: 2006-08-16T05:55:09+09:00 Subject: Re: goto function? fabsy wrote: > Hey! > I have been trying to find a goto function in ruby.. > Like this: > > foo: bar > If blabla then GOTO foo > > Is there any command for exiting the app? > And how do I search ex a textfile for a certain word and delete it? > > > ------ > > if value == "2" > system('clear') > print "[Opening file..]\n\n" > r_file = File.open( "file", "a") #Wrote this so I wouldn't get an > error like "File doesn't exist". > r_file = File.open( "file", "r") > print "-----\n" > print r_file.read > print "-----" > print "\n" > system ('ruby note.rb') #is there anyway to restart or goto the > beginning of the script? > end > > ----- > > Thanks! > begin ... end while your_condition_here begin ... end until your_condition_here If you need an endless loop loop do ... end See also http://ruby-doc.org/docs/ProgrammingRuby/html/tut_expressions.html#S6 Note that your script opens the file over and over again and never closes it. This can cause problems - especially since you do it with different modes. Kind regards robert