Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 16 Apr 2014, 09:08
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
How to use BASIC in Puppy
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [4 Posts]  
Author Message
kethd

Joined: 20 Oct 2005
Posts: 451
Location: Boston MA USA

PostPosted: Fri 02 Dec 2005, 12:08    Post subject:  How to use BASIC in Puppy  

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-documentation/wxbasic/frameset.htm
http://noforum.de/wxBasicscript-documentation/wxbasicscript/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.)
Back to top
View user's profile Send private message 
Lobster
Official Crustacean


Joined: 04 May 2005
Posts: 15117
Location: Paradox Realm

PostPosted: Fri 02 Dec 2005, 13:35    Post subject: first script program  

Good stuff - well done Smile

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

Code:
#!/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 Smile

_________________
Puppy WIKI

Last edited by Lobster on Sat 03 Dec 2005, 00:49; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
kethd

Joined: 20 Oct 2005
Posts: 451
Location: Boston MA USA

PostPosted: Fri 02 Dec 2005, 18:59    Post subject: This is not so easy!  

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.)
Back to top
View user's profile Send private message 
kethd

Joined: 20 Oct 2005
Posts: 451
Location: Boston MA USA

PostPosted: Sat 10 Dec 2005, 18:55    Post subject:  

3 sample PuppyBasic programs:
http://puppylinux.org/wikka/hexdumpBASIC
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [4 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0449s ][ Queries: 11 (0.0040s) ][ GZIP on ]