Release Candidates :: DSL v3.1 RC2



That "test" together with the io.input actually opens the file twice. Once in the test which then closes it, then again with the following io.input. I would rather to use io.open to which will allow control of error condition. Also, I would rather try to stay as generic Lua/Fltk as possible. Some of those tests as well as many others could also be easily added to our own functions5.lua. But then again, it becomes easy to use and not realize the overhead of what is happening, opening and closing files. If it were at the Lua base level via the os library then I would not have such concern. But then again that is my way of thinking.
Quote
it becomes easy to use and not realize the overhead of what is happening, opening and closing files
true. I usually think primarily about file size and noticeable performance differences, and not so much about what is actually happening. I'm sure it would be much more noticeable in a larger application running on a slower machine.

EDIT:
Would something like this work better, or am I doing the same type of redundant work?
Code Sample
 dotmydsl=io.open("/home/dsl/.mydsl")
 if dotmydsl then
   mydsl_dir = dotmydsl:read("*line")
   io.close(dotmydsl)
 else
   mydsl_dir = "/"
 end

mikshaw, YES, now that's what I am talking about.
I prefer that approach.

But, I still don't really like the failover to /, which was my original post.
But "load local" is more than likely in lieu of the auto loading via the autoscanned "mydsl dir" or the boot time option of "mydsl=xxxx". So, I guess that failover shall remain until it becomes set via user navigation.



1) I don't really understand why we need /opt/.dslrc and /home/dsl/.mydsl.
2) Due to error in loading unc via mydsl icon I've changed /usr/bin/mydslinfo.lua to
Code Sample

#!/bin/murgaLua

-- (c) 2005, 2006 Robert Shingledecker
-- myDSL info display usually called from mydslBrowser

dofile("/etc/init.d/functions5.lua")

function parseInfo(infofile)
 local i,j = string.find(infofile,".info")
 if not i then
    return nil
 end
 local basename=string.sub(infofile,1,i-1)
 local k,l = string.find(basename,'.dsl')
 if k then
    return basename
 else
    m,n = string.find(basename,'.uci')
    if m then
       return basename
    else
       o,p = string.find(basename,'.unc')
       if o then
          return basename
       else
          return basename .. '.tar.gz'
       end
    end
 end
end

-- Main
if #arg == 2 then
  library = arg[1]
  infofile = arg[2]
else
  print("usage: mydslInfo.lua [library_name infofile_name]")
  os.exit(1)
end

os.execute("pkill mydslBrowser.lua")

mirror = getOption("/opt/.dslrc","Mirror")
protocol = getOption("/opt/.dslrc","Protocol")

os.execute('wget -q '..protocol..'://'..mirror..'/mydsl/'..library..'/'..infofile)

wWidth=500
wHgth=290
w = fltk:Fl_Window(wWidth,wHgth,infofile)

browser = fltk:Fl_Browser(0,0,wWidth,wHgth-30)
if not browser:load(infofile) then
  print("can't load ", infofile)
  os.exit(1)
end

cancelBtn = fltk:Fl_Button(180,wHgth-28,70,25,"&Cancel")
cancelBtn:shortcut('c')
cancelBtn:callback(
function(cancelBtn)
 os.remove(infofile)
 os.exit(0)
end)

downloadBtn = fltk:Fl_Button(255,wHgth-28,70,25,"&Download")
downloadBtn:shortcut('d')
downloadBtn:callback(
function(downloadBtn)
 extension = parseInfo(infofile)
 os.remove(infofile)
 os.execute('mydslDownload.lua ' .. library .. ' ' .. extension)
 os.exit(0)
end)

w:resizable(w)
w:show()
Fl:run()


I concur, good job, and thanks for your interest in testing.

1. I believe you meant /opt/.mydsl_dir which I have already made this change.

Next Page...
original here.