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 18 Apr 2014, 20:40
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 3 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: Sun 18 Sep 2005, 15:04    Post subject:  

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



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

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
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, 19:08    Post subject:  

Quote:
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.
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, 20:32    Post subject:  

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).
wxbasic-2.2k-puppy.tar.gz
Description 
gz

 Download 
Filename  wxbasic-2.2k-puppy.tar.gz 
Filesize  77.23 KB 
Downloaded  282 Time(s) 
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, 20:42    Post subject:  

hey cool Smile

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
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, 22:17    Post subject:  

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? Smile

_________________
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, 22:51    Post subject:  

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? Smile


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 Smile

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, 23:31    Post subject:  

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 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, 23:47    Post subject:  

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-desktop01alpha01/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 Smile

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? Wink

Mark
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: Mon 19 Sep 2005, 03:31    Post subject:  

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.
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: Mon 19 Sep 2005, 04:06    Post subject:  

Right working on the next bit . . .

Code:
 //////////////////////////////////////////////////////////////////////
// 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:
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 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: Mon 19 Sep 2005, 08:13    Post subject:  

Lobster,

If you do not write an "if"-condition in 1 line, you must close it with "end if".

Ok:
Code:
if result = 1 then print 1


Wrong:
Code:
if result = 1 then
  print 1


Ok:
Code:
if result = 1 then
  print 1
end if


This one works:

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


 //////////////////////////////////////////////////////////////////////
// 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 'dismissed' 0 0"
else

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

  result , choice = xdialog ( dialog )

end if




Also, you mixed up result and choice.
result just will have one of 3 values:
1=ok
2=cancel
255= Window was destroyed.

Your "1" "2" "3" -values will be returned in the choice-variable.

You can write the example a little bit shorter, using a list.

A list is a list of strings, you can index with a number, like mylist[1] mylist[2] mylist [3].

Look at this example:

Code:
#!/usr/bin/wxbasicscript
// creating Menue with a list
include "/usr/lib/wxbasicscript/basefunctions.inc"


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


//--- Putting the menue-points to a list


MP = { "Writing and running a first script" , "Calling sub programs or procedures" , "Other stuff" }

dialog = "--title 'Tips' "&
"         --menu 'Double click for selected tip "&
" Choose a Section:' 0 0 10 "&
"        '1'  '" & MP[1] & "' "&
"        '2'  '" & MP[2] & "' "&
"        '3'  '" & MP[3] & "'"

result , choice = xdialog ( dialog )

if result != 0 then
  dialog = "--title 'info' --msgbox 'dismissed' 0 0"
else

 //--- to use the value of the string choice as an index-number, we must convert it to a number using "val()"
 result , choice = xdialog ( "--title 'info' --msgbox '" & MP[val(choice)] & "' 0 0" )

end if


Greets, Mark
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: Wed 21 Sep 2005, 06:13    Post subject:  

Beaver has color syntax highlighting compatible with UltraEdit.
So I got the highlighting file for Qbasic from www.ultraedit.com.

I have placed this into the file /root/.beaver/wordfile.txt
I only gave it one file extension, WXBS, but more can be added, separated
by spaces, for example
WXBS WX
and the extension has to be capitals.

I've attached the wordfile.txt because although wxBasic is based on Qbasic, it seems to be a somewhat tenuous relationship.
If anyone feels like it, they're welcome to fix it up to work better with
wxBasicScript.
wordfile.txt.gz
Description 
gz

 Download 
Filename  wordfile.txt.gz 
Filesize  12.47 KB 
Downloaded  314 Time(s) 
Back to top
View user's profile Send private message Visit poster's website 
JohnMurga
Site Admin


Joined: 04 May 2005
Posts: 586
Location: Far to the east

PostPosted: Wed 21 Sep 2005, 17:15    Post subject:  

Hey

Just a quick question ... How would you use a progress bar when using xdialog within wxBasic ?

I know how to do it in shell script, but I an not sure how it would work from here.

Cheers
JohnM
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: Wed 21 Sep 2005, 18:40    Post subject:  

I haven't looked at progressbars yet.

If you post the shellscriptexample, I might translate it to wxbs.

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: Thu 22 Sep 2005, 00:10    Post subject:  

Example: using a gauge (Progress-bar)

The gauge wants to get its values sent via Shellscript-echo-commands.

So I create those commands in wxbasicScript, and send them through a pipe(|) to the gauge.

You could add any commands, for example check the size of a large zip (50 MB) you create.

The example shows, that the gauge is really reacting to events.

First I define the commands.
Then I run xcalc in Background.
Now I launch the progressbar (gauge).

It is feeded from the shell-commands, that check with help of "ps", if xcalc still is running.
If not, the gauge is closed (exit).
If yes, the value in increased in 20%-steps, until 100% is reached.

If 100% is reached, xcalc is killed and the script ends.

So run it, and close xcalc, when the gauge reaches 40%, you will see the gauge stops.

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


GAUGE = "("&
"echo \"20\" ; sleep 5;"&
" if [ ! \"`ps |grep xcalc`\" ];then exit;fi;  echo \"40\" ; sleep 5;"&
" if [ ! \"`ps |grep xcalc`\" ];then exit;fi;  echo \"60\" ; sleep 5;"&
" if [ ! \"`ps |grep xcalc`\" ];then exit;fi;  echo \"80\" ; sleep 5;"&
" if [ ! \"`ps |grep xcalc`\" ];then exit;fi;  echo \"100\" ; sleep 5;"&
")"

shell ("xcalc&")
xwin_exec( GAUGE & "|Xdialog --title \"Gauge\" --gauge \"test\" 8 30" )
shell ("killall xcalc")
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 3 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.0871s ][ Queries: 12 (0.0061s) ][ GZIP on ]