yab | yet another Basic for HAIKU
Peek requests - Printable Version

+- yab | yet another Basic for HAIKU (https://yab.orgfree.com/forum)
+-- Forum: installing / troubleshooting / feature requests (https://yab.orgfree.com/forum/forumdisplay.php?fid=5)
+--- Forum: feature requests / bug fixes (https://yab.orgfree.com/forum/forumdisplay.php?fid=11)
+--- Thread: Peek requests (/showthread.php?tid=57)



Peek requests - clasqm - 03-21-2016

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


RE: Peek requests - bbjimmy - 03-23-2016

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.


RE: Peek requests - clasqm - 03-25-2016

(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.


Free Web Hosting