wxBasicscript - script language for Xdialog

Stuff that has yet to be sorted into a category.
Message
Author
User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#21 Post by BarryK »

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/.
?

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

#22 Post by MU »

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 :)

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

Greets, Mark

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

#23 Post by Lobster »

I have been trying to join - contacted by email because there is a problem with spambots so not that straightforward to join . .
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

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

#24 Post by MU »

Lobster,

I can see you as newest registered user there :)

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 :(
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

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

#25 Post by MU »

Lobster wrote:Shame about Gambas :(
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

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

#26 Post by Lobster »

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: Select all

#!/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 Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

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

#27 Post by MU »

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

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: Select all

result = left ( "Markus" , 4 )
print result
###>Mark

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

So

Code: Select all

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: Select all

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

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: Select all

#!/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: Select all

#!/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: Select all

#!/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: Select all

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".


Image

This example shows how to use Xdialog:

Code: Select all

#!/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: Select all

         --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: Select all

#!/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, 18:59, edited 5 times in total.

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

#28 Post by Lobster »

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: Select all

Syntax error: Unable to open "/usr/lib/wxbasicscript/basefunctions.inc" or "/root/wxbs//usr/lib/wxbasicscript/basefunctions.inc"
What am I doing wrong?
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

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

#29 Post by MU »

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

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

#30 Post by Lobster »

Thanks Mark - your amended tutorial is working . . .

When Puppy 1.0.5 is released will the

Code: Select all

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

be required?

Sorry for these basic BASIC questions :oops:

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

Code: Select all

#!/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 ) 
Attachments
hello.jpg
(5.41 KiB) Downloaded 2224 times
Last edited by Lobster on Sun 18 Sep 2005, 20:12, edited 1 time in total.
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

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

#31 Post by MU »

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

Yes, this line is required, if you want to use functions of it.
You also could copy it to the folder of your program, and use
include "basefunctions.inc"

Then this file will be loaded.
But this method is unsecure, as some menuesystems have a problem with setting the path correctly.
If you want to do it, you must add this:

Code: Select all

#!/usr/bin/wxbasicscript

mypath = command(2)
if left ( mypath , 1 ) != "/" then 
  mypath = "./"
else
    x = rinstr( mypath , "/" )
    mypath = left( mypath , x-1 )
end if

include mypath & "basefunctions.inc"
I might try to add this to the interpreter,but it will take some days, as I am not a very experienced C-Coder.

Congratulations for your first program :)

Image

And remember: No question is stupid, everybody started as a "Beginner" :-)

These questions also help to get the Tutorial "Beginner-friendly", as I am always in danger to forget things, that are "normal" for me beeing used to work with wxBasic since several years now.

Mark

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#32 Post by BarryK »

I think it is a good idea, to add /usr/lib/wxbasicscript/basefunctions.inc by default.
Yes, but it isn't urgent, so maybe that can be done sometime later.

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#33 Post by BarryK »

Mark,
attached is the wxbasicscript Unleashed package that I intend to put into 1.0.5.
I have placed your intro into it, but changed the images to GIFs as much smaller.
(it's better to take the snapshot then convert to indexed colour, then save as gif).
Attachments
wxbasic-2.2k-puppy.tar.gz
(77.23 KiB) Downloaded 446 times

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

#34 Post by MU »

hey cool :)

I will continue the documentation this week.

I just uploaded DotpupDownloader 04, it has 1 new function in basefunctions.inc

So if you want to add that too, and alter the code to include /usr/lib/wxbasicscript/basefunctions.inc , you would have to replace that file.

MaybeI should leave basefunctions.inc untouched now, and add new functions to programspecific.inc

Thanks, Mark

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

#35 Post by Lobster »

The dotpupdownloader 0.4 is already an indispensible program. If it is not included in 1.0.5, it is the first thing I will download.

Worth thinking about . . .

1. Can contributed and G2's programs be combined
(one way of doing this is by having trusted wiki editors testing code and moving it into G2's dotpups?)
2. Can pupgets be called from your program? :)
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

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

#36 Post by MU »

Lobster wrote: 1. Can contributed and G2's programs be combined
(one way of doing this is by having trusted wiki editors testing code and moving it into G2's dotpups?)
2. Can pupgets be called from your program? :)
1: difficult. Not impossible, but not easy though.
Do you mean, that "Grafics" and "Grafics(contrib)" will be shown as one single category?

This might be something to look for in the next weeks.

2: Same as 1, this would mean to program a complete new part.

I'll think about it, but currently I have some other plans.
In Summer, I started building grafical tools for the Oroborus-WindowManager.

I want to finish it this autumn, so this has kind of priority now the Downloader does its job.

Maybe after that I might think of adding more options to existing programs :)

Mark

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

#37 Post by Lobster »

MU wrote:
1: difficult. Not impossible, but not easy though.
Do you mean, that "Graphics" and "Graphics(contrib)" will be shown as one single category?
Yes - no interest in separation for end users . . .

good luck with
http://www.oroborus.org/

Will it work in Puppy or is it Gnome library dependent?
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

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

#38 Post by MU »

You're right, I will try to add it.

But not this week I think.

---------------
There is a Alpha-version there:
http://www.freewebs.com/markulrich/wxb- ... /index.htm

http://www.freewebs.com/markulrich/expose2/index.htm

I will upload a dotpup with expose-clone this week.
The rest is completely reprogrammed (Icon-System) and not working yet (the Alphaversion worked more or less, but had some serious bugs).

And yes, it will run in Puppy :)

In fact, since xorg now works, Puppy has become my "main-system",and I just keep my Mandrake because it has several programs compiled in the last 3 years.

Btw not tired yet? ;)

Mark

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#39 Post by BarryK »

Maybe I should leave basefunctions.inc untouched now, and add new functions to programspecific.inc

Well, let's keep the package open until Friday.
Then I will have to close it an not make any more changes.
I have to bring out 1.0.5 next week. The tempation is to keep adding
more features. So Friday is the deadline. You too thoughtjourney, if you're reading this! And Jesse, if you want to upgrade MUT!
Then I can do a solid weekend of testing, a bit more testing early next week,
official release about mid-week -- that's the plan anyway.

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

#40 Post by Lobster »

Right working on the next bit . . .

Code: Select all

 //////////////////////////////////////////////////////////////////////
// Menu of available tutorials

dialog = "--title 'Tips' "&
"         --menu 'Double click for selected tip "&
" Choose a Section:' 0 0 10 "&
"        '1'  'Writing and running a first script' "&
"        '2'  'Calling sub programs or procedures' "&
"        '3'  'Other stuff'"

result , choice = xdialog ( dialog ) 

if result = 0 then
  dialog = "--title 'info' --msgbox '" & choice & " Writing and running a first script' 0 0"
if result = 1 then
  dialog = "--title 'info' --msgbox '" & choice & " Calling sub programs or procedures' 0 0"
if result = 2 then
  dialog = "--title 'info' --msgbox '" & choice & " Other stuff' 0 0"
else
  dialog = "--title 'info' --msgbox 'dismissed' 0 0"
end if

result , choice = xdialog ( dialog ) 
I am not sure what this does?

Code: Select all

Choose a Section:' 0 0 10 "&
and also I do not seem to be calling the menu selections in the right way?
Any help appreciated - your other projects seem like fun.
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

Post Reply