Peek requests
#1
A few items of system information that I think would be useful to yab programmers if they were added to the PEEK system. There are workarounds for these, mostly involving system calls like SYSTEM$("if [ -e filename ] )", and parsing the results, but having them in the system would speed things up.

var = PEEK "PackageStatus"
0 running from a non-packaged location
1 running from /boot/system
2 running from /boot/home/config

var = PEEK "FileExists" Filename$
0 File does not exist
1 File exists

var = PEEK "DirectoryExists" Pathname$
0 Directory does not exist
1 Directory exists
Reply
#2
The first two are already available in yab without calling the system.

PackageStatus:

Code:
name$="yourprogramname"
path$=attribute get$ "",""
programname$=path$+"/"+name$
print programname$
attribute$=attribute get$ "",programname$

if instr(attribute$, "SYS:PACKAGE_FILE") and instr(path$,"/boot/system") print "program is a package in the system tree"
if instr(attribute$, "SYS:PACKAGE_FILE") and instr(path$,"/boot/home/config") print "program is a package in the home tree"
if (! instr(attribute$, "SYS:PACKAGE_FILE")) print "not in a package location"

FileExists:

Code:
name$="your file name"
if open(name$,"r") then
print name$+" exists"
else
print name$+" does not exist"
endif

The path may need to be added to the peek$ command.
Reply
#3
(03-23-2016, 09:42 AM)bbjimmy Wrote: The first two are already available in yab without calling the system.

Thanks, I think I will write those into a library.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)
Free Web Hosting