I am tearing my hair out on this. I am working on a project that, amongst other things, is reading in .desktop files and storing some of the information it finds in them. I'd like to use classes to store the info but I am getting some behaviour which I only half understand.
I've created a simple test program to demonstrate:
Code: Select all
class Thing
prop nameline : string = "** name line not found **"
prop genericnameline : string = " generic name line not found **"
init
line : string
lngth : size_t
var t = new Thing()
var dis = new DataInputStream(File.new_for_path("/usr/share/applications/Geany-text-editor.desktop").read())
while ((line = dis.read_line (out lngth, null)) != null)
if line.has_prefix("Name=")
t.nameline = line
else if line.has_prefix("GenericName=")
t.genericnameline = line
print "We found\n Name: %s\n Generic name: %s", t.nameline, t.genericnameline
Code: Select all
We found
Name:
Generic Name: XricName=Geany^ [[?1;2c
Code: Select all
init
line : string
lngth : size_t
nameline : string = "** name line not found **"
genericnameline : string = "** generic name line not found **"
var dis = new DataInputStream(File.new_for_path("/usr/share/applications/Geany-text-editor.desktop").read())
while ((line = dis.read_line (out lngth, null)) != null)
if line.has_prefix("Name=")
nameline = line
else if line.has_prefix("GenericName=")
genericnameline = line
print "We found\n Name: %s\n Generic name: %s", nameline, genericnameline
Code: Select all
We found
Name: Name=Geany text editor
GenericName: GenericName=Geany
Can anyone advise?
Thanks,
Rob