A
aidy
I have a simple web GUI that I would like to read a file and enter data
into
This is my class
class Form
def initialize
@filename = "search.txt"
end
def enter_data
read_in_test_data.each { |x|
line = x.chomp
#need to log testId
next if line.upcase.include? 'TESTID'
next if line.upcase == 'ADDRESS:'
$ie.text_fieldname, 'Address1').set(line)
$ie.text_fieldname, 'Address2').set(line)
$ie.text_fieldname, 'Address3').set(line)
$ie.text_fieldname, 'Address4').set(line)
$ie.text_fieldname, 'Address5').set(line)
$ie.text_fieldname, 'Address6').set(line)
$ie.text_fieldname, 'Address7').set(line)
}
end
def read_in_test_data
#check if file exists and give date of last change
File.readlines(@filename, "\n" )
end
private:read_in_test_data
end
this is an example of the file I am reading
*********************************************** TESTID_10
Address:
30 Choyce Close
Atherstone
Warwickshire
Country:
GB
Search-Results:
20
*********************************************** TESTID_20
Address:
Hamilton Chartered Surveyors
Aidy Street
Bath
Country:
GB
Search-Results:
1
*********************************************** TESTID_30
Sometimes the address can be upto 1..7 lines. What I am looking for is
something like a goto
statement, that when 'Country:' is found a different field can be
filled in e.g.($ie.text_fieldname, 'Ctry1').set(line).
Thanks for the help
Cheers
Aidy
into
This is my class
class Form
def initialize
@filename = "search.txt"
end
def enter_data
read_in_test_data.each { |x|
line = x.chomp
#need to log testId
next if line.upcase.include? 'TESTID'
next if line.upcase == 'ADDRESS:'
$ie.text_fieldname, 'Address1').set(line)
$ie.text_fieldname, 'Address2').set(line)
$ie.text_fieldname, 'Address3').set(line)
$ie.text_fieldname, 'Address4').set(line)
$ie.text_fieldname, 'Address5').set(line)
$ie.text_fieldname, 'Address6').set(line)
$ie.text_fieldname, 'Address7').set(line)
}
end
def read_in_test_data
#check if file exists and give date of last change
File.readlines(@filename, "\n" )
end
private:read_in_test_data
end
this is an example of the file I am reading
*********************************************** TESTID_10
Address:
30 Choyce Close
Atherstone
Warwickshire
Country:
GB
Search-Results:
20
*********************************************** TESTID_20
Address:
Hamilton Chartered Surveyors
Aidy Street
Bath
Country:
GB
Search-Results:
1
*********************************************** TESTID_30
Sometimes the address can be upto 1..7 lines. What I am looking for is
something like a goto
statement, that when 'Country:' is found a different field can be
filled in e.g.($ie.text_fieldname, 'Ctry1').set(line).
Thanks for the help
Cheers
Aidy