@Hugh, I agree Case statements are cool but i remember with VB you could have multi tests on 1 test.
eg case key when :enter, "\n" <- thus enter key OR keypad enter press both are caught here. my test statements here insdie the case block. Now I don't see it as a big issue now as i've got my program working as i want it to for now (ie i can enter a customer # or customer name and get a result from SQLite3). cheers, ----- Original Message Follows ----- > Not forgetting: > Wonder of the When-Be-Splat > > http://redhanded.hobix.com/bits/wonderOfTheWhenBeFlat.html > > Hugh > On Wed, 10 Jun 2009, Bradley Grzesiak wrote: > > > case statements can be pretty neat: > > > > case foo > > when 'bar' > > puts 'bar!' > > when :baz, 'baz' > > puts 'baz! > > when 2000..2009 > > puts 'the aughts!' > > when /^regex(\/ > > puts "matching: #{$1}" > > else > > puts "the naughts!" > > end > > > > > > On Wed, Jun 10, 2009 at 5:45 AM, dave > > <[email protected]> wrote: > > > This post is more for completeness and so hopefully > > help someone someday. > > > > > > > i now have my code working as i want it to so am > > > posting it here. and as you can see i have had to > > rework it from my original post. > > > > > > > please note ... > > > that I have had to use a case statement inside the > > keypress do block. > > > > > > > created a define block for the if tests and the actual > > > test has changed to check on the length of the text as > > apposed to nil or false as before. > > > > > > > would've liked to have the :enter & "\n" in 1 when > > clause to have saved the > > > > define but i couldn't figure it out (after using some > > > like values - semi-comma > > > & comma, space). > > > > > > > > > hope this helps someone in future, > > > > > > > > > Dave. > > > > > > > > > > > > #require "sqlite3_calls" > > > > > > > > > Shoes.app do > > > # extend Dbase > > > > > > def what_has_data > > > if @custno.text.length > 0 > > > alert 'cust number has a value !' > > > # rows = rec_to_find('customers', 'cust_nos', @custno) > > > else > > > if @custname.text.length > 0 > > > alert 'cust name has a value !' > > > end > > > end > > > > > > end > > > > > > stack :top =>5, :height => 90 do > > > title "Find Customer Info", :align => 'center' > > > end > > > > > > > > > flow :top => 100 do > > > para strong "Customer nos" > > > @custno = edit_line :width => 50 > > > > > > > > > para strong 'customer name' > > > @custname = edit_line :width => 270 > > > > > > keypress do |key| > > > case key > > > when :enter > > > what_has_data > > > > > > when "\n" > > > what_has_data > > > > > > > > > end > > > end > > > > > > end > > > > > > stack :top => 250 do > > > para strong 'data return shown here!' > > > end > > > > > > > > > end > > > > > > > > > > > > On Wednesday 10 June 2009 09:53:01 pm dave wrote: > > > > Doh!!! as homer would say. > > > > > > > > am too close to the code to see it. > > > > > > > > many thanks, now onto other issues :). > > > > > > > > On Wednesday 10 June 2009 09:26:14 pm jonty wrote: > > > > > Hi Dave > > > > > > > > > > Just a small help for you > > > > > > > > > > your code contains if x=y.......end > > > > > > > > > > this will set the variable x to being y before > > > > testing it! > > > > > > you need to use the comparison operator == (2 > > > > > equals) as in: if x == y .... end > > > > > > > > > > dave wrote: > > > > > > I have a shoes program (below this message) > > > where what i want to do is > > > > > > to allow the user to enter data into 1 of 2 > > > > > edit_lines. > > > > > > > > > > > > > From the user pressing enter i then check which > > > > > > edit_line has something in it > > > > > > and setup parameters for a SQL statement that 's > > > > > > in a class called dbase that's inside a module > > > > > called sqlite3_calls. > > > > > > > > > > > > > this tho is of no importance yet as i cannot > > > > > capture the enter key! > > > > > > > > > > > > > Note I'm only wanting to get 1 of the two > > > > > > edit_lines working then get the other done once > > > > > i working based on the solution for the 1st one. > > > > > > > > > > > > > Currently what happens is that the program runs > > > > > > but when I alt+/ to see the debug window after > > > > > > my shoes screen appears i see a comment saying > pressed enter! when in fact i haven't press a dam thing > > > except . > > > > > > > > > > > > > > > > > > did a search on keypress and edit_line and > > > > > > keypress but nothing i saw really gave me any > > > > > hints. > > > > > > > > > > > > > Dave. > > > > > > > > > > > > > > > > > > code as it stands is below..... > > > > > > > > > > > > > > > > > > require "sqlite3_calls.rb" > > > > > > > > > > > > > > > > > > Shoes.app do > > > > > > # extend Dbase #for the purposes isolation I've > > > commented out this line > > > > > > > > > > > > stack :top =>5, :height => 90 do > > > > > > title "Find Customer Info", :align => 'center' > > > > > > end > > > > > > > > > > > > > > > > > > flow :top => 100, height => 70 do > > > > > > para strong "Customer nos" > > > > > > @custno = edit_line :width => 50 :focus > > > > > > > > > > > > > > > > > > para strong 'customer name' > > > > > > @custname = edit_line :width => 270 > > > > > > end > > > > > > if keypress = :enter or keypress = "\n" > > > > > > debug 'pressed enter !' > > > > > > if @custno != nil > > > > > > para 'cust number has a value !' > > > > > > # rows = rec_to_find('customers', 'cust_nos', > > > @custno) # please ignore > > > > > > else > > > > > > if @custname != nil > > > > > > para 'cust name has a value !' > > > > > > > > > > > > end > > > > > > > > > > > > end > > > > > > end > > > > > > > > > > > > > > > > > > flow :top => 550 do > > > > > > para strong 'data return shown here!' > > > > > > end > > > > > > > > > > > > > > > > > > end > > > > > > > > > > ---------------------------------------------------------- > > > > > ------------- >- > > > > > > > > > > > > > > > > > > No virus found in this incoming message. > > > > > > Checked by AVG - www.avg.com > > > > > > Version: 8.5.339 / Virus Database: > > > > > > 270.12.60/2166 - Release Date: 06/09/09 18:08:00 > > > > > > > > > > > > > > > > > > -- > > Bradley Grzesiak > > [email protected] > > http://toleoandbeyond.blogspot.com > > > > * You have received an email from my personal account. > > Please do not divulge this address to any website (eg: > > evite, shutterfly, etc). I have another address for such > > uses; please ask me for it.
