How to use BASIC in Puppy

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
kethd
Posts: 451
Joined: Thu 20 Oct 2005, 12:54
Location: Boston MA USA

How to use BASIC in Puppy

#1 Post by kethd »

HOWTO use BASIC in Puppy

Yes, there is BASIC hidden in Puppy (versions 1.0.5 and 1.0.6)!

PuppyBasic is wxbasicscript, a simplified version of wxBasic.

EXAMPLE

From the desktop, click on the <console> icon, to get a command line.

This command tells PuppyBasic to take the program directly from the keyboard:
# puppybasic /dev/tty

Now you can enter your program:
print "Hello World"

On the next line, just enter CTRL-D to finish entering the program. Then the program will run immediately!

STORE A PROGRAM

That is actually a good way to try some simple commands, to see quickly how they work. But you will soon want to use an editor for your programs.

Change to a temporary directory:
# cd tmp

Make a program file:
# leafpad hellow

In the editor, enter the file and save and exit:
' My first program
print "Hello World"
print 2+2
print "Goodbye"
end

Now you can run the program:
# puppybasic hellow

Program development tip:
For quickly making changes and testing them, use the up-arrow key on the command line, to access your previous commands to use the editor or run the program.
For some reason, it does not seem to work to leave the editor open while you try out program changes. But if you open the editor in another one of your four "workspaces", then you can leave it open -- just Save and switch to the console in the other workspace to try it out.

If you have not used BASIC since the 1980's, the line numbers and REM statements seem to be gone, so you will have to brush up on this version.

Use the desktop FIND command to search for files containing wxbs in their names, to see complex examples in Puppy.

You can learn more at:
http://puppylinux.org/wikka/PuppyBasic
http://puppylinux.org/wikka/WxBasic
http://noforum.de/wxBasicscript-documen ... ameset.htm
http://noforum.de/wxBasicscript-documen ... /index.htm

http://www.murga.org/%7Epuppy/viewtopic.php?t=2349
http://www.murga.org/%7Epuppy/viewtopic.php?t=2457
http://www.murga.org/%7Epuppy/viewtopic.php?t=2339
(There is supposed to be an automatic system of executing BASIC programs in Puppy, based on naming files with .wxbs extensions, but it does not seem to work for simple command line text programs.)

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

first script program

#2 Post by Lobster »

Good stuff - well done :)

A piece of code like this
(note you are telling it to run xbasic and call a 'library'
- basefunctions.inc)

Code: Select all

#!/usr/bin/wxbasicscript
include "/usr/lib/wxbasicscript/basefunctions.inc"
//My First Runnable Script 

xmessage ( "I am a Xmessage" )

  print "Hello World"
  print 2+2
  print "Goodbye and thanks for all the fish"

end 
when given changed permissions with rox
(make it excutible)
will run the message BUT the other parts require a command line interface
so run console (right click and open xterm where your script file is)
then type ./myscript (where myscript is the name of your executible text script)

Now you should get a prog in a window and the results of 2+2 etc in the rxvt console window . . .

Hope that works for you :)
Last edited by Lobster on Sat 03 Dec 2005, 04:49, edited 1 time in total.
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

kethd
Posts: 451
Joined: Thu 20 Oct 2005, 12:54
Location: Boston MA USA

This is not so easy!

#3 Post by kethd »

Hmmm... This is not so easy!
I have gotten your example to work. Sort of...
It seems like PuppyLinux does not associate file types with execute modules? The file extensions are mostly arbitrary/meaningless, just to help the humans keep track of things?
It seems like making a file "executable" just means the system is willing to process it as a shell script, if it is text? (How does it distinguish from real binary code?) But for some reason, the current directory is not in the default path, so you need to use ./ to force a reference to the current directory...
The leading #! on the first line tells it where to go for the real executable, to process the text code lines that follow?
The include line just includes text from another file as though it appeared at that point?
The xmessage code makes a window, and requires the included library code to be defined. (After the window closes, sometimes getting "focus" back in the text window is a problem.)

This seems like it may be a reasonably simple way to do complicated (GUI) things -- but so far it seems like a pretty complicated way to do simple things. In terms of simple command line text mode BASIC programs, it seems like there is no advantage to the wxbs naming convention or the #! invocation. (In fact, in the tests I just did, the #! seemed to over-ride my manual invocation of puppybasic from the command line, and prevent me from being able to pass flags like -trace.)

kethd
Posts: 451
Joined: Thu 20 Oct 2005, 12:54
Location: Boston MA USA

#4 Post by kethd »

3 sample PuppyBasic programs:
http://puppylinux.org/wikka/hexdumpBASIC

Post Reply