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 Fri 31 Oct 2014, 11:08
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
Recommendation for simple programming language for utilities
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [14 Posts]  
Author Message
veronicathecow


Joined: 21 Oct 2006
Posts: 533

PostPosted: Tue 08 May 2007, 08:14    Post subject:  Recommendation for simple programming language for utilities  

Hi, I want to try and muck around making a few little utilities to do things like mount drives.
Can anyone recommend a simple language for me to use (I've used Spectrum Basic, QBasic, Visual Basic and many years ago some hex 8085)
Something to make some simple boxes and to be able to use command like Mount.
Any thoughts appreciated but please remember I really am a beginner here and work best by seeing example programs that are commented.
Many thanks
Back to top
View user's profile Send private message 
Lobster
Official Crustacean


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

PostPosted: Tue 08 May 2007, 08:36    Post subject:  

Smile

There are many reasons why I suggest using BASH
Dialects of Basic (such as Puppy Basic) still await a comprehensive manual / tutorial

Bash is VERY powerful, the chances are you will be calling BASH (Bourne Again SHell) from your choosen language

http://puppylinux.org/wikka/ProgrammingLanguage
http://puppylinux.org/wikka/PuppyBasic

_________________
Puppy WIKI
Back to top
View user's profile Send private message Visit poster's website 
wdef

Joined: 13 Apr 2007
Posts: 91

PostPosted: Tue 08 May 2007, 11:50    Post subject:  

You can make simple boxes and things with bash using dialog or one of its variants. Not that pretty but it works.

If you know and love any perl: perlgtk or perlgtk2 is quite a powerful gui methodology, I've used it. A good example of a well-known program with a perlgtk GUI would be dvd::rip. It's not trivial to learn, and you need to know a little perl.

Lua guis using flua (is it?) and John Murga's own MurgaLua is a very light and fast GUI language, used with great effect in damnsmalllinux. Lua addicts swear by it..

BTW, the two most useful languages you can learn in linux are bash and perl. The former glues most systems together and is the lingua franca; the latter can just about do anything.
Back to top
View user's profile Send private message 
GuestToo
Puppy Master

Joined: 04 May 2005
Posts: 4078

PostPosted: Tue 08 May 2007, 22:09    Post subject:  

Puppy 216's devx has FreeBasic, which is based on Qbasic/QuickBasic syntax ... if you are familiar with Qbasic, you will feel at home using FreeBasic ... though you would need to interface with other libraries/programs to create gui windows
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Tue 15 May 2007, 19:30    Post subject: Simple programming languages
Subject description: various scripting languages available
 

Dear VtC,

If you really don't like bash's crypting syntax, you can use a variety of interpreters out there as shells. FreeBasic comes with fbsh - which is a scripting Basic you can use to write your own "bash-like" scripts in Basic. You could also get brandy (BB Basic V, as in Acorn and Archimedes), WSbasic or MoleBasic. They are rather small. WS weighs in at 119k and BBC basic (brandy) is not much larger (at 194k). You need to include the "shebang" character combination at the top of your basic script to get it to run "automatically". All the above allow you to execute external (i.e. Unix) commands and to get the results back from either stderr or stdout. What follows is just a silly WSbasic example I did for demonstration purposes. What is key here is that I get the ls listing (or any output) into a variable and can then manipulate it or use it, for instance, to control conditional branching. If you're interested I could upload my recently compiled verions brandy and wsbasic for you to have a look at.

With kind regards,
vovchik

-------------------

#!/usr/local/bin/wsbasic
# usage: p <target address for ping> (the default is my ISP gateway)

# -------------------------------------------------------------------

# This script pings a target address five times every 60 seconds and
# then shows the results in a terminal. The program continues in
# an endless loop until Ctrl-C is pressed. All functions must be defined
# at the top, before the actual program is invoked. The default target
# address can be changed via the default_addr var in the initialize
# variables section (set to my local IP by default).

# 29 April 2007, vovchik
# -------------------------------------------------------------------
# define printx - print external function
# -------------------------------------------------------------------

# this function removes the last byte from stringvars
# passed to wsbasic via an external call - i.e. run(x) - that terminate with a
# a superfluous LF.

function printx(xstring)
begin
print left(xstring,len(xstring)-1)
end # end function printx()

# -------------------------------------------------------------------
# define makeline - string concatenation function
# -------------------------------------------------------------------

# this function creates a long string of hyphens, used to separate
# elements of the screen display.

function makeline(stringvar,integer)
begin
catstring = ""
for xx = 1 to integer
begin
catstring = catstring + stringvar
end
return catstring
end # end function makeline()

# -------------------------------------------------------------------
# initialize variables - some only for the sake of Pascal-like formality
# -------------------------------------------------------------------

cmd_line = "" # only a formalism
xstring = "" # only a formalism
target_addr = "" # only a formalism
default_addr = "192.168.0.1" # default ping target - change to suit your needs
null_string = "" # just initialization of string
dummy_var = 0 # dummy var value for endless loop
run_count = 0 # iteration counter - only for information
hyphen = "-" # char passed to makeline function
long_line = makeline(hyphen,70) # invocation of function to create long hyphen string
ping_cmd="ping -c 5 " # actual unix ping command for 5 ping requests
delay = 60 # duration of delay (seconds) between invocations
getdate="date" # unix date command
usr_msg = "Pausing for " + delay + " seconds... Interrupt program with Ctrl-C."

# -------------------------------------------------------------------
# check the command line for arguments
# -------------------------------------------------------------------

# Wsbasic, when run as a shell interpreter, assigns #$ to the complete
# command line. This includes arg $0 as /usr/local/bin/wsbasic (in
# my case) and arg $1 as the actual program being run (p in this case).
# The first real arg - i.e., the first parameter passed to the program - is $2.

cmd_line = $2
if cmd_line==""
begin
target_addr = default_addr
end
else
begin
target_addr = $2
end # end of cmd_line argument check

# -------------------------------------------------------------------
# start main program - endless loop
# -------------------------------------------------------------------

while dummy_var < 1
begin
print long_line
run_count = run_count + 1
print "Iteration: ", run_count
a=run(getdate)
printx(a)
print long_line
do_ping=run(ping_cmd + target_addr)
printx(do_ping)
print long_line
print usr_msg
do_delay=run("sleep " + delay)
print null_string
end # end of main endless while loop
Back to top
View user's profile Send private message 
Gekko


Joined: 22 Jul 2006
Posts: 445
Location: Sydney, New South Wales

PostPosted: Wed 16 May 2007, 06:06    Post subject:  

I recommend Ruby. www.ruby-lang.org Theres an online tutorial on the side.
Back to top
View user's profile Send private message 
drongo


Joined: 10 Dec 2005
Posts: 353
Location: UK

PostPosted: Wed 16 May 2007, 08:36    Post subject:  

vovchick,

If I could get hold of a version of BBC Basic (aka brandy) that worked in Puppy I would never ask for anything else on this forum ever again! (Until I think of something else.)

How could I get a copy and what would I have to do to get it working in Puppy?

25 years ago many people in the UK (including lots of school-children) cut their programming teeth on BBC Basic. I'm sure all of the more modern languages have many fine features, but a structured basic on linux sounds perfect.

drongo
Back to top
View user's profile Send private message 
drongo


Joined: 10 Dec 2005
Posts: 353
Location: UK

PostPosted: Wed 16 May 2007, 08:38    Post subject:  

deleted - double post - it wasn't me it was the Forum software made me do it!

drongo
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Wed 16 May 2007, 10:23    Post subject: Brandy here
Subject description: Brandy (BBC Basic V interpreter)
 

Dear Drongo - and VtC,

Here is a little archive containing the brandy interpreter, documentation and some examples. Please unpack the archive to /tmp and then copy the contents to appropriate directories. Brandy (located in the archive within /usr/local/bin) should be copied into your /usr/local/bin. The documentation and examples (some also by me - and rather crude but very structured) should go into /root/my-applications/bin/brandy (or wherever you wish). Let me know whether brandy runs on your system. I compiled it under Puppy 2.10 and all dependecies were satisfied in my setup. When running as a shell, brandy needs the -quit parameter on the unix shebang line. Look at my program d1 in the examples and you'll understand.

With kind regards,
Vovchik
brandy.tar.gz
Description  Brandy (BBC Basic V) interpreter for Puppy
gz

 Download 
Filename  brandy.tar.gz 
Filesize  237.94 KB 
Downloaded  694 Time(s) 
Back to top
View user's profile Send private message 
Lobster
Official Crustacean


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

PostPosted: Wed 16 May 2007, 13:34    Post subject:  

Smile seems to be working OK

BBC Basic is a nice procedural language, I last used it on a BBC Master, when I was learnng Pascal and C (I was rubbish at both)

Many thanks for making it available Smile

I only ever wrote one useful program in C - it was actually faster in BBC Basic . . .

_________________
Puppy WIKI
Back to top
View user's profile Send private message Visit poster's website 
drongo


Joined: 10 Dec 2005
Posts: 353
Location: UK

PostPosted: Wed 16 May 2007, 14:11    Post subject:  

Thanks vovchick,

This seems to work fine. I can get it to work interactively from the CLI. How do I make one of your examples run? I get an "event not found" error.

It runs a bit faster than a 1981 vintage BBC Micro as well!

Thanks again

drongo
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Wed 16 May 2007, 15:08    Post subject: Examples
Subject description: I konw some don't work
 

Dear drongo,

I never got around to finishing the brandygtk and xec1 examples, since I was only playing with brandy and had about one hour of experience with the language at the time of writing them. At some point I will actually finish them - particularly ones that launch gtk menu-builders - and will then post them. As to your question, to run my examples, simply type:

./progname

when in a terminal.

I agree with Lobster that brandy is a nice language, and it satisfies my requirement for structure and strong variable typing - fewer mistakes that way and the coding is much more transparent than would be otherwise. As you might be able to tell from my little examples, I come from the ancient "Pascal school".

By the way, has anybody seen a reasonable Pascal interpreter? As far as compilers go, there is FreePascal, GNU Pascal, Kylix and something beginning with the letter "N", but I am looking for a small interpreter something like brandy (although, perhaps, brandy will suffice, since I can rewrite most of the statements as procedures with pascal-like names and throw them all into an external lib).

With kind regards,
vovchik
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5039
Location: Arizona, U.S.A.

PostPosted: Wed 16 May 2007, 15:29    Post subject:  

veronicathecow must be rather confused by now, all the choices & no clarity.

For the simple GUIs that I made for LanPuppy I used Bash & GTKdialog.
It's crude but simple... Just what you've asked for.

The most complex is a TabPanel of 5 tabs for: AddUsers, AddHosts, Options, etc.
I've also made a file mounter, partition boot mounter, & Samba share mounter.

If your interested, ask & I'll PM you several GUIs & some text help.
Back to top
View user's profile Send private message 
veronicathecow


Joined: 21 Oct 2006
Posts: 533

PostPosted: Thu 17 May 2007, 14:47    Post subject:  

Hi Everyone, my apologies for not being around for a while but a combination of computer problems and lack of cash means that I am having to spend my time doing my book business and sorting out my VERY late Tax. Many thanks for your information and I hope to be back helping in what way I can in a few weeks and I'm sorry for letting you down.
All the best
Tony
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [14 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Cutting edge
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.0854s ][ Queries: 12 (0.0061s) ][ GZIP on ]