yab | yet another Basic for HAIKU

Full Version: Peek requests
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
The first two are already available in yab without calling the system.


path$=attribute get$ "",""
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"


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

The path may need to be added to the peek$ command.
(03-24-2016, 01: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.
Free Web Hosting