Problems with programming (shoes)

heey, i have a problem with my script could some one please look at it
and tell me why my search button and list button doesn’t work!!

the script workes fine when i don’t have it in a SHOES inviroment (GUI)

here is my script:

Shoes.app :title => “PPID”, :height => 400, :width => 700 do
background black, :height => 60
background gradient(rgb(1.0, 1.0, 1.0, 0.7), rgb(1.0, 1.0, 1.0, 0.0))
title “PPID”, :align => “center”, :stroke => white
caption “Personal: Person Info Database”, :top => 80, :left => 20
stack :top => 85, :left => 380 do
flow do
name = edit_line :width => 150
button “Search” do
ds = SomeDataProcessing.openOn(“PPIDdata.txt”)
ds.showData(name.text)
end
button “List” do
dl = SomeDataProcessing.openOn(“PPIDdata.txt”)
dl.listData
end
end
end

#< between here there is a other part of the script but that is working
fine>

class SomeDataProcessing
Person = Struct.new :name, :last_name, :phone_number, :birthday,
:city, :adress
def self.openOn(p_file)
new(p_file)
end
def initialize(p_file)
@file = p_file
@persons = {}
loadData
end
def listData
@persons.keys.sort.each {|p| showlistData§}
end
def loadData
File.foreach(@file) do |line|
name, last_name, phone_number, birthday, city, adress =
line.chomp.split(",")
@persons[name] = Person.new(name, last_name, phone_number,
birthday, city, adress)
end
end
def showData(p_name)
person = @persons[p_name]
if person.nil?
then
@show_text2 = “#{p_name} not in database.”
end
stack do
@show_text2 = “Name: #{person.name} #{person.last_name}”
“Phonenumber: #{person.phone_number}”
“Birthday: #{person.birthday}”
“City: #{person.city}”
“Adress: #{person.adress}”
end
edit_box @show_text2, :width => 250, :height => 200, :top => 140,
:left => 380
end
def showlistData(p_name)
person = @persons[p_name]
if person.nil?
then
@show_text3 = “#{p_name} not in database.”
end
@show_text3 = “#{person.name} #{person.last_name}”
edit_box @show_text3, :width => 250, :height => 200, :top => 140,
:left => 380
end
end

end

You can check the Shoes Console with command-/. When typing something
into
the search bar, I see ‘uninitialized constant
Shoes::App::SomeDataProcessing.’ This happens because you use
SomeDataProcessing before you define it. Moving the definition above
gives
an error about not having the data file, do you have an example of the
format it’s in?

Hi Lark W., Steve and folks,

You define the SomeDataProcessing class within Shoes.app block.

But even in the Shoes.app block, you can’t use Shoes methods (ex. stack,
edit_box, etc.) directly in the SomeDataProcessing class. As same as the
following snippet:


class A
def a
puts ‘hi’
end
end

def m
a
end

m #=> undefined local variable or method `a’

i am still stuck, can somebody please help me

heey thank you all for the reactions

to Steve K., the file i am using is verry standart it is

a .txt file with data in saperated lines, the data in one line is
saperated with a “,” here is a example for it:
test,test,test,test-test-test,test,test test

just put it in a .txt file with the name “PPID data”

to Ashbb: i understand that it doesn’t work that way

but i think u mean this code :
dl = SomeDataProcessing.openOn(“PPIDdata.txt”)
dl.listData

that code works without Shoes.

thanks again

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs