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, 06:35
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Unsorted
wxBasicscript - script language for Xdialog
Moderators: deshlab, Flash, GuestToo, Ian, JohnMurga, Lobster
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 4 [51 Posts]   Goto page: Previous 1, 2, 3, 4 Next
Author Message
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Sat 17 Sep 2005, 20:13    Post subject:  

Barry, very fine, it is good to see wxBasic getting more interest Smile
It is a nice small language, but relatively unknown.

I attach the source.

Extract and run ./_compileconsole.sh

This will compile wxbasicscript.
Compiling the "big" version is more complicated, see here: http://wxbasic.sourceforge.net/phpBB2/viewtopic.php?t=911

Ok, I will try to write a small introduction to it next week.

Thanks, Mark
wxbasic-2.2k-source.tar.gz
Description 
gz

 Download 
Filename  wxbasic-2.2k-source.tar.gz 
Filesize  505.73 KB 
Downloaded  337 Time(s) 
Back to top
View user's profile Send private message Visit poster's website 
Lobster
Official Crustacean


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

PostPosted: Sun 18 Sep 2005, 01:40    Post subject:  

In the Puppy documentation, reference is made to X11 Basic and we have also considered Freebasic. However now that we have a Basic (WxBasic) that is being used AND that will be included in Puppy, hopefully a new layer of Puppy programmers will become invloved.

Good news Cool Anyone up to doing a WxBasic page on the wiki? Perhaps with a Puppy specific tutorial?

Have created a stub here . . .
http://www.goosee.com/puppy/wikka/WxBasic

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


Joined: 09 May 2005
Posts: 7047
Location: Perth, Western Australia

PostPosted: Sun 18 Sep 2005, 06:00    Post subject:  

Lobster,
You are our original Basic programming guru!
So you are the obvious choice to do some extra intro docs.
If Mark writes an overview of the features of wxbasic, someone (such as
yourself) can write a beginner's guide etc.
...we may attract a whole new bunch of people, writing gui apps for Puppy!

As this is looking like a "goer", I will probably remove Gambas pupget to avoid
confusion. It's a big bloated thing anyway.
Back to top
View user's profile Send private message Visit poster's website 
Lobster
Official Crustacean


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

PostPosted: Sun 18 Sep 2005, 07:06    Post subject:  

Shame about Gambas Sad
I played with it and liked it but Wxbasic is being used (big difference)
Looks like I have been volunteered. I have been following Marks efforts with a lot of interest..

The first thing I need to be clear about . . .
is wxbasicscript (the run time interpreter) gonna be in 1.0.5 - 1.0.6? or will the full wxbasic be available?

Who is up for some simple Basic programming and testing? - We might write a Puppy wxBasic tutorial in wxbasic . . .

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


Joined: 09 May 2005
Posts: 7047
Location: Perth, Western Australia

PostPosted: Sun 18 Sep 2005, 08:45    Post subject:  

I propose to only put wxbasicscript into the CD.
The full wxwidgets version could be a PupGet or DotPup though.

wxbasicscript will be in 1.0.5.
Back to top
View user's profile Send private message Visit poster's website 
BarryK
Puppy Master


Joined: 09 May 2005
Posts: 7047
Location: Perth, Western Australia

PostPosted: Sun 18 Sep 2005, 08:53    Post subject:  

Mark,
I would like your opinion about basefunctions.inc.

I'm preparing the Unleashed package, and I did this:

/usr/bin/wxbasicscript
/usr/lib/wxbasicscript/basefunctions.inc

It seemed like a good idea to have /usr/lib/wxbasicscript/ for include files
built-in to the CD?

But then I wondered, can wxBasic have something like in C:
include <basefunctions.inc>
which will look in the pre-defined location for header files.
In this case, the predefined location would be /usr/lib/wxbasicscript/.
?
Back to top
View user's profile Send private message Visit poster's website 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Sun 18 Sep 2005, 10:20    Post subject:  

Barry,

wxBasic needs the full path, like
include "/usr/lib/wxbasicscript/test.inc"

It also can be relative, like include "mylib/test.inc"

But it will not search in the PATH

Do you think, this would be an important feature?
I might try to implement that, but currently there is the question of priority:
new functionality, or documentation first (I tend to the documentation, as it is requested very often).

I think it is a good idea, to add /usr/lib/wxbasicscript/basefunctions.inc by default.
I will document those functions, to make it easy to use.


Nice to hear, Lobster is interested, too, if there are any question, plz ask.
I would suggest to ask programming questions in the wxbasic-board, so David Cuny has an insight what people need as possible addons.
Also, there are some more programmers, that might beinterested in contributing things, as I wrote somewhere, Jerry Muelver currently is writing an authoring sytem based on my wxB-Card (wxB-Card is included in the wxIconbar-dotpup http://www.murga.org/%7Epuppy/viewtopic.php?t=2310 Smile

The Board:
http://wxbasic.sourceforge.net/phpBB2/index.php

Greets, Mark
Back to top
View user's profile Send private message Visit poster's website 
Lobster
Official Crustacean


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

PostPosted: Sun 18 Sep 2005, 10:27    Post subject:  

MU wrote:


The Board:
http://wxbasic.sourceforge.net/phpBB2/index.php


I have been trying to join - contacted by email because there is a problem with spambots so not that straightforward to join . .

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


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Sun 18 Sep 2005, 10:38    Post subject:  

Lobster,

I can see you as newest registered user there Smile

David usually looks at least once a day to the board, sometimes also every second or third day, as he has a family with 4 kids.

The spam has become a real problem, there are days when the board is unreachable because the database has too many users writing to it Sad
So in that case we might discuss things here.

Sourceforge.net already could track down the problems, but they are not completely solved yet.

Greets, Mark
Back to top
View user's profile Send private message Visit poster's website 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Sun 18 Sep 2005, 11:38    Post subject:  

Lobster wrote:
Shame about Gambas Sad
I played with it and liked it but Wxbasic is being used (big difference)

is wxbasicscript (the run time interpreter) gonna be in 1.0.5 - 1.0.6? or will the full wxbasic be available? .


I did not use Gambas yet, but read about it.
It seems to be the "best" Basic around for Linux.

Though, it has the same problem as wxBasic: size.
So I would assume just to use wxbasicscript, and to leave gambas and wxBasic as additional Pupgets or Dotpups.

Yes, the concept is different.
Gambas main-goal is to provide an IDE like Visual Basic, but started highly platform-dependent (KDE), now slowly approaching other Libs (Gtk).

wxBasics main goal is platform-independance, Linux, Windows, MacOSX (this goal was reached).
But is has no IDE yet.
Meanwhile there is an Editor (wxEditor, Part of wxIconbar).
The Windows-Version of wxeditor has a Prototype of a grafical GUI-Builder, but this was incompatible with Linux/Gtk, so at moment it is completely rewritten.

Both Projects are in a relatively early state (though already usable depending on your goals), what explains the current differences.

Btw. wxbasicscript breaks the concept of platform-independance,by adding the "xwin_XXX()"-functions, that rely on a Xserver, and allow some things not possible on Windows (like moving or minimizing windows).
My goal is to provide a minimalistic (in size) language to build small system-tools.

Greets, Mark
Back to top
View user's profile Send private message Visit poster's website 
Lobster
Official Crustacean


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

PostPosted: Sun 18 Sep 2005, 11:51    Post subject:  

Let us slow down and recap . . .

the program wxbasicscript will be in
/usr/bin/wxbasicscript for Puppy 1.0.5

I already have it there (will have to document how that is done - or maybe not if it is included)
I can run programs from /usr/bin/

So now I want to run something simple but I have to set permissions or something?
Not sure why I cannot run the program from anywhere . . .

For example here is a script - will that run?
I have changed it into a shell (in ROX with permissions)

Code:
#!/usr/bin/wxbasicscript
include "basefunctions.inc"

 //////////////////////////////////////////////////////////////////////
//    Simple Message

xmessage ( "I am a Xmessage" )


 //////////////////////////////////////////////////////////////////////
//    User-defined Buttons

choice = xmessage( "-buttons 'yes','no','something else' 'your choice?'" )
if choice != nothing then
  xmessage( choice )
end if

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


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Sun 18 Sep 2005, 12:26    Post subject:  

Oh, I think the first lines of my tutorial will help you Smile

I suggest to run a script in a rxvt to see error-messages:
cd /root/wxbs
./tut01.wxbs

---------------------------
Introduction

wxbasicscript (short: wxbs) is a simpler version of the programming-language wxBasic ( http://wxbasic.sf.net ).

While wxBasic allows you to alter every detail of a window, wxbasicscript wants to offer some "pre-defined" dialogs, using external addons like "Xmessage" and "Xdialog".

In some cases, Xdialog will be too limited, so you also can use Gtkdialog, that allows you to combine elements like buttons and lists to your own window.

Different to shellscripts, you don't need to learn complex "regular expressions".

wxbs provides simple functions like
Code:
result = left ( "Markus" , 4 )
print result


###>Mark

As wxbs just has a small set of such functions, you can "include" external libraries.

So
Code:
include "/usr/lib/wxbasicscript/basefunctions.inc"
result = cutleft ( "http://www.linux.de" , "//" )
print result


will produce:
###>www.linux.de


A first grafical program

Create a new folder /root/wxbs
Open beaver, and enter this code:

Code:
#!/usr/bin/wxbasicscript
// tut01.wxbs
include "/usr/lib/wxbasicscript/basefunctions.inc"

xmessage ( "hello Puppy" )


Save this as /root/wxbs/tut01.wxbs

Now make it executable in rox:



Now you can run your program by clicking it in rox, and a messagebox appears.

Explanation

Lines beginning with // are comments and will be ignored during execution.

xmessage ()
is one of the functions included from basefunctions.inc , that make life easier.
It will give you these functions:

--
--
--


Return-values

Code:
#!/usr/bin/wxbasicscript
// tut02.wxbs
include "/usr/lib/wxbasicscript/basefunctions.inc"

result = xmessage ( "-buttons yes,no Please coose" )

xmessage ( result )


Xmessage, Xdialog and Gtkdialog return values to let you know, what Option the user selected.
You can optain them by "result = ..."


Conditions

If we got a result, we must decide what to do, depending on its value.

Code:
#!/usr/bin/wxbasicscript
// tut03.wxbs
include "/usr/lib/wxbasicscript/basefunctions.inc"

result = xmessage ( "-buttons yes,no Please coose" )

MSG = ""
if result = "yes" then MSG = "you chose yes"
if result = "no" then MSG = "you chose no"
if result = nothing then MSG = "you closed the window"

xmessage ( MSG )


Here the variable MSG is assigned different values, depending on the return-value "result"

You can "contacenate" strings (Text-Variables) with "&" to get shorter code:

Code:
#!/usr/bin/wxbasicscript
// tut04.wxbs
include "/usr/lib/wxbasicscript/basefunctions.inc"

result = xmessage ( "-buttons yes,no Please coose" )

MSG = "you "
if result = "yes" then MSG &= "chose yes"
if result = "no" then MSG &= "chose no"
if result = Nothing then MSG &= "closed the window"

xmessage ( MSG )


If you want to put more than one lines in an "if"-condition, do it like this:
Code:
if result = "yes" then
  MSG &= "chose yes"
  print MSG
end if



Execute external programs

You can run external programs using the "shell()"-command.
Your script will stop, until the program is finished (closed).
shell ( "beaver" )

To avoid that, add " &" to the command.
shell ( "beaver &" )

If you need the exit-code of a program, use the "xwin_exec()"-command:
result = xwin_exec ( "beaver" )

Differences of Xmessage and Xdialog

Xmessage returns "strings", for example the "yes" of a button.
Xdialog returns a number, representing a button.
In addition, it returns a string, that returns an optional choice, as in a "menue".




This example shows how to use Xdialog:
Code:
#!/usr/bin/wxbasicscript
// tut05.wxbs
include "/usr/lib/wxbasicscript/basefunctions.inc"

dialog = "--title 'MENU BOX' "&
"         --menu 'Simple program launcher "&
" \n\nWhat program do you want to run?' 0 0 10 "&
"        'beaver'  'Gtk-Texteditor' "&
"        'leafpad'  'another Gtk-Texteditor'"

result , choice = xdialog ( dialog )

if result = 0 then
  shell ( choice & " &" )
else
  xdialog ( "--title 'info' --msgbox 'dismissed' 0 0" )
end if


Here the Xdialog-code is encapsulated in ""&
This means
line1 and
line2 and
line3 ...

You also can put this code in an external file, a so called "template".
Then you don't need to "encapsulate" the Xdialog-code:

File: menubox1.tpl
Code:
         --title "MENU BOX"
         --menu "Simple program launcher
 \n\nWhat program do you want to run?" 0 0 10
        "beaver"  "Gtk-Texteditor"
        "leafpad"  "another Gtk-Texteditor"


Code:
#!/usr/bin/wxbasicscript
// tut06.wxbs
include "/usr/lib/wxbasicscript/basefunctions.inc"

dialog = readfile ( STARTDIR & "/menubox1.tpl" )
result , choice = xdialog ( dialog )

if result = 0 then
  shell ( choice & " &" )
else
  xdialog ( "--title 'info' --msgbox 'dismissed' 0 0" )
end if


The "\n" is a "Line-Feed", so you get an empty line in the dialogbox.
Note the line
dialog = readfile ( STARTDIR & "/menubox1.tpl" )

The Variable STARTDIR holds the folder of your script. Just like this you can be shure, your template will be found.

Using templates has advantages:
- Your mainscript gets shorter (easier to read)
- You can copy&paste lines from the Xdialog-examples at http://xdialog.dyns.net/ ,and just have to delete the"\" in the end of each line.

Last edited by MU on Sun 18 Sep 2005, 14:59; edited 5 times in total
Back to top
View user's profile Send private message Visit poster's website 
Lobster
Official Crustacean


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

PostPosted: Sun 18 Sep 2005, 12:58    Post subject:  

Ah a tutorial - yippee . . .

Did all the above and reloaded the wxbasicscript pup (the version 3 one) just in case

What I am getting is a file called wx.err in wxbs
with the following
Code:
Syntax error: Unable to open "/usr/lib/wxbasicscript/basefunctions.inc" or "/root/wxbs//usr/lib/wxbasicscript/basefunctions.inc"


What am I doing wrong?

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


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Sun 18 Sep 2005, 13:32    Post subject:  

Did you copy basefunctions.inc to
/usr/lib/wxbasicscript/
?

It is in the /usr/local/wxBasicscript03 -Folder.

You must do it, as the idea of using the folder /usr/lib/wxbasicscript/ is new (proposed by Barry).
I did not mention that in the tut, as it is assumed to be added to 1.0.5, where all paths will be setup correctly.

Sorry if my tut has errors, I just started writing it, and had not tested the examples.

I just replaced it with a corrected version.

Greets, Mark
Back to top
View user's profile Send private message Visit poster's website 
Lobster
Official Crustacean


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

PostPosted: Sun 18 Sep 2005, 14:54    Post subject:  

Thanks Mark - your amended tutorial is working . . .

When Puppy 1.0.5 is released will the
Code:
include "/usr/lib/wxbasicscript/basefunctions.inc"

be required?

Sorry for these basic BASIC questions Embarassed

I am now learning and bootstrapping a tutorial written in . . . wxbasic
the code so far . . .

Code:
#!/usr/bin/wxbasicscript

// Tutorial for Puppy 1.0.5 wxBasic - Lobster Sep 2005, uses wxbasicscript created by Mark Ulrich

include "/usr/lib/wxbasicscript/basefunctions.inc"

 result = xmessage ( "-buttons About_Basic,Lesson1,Lesson2,Lesson3,Reference Welcome to the Puppy wxBasic Tutorial Please choose" )
xmessage ( result )

MSG = ""
 if result = "About_Basic" then MSG = "you chose about"
 if result = "Lesson1" then MSG = "you chose Lesson 1"
 if result = "Lesson2" then MSG = "you chose Lesson 2"
 if result = "Lesson3" then MSG = "you chose Lesson 3"
 if result = "Reference" then MSG = "you chose Reference"
 if result = nothing then MSG = "you closed the window"
xmessage ( MSG )
hello.jpg
 Description   
 Filesize   5.41 KB
 Viewed   1488 Time(s)

hello.jpg


_________________
Puppy WIKI

Last edited by Lobster on Sun 18 Sep 2005, 16:12; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 2 of 4 [51 Posts]   Goto page: Previous 1, 2, 3, 4 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Unsorted
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.0992s ][ Queries: 13 (0.0062s) ][ GZIP on ]