PuppyBasic 2.6 (updated august, 06, 2008)

Stuff that has yet to be sorted into a category.
Post Reply
Message
Author
User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

PuppyBasic 2.6 (updated august, 06, 2008)

#1 Post by MU »

2 major changes from my side:

xwin_system() explained here:
http://wxbasic.sourceforge.net/phpBB2/v ... .php?t=992

So now like in the bash you can run

Code: Select all

mylist = xwin_system("ls /root")
for each folder in mylist
  print folder
next
Or any other programs.

puppybasic -v works now (version-information).

And a new comandlineargument "-e" for "execute"

Now you can run
puppybasic -e 'print 2*4'
Or
puppybasic -e 'a=2:b=4:print a*b'

Minor changes:
added "cutleftfromright()" to basefunctions.inc
Added basefunctions2.inc, this is identical to basefunctions.inc, but also works if you use "option explicit" to create safer/cleaner code.

It is based on wxBasic 2.5.
Readme, source, binary:
http://noforum.de/files/wxbasic/PuppyBasic-2.5/

UPDATE 2.6:
http://www.murga-linux.com/puppy/viewto ... 475#220475

Mark
Last edited by MU on Wed 06 Aug 2008, 08:48, edited 4 times in total.

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#2 Post by MU »

Updated the files, there was a small error with the returncodes (they were not divided by 256).

With the new version, you can use them for example to check, if a folder exists:

Code: Select all

#!/usr/bin/puppybasic

//-- using stdout for a custom "input":
print "enter a foldername to test, if it exists:"
a,b = xwin_system("read a;echo $a")

//-- trim removes linefeeds
testfolder = trim(a[0])

//-- test if the folder exists by using the exitcode
a,b = xwin_system("if [ -d '" & testfolder & "' ];then exit 0;else exit 1;fi")

if b = 0 then
  print "dir " & testfolder & " exists"
else
  print "dir " & testfolder & " does not exist"
end if
This example shows the real name of the "home" folder:

Code: Select all

#!/usr/bin/puppybasic

//-- find out homefolder
a,b = xwin_system("echo ~")
print "the homefolder is: " & trim(a[0])

Code: Select all

#!/usr/bin/puppybasic

 //------------------
//- using xmessage

//-- return Button-CODES
a,b = xwin_system("xmessage -center -buttons 'yes,no' 'choose a button'")
print "result from xmessage: " & b

//-- return Button-TEXT
a,b = xwin_system("xmessage -print -center -buttons 'yes,no' 'choose a button';echo $?")
print "result from xmessage: " & trim(a[0])

Mark

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#3 Post by GuestToo »

that's useful ... an interface to the system shell

i think this is how i would do it:

cmd = "test -d '" & testfolder & "'"
a,b = xwin_system(cmd)

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#4 Post by MU »

yes, that's a good way.

You could use the resulting exitcode to choose the resulting text from a list:

Code: Select all

//-- a shorter way to test if a folder exists:
cmd = "test -d '" & testfolder & "'" 
a,b = xwin_system(cmd)

dirchecktext = {}
dirchecktext[0] = " exists"
dirchecktext[1] = " does not exist"
print "the folder " & testfolder & dirchecktext[b]
Mark

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#5 Post by MU »

I updated the files.
The interpreter is unchanged, but I added "natsort" and "reducelist" to the basefunctions.inc

natsort:
newlist = natsort (oldlist)
if oldlist is
r t g T
then newlist is
g r T t

reducelist:
deletes double-entries that follow each other..
a a a f t
will become
a f t

You usually will run natsort or bubblesort first, then reducelist.

Here is a prototype of a quite fast dependency-checker using these functions:
http://dotpups.de/tests/PSI-dev/checkdep-standalone

run it like this:
checkdep-standalone Gimp-2.3.10-CVS-Gtk-2.8.files

Look in /root/.packages/ for existing ones.

It displays a gauge of the process 8)

It is very fast, as it excludes files like ".png" ".txt" from the checks.
It works in PSI, bit is not finished yet (must add a check for existing libraries in gimp.files, too).
Mark

User avatar
klhrevolutionist
Posts: 1121
Joined: Wed 08 Jun 2005, 10:09

#6 Post by klhrevolutionist »

Seeing as I cannot comprehend any of these languages out there.
I came across this http://easynews.dl.sourceforge.net/sour ... 0.3.tar.gz

http://kidbasic.sourceforge.net/ - line-oriented language

I also saw something about gtkhtml. But it looks like it requires a bunch of gnome...


MU give me or us your thoughts on this please.
Heaven is on the way, until then let's get the truth out!

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#7 Post by MU »

Kidbasic needs Qt4 (that will be the base for KDE4).

We don't have a dotpup yet.

But you can run the windows-version in Wine.

Gtkhtml: the current version heavily depends on Gnome, but I think there is an older library that works without gnome.

Liferea uses Gtkhtml:
http://www.murga.org/~puppy/viewtopic.php?t=10127

But Gtkhtml is not easy to program, it requires C-code.

Mark

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#8 Post by MU »

Updated to PuppyBasic 2.6.

Changes:

- the file-fuctions had limitations.
Line input would read only 1024 characters, I extended this to 10240.
Also now 254 instead of 32 filehandles are supported.

- added 2 new functions to basefunctions.inc and asefunctions2.inc:

thelist = quicknatsort (thelist , startitem , lastitem)
thevalue = getargs("test")
This would return "fine", if you ran your program like this:
program --test fine

- I also cleaned up the dialog-functions, they no longer use temporary files.
And I added gtkdialog3() to run templates with gtkdialog 3.

- added the latest xwin_ functions from GtkBasic, that do not depend on Gtk.

I compiled it in Muppy007 (Puppy 2.12), because like this I could avoid unneeded dependencies (libxcb from Puppy3 or libpixmap from Puppy4).
Tested in Puppy 2, 3,4.

Download:
http://dotpups.de/dotpups/Programming/P ... ic-2.6.pet
mirror:
http://puppyfiles.ca/dotpupsde/dotpups/Programming/
source:
http://noforum.de/files/wxbasic/PuppyBasic-2.6/


Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#9 Post by MU »

updated the 2.6 pet and source.
There was a bug in using Xdialog, fixed it.
Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#10 Post by MU »

there was another bug with the new Xdialog code.
It did not work correct with erratic Gtk-Themes.

Updated Puppybasic 2.6 again.

Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

Post Reply