Power Status (was Re: Because LC can't do two things at once.)

Richard Gaskin ambassador at fourthworld.com
Sat Mar 7 11:33:13 EST 2015


Mark Wieder wrote:

 > And now that I'm looking at it again, I don't think that's the proper
 > format for the url command. It should be
 >
 > put url "file:///sys/class/power_supply/BAT0/status" into tStatus

Oddly, I find that LC's file I/O routines don't work with *NIX virtual 
file system elements.  I can use cat in shell to get those values, but 
neither LC's open/read/close nor get url options for work me.

It would be helpful if you could test this on your machine and verify 
what I've seen on both of my Ubuntu boxes:

on mouseUp
    put "/proc/meminfo" into tFile
    put url ("file:"& tFile) into t1
    put the result into r1
    --
    open file tFile for read
    put the result into r2
    read from file tFile until EOF
    put it into t2
    close file tFile
    --
    put shell("cat "& tFile) into t3
    put the result into r3
    --
    put "URL: "& t1 && r1 &cr\
    & "Open: "& t2 && r2 &cr\
    & "Shell: "& t3 && r3
end mouseUp

Here both of the first two values are empty, but the latter works fine. 
  In all three cases the result is empty, which I would expect for the 
one that works but not for the two that don't.

And since you've memorized the LC code base <g>, can you guess why LC's 
file I/O routines don't work on virtual file system elements the way 
that nearly everything else in Linux does?

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com




More information about the Use-livecode mailing list