Page 25 of 27

Posted: Thu 28 Feb 2013, 16:38
by vovchik
Dear Terry,

Glad to see youa re so busy :) There is a link to UXP binaries on the forum:

http://208.109.22.214/puppy/viewtopic.p ... cb706abdd5

With kind regards,
vovchik

Posted: Fri 01 Mar 2013, 01:35
by e_mattis
Hey guys,

@ L18L

yea, isn't it funny how such a small mistake can make you look like such a big dummy :oops: ! I went back and sure enough- no line after the end. I put one there and got a good run through. Thanks m8!
@ vovchik

I see what you mean. Tried the hug_imports just for 'grins & giggles' to see what would happen. what a mess! LOL Thanks for the fore-warning!


@ everyone

Now I have more questions.... :shock: :roll:

I need to incorporate a text-area on my window. Also, I will have a listbox to list the 'records' within a file (i.e. lines of data contained within). :D

I've looked through the docs I have, but do not see any indication of a text area command. I'm sure it is probably something i am overlooking - like multiline or something - so I ask, is there a means of producing multi-lined entry?

As far as the second issue, I have the listbox set up. Question is what would be the best method of inserting data obtained from the read-in of a file? Can I simply create an array and print it to the listbox?

:!: You guys are the best! I have gained a lot of insight from you and appreciate it more than I can express. :!:

Thanks!

E

.

Posted: Fri 01 Mar 2013, 02:47
by sunburnt
If you`re using OPEN to read the file then it`s already in an array, correct?
If your using Txt$ = EXEC$(CONCAT$("cat ", $PathFile)) as I suggested then:

Code: Select all

SPLIT Txt$ BY NL$ TO File$ Size fileSz
Now the file`s contents is in the array $File$[]

The MARK is Bacon`s "Label", it only shows text and can do multiple lines.

Posted: Fri 01 Mar 2013, 03:48
by e_mattis
Thanks sunburnt,

Yea, the info is already in an array, just not sure how to print it in the list box. assuming the 'MARK' attribute will do that? :?

Also, the multi lined area is not the listbox. It will actually be a 'notes' area - for entering your personal notations. As an ENTRY box, i would assume there would be some sort of word-wrap or multi-line setting to use in order to accomplish this. Haven't found the code yet though.

Thanks!

E

[update] 022813 23:32 est

Looks like i figured out the print to listbox (finally :) ):

TEXT(listbox,variable)

Still working on how to make a multi-line ENTRY box, so any help will be appreciated :D

.

Posted: Fri 01 Mar 2013, 08:41
by vovchik
Dear e_mattis,

This may or may not be what you are after, but HUG's EDIT box allows for multiple lines:

Code: Select all

EDIT(xsize, ysize)
Type: directive
Defines a multiline text widget with a width of <xsize> and a height of <ysize>.
Returns the ID of the created text widget.
With kind regards,
vovchik

PS. For reading in text files, which I do often, I use my own hand-rolled CAT command:

Code: Select all

' --------------------
FUNCTION CAT(STRING FILENAME$)
' --------------------
	LOCAL fileline$, txt$ TYPE STRING
	IF FILEEXISTS(FILENAME$) THEN
		OPEN FILENAME$ FOR READING AS catfile
		WHILE NOT(ENDFILE(catfile)) DO
			READLN fileline$ FROM catfile
			txt$ = CONCAT$(txt$, fileline$, NL$)
		WEND
		CLOSE FILE catfile
	END IF
	RETURN CHOP$(txt$)
END FUNCTION

x$ = CAT("/etc/profile")
PRINT x$
And, as sunburnt has said, if you use NL$ as your SPLIT delimiter, every separate line will be an array element. If you don't want to use arrays, you can always use my little GETWORD$ function:

Code: Select all

' --------------
FUNCTION GETWORD$(STRING mystring$, NUMBER word_number, STRING delimiter$)
' --------------
	LOCAL  i, mypos, n TYPE NUMBER
	LOCAL string_temp$ TYPE STRING
	i = 0
	mypos  = 0
	n = 1
	string_temp$ = ""
	mystring$ = CONCAT$(mystring$, delimiter$)
	REPEAT
		mypos  = INSTR(mystring$, delimiter$, n)
		INCR i
		IF i = word_number THEN
			string_temp$ = MID$(mystring$, n, (mypos - n))
		END IF
		n = mypos + 1
	UNTIL mypos IS FALSE
	RETURN string_temp$
END FUNCTION

x$ = CAT("/etc/profile")
' grab first line
y$ = GETWORD$(x$, 1, NL$)
PRINT y$

Peg Solitaire - BaCon version

Posted: Fri 01 Mar 2013, 10:22
by vovchik
Hi guys,

This is a little game I programmed in Bacon durng the summer but revised it today to take into account the stricter type casting in newer BaCon versions. The excercise was interesting, at least to me, for a number of reasons:

The graphics are all internal to the source - they are generated internally and not loaded from disk.

The program shows how to change mouse cursors and how to create a unique taskbar icon.

My implementation, after some long and hard thought, avoids any real movement of objects. They are simply hidden or shown, and I keep track of thier status.

The rsvg lib is put to good use, and gtk and gkd imports are used because native HUG did not have them.

The program demostrates how to REGISTER new widgets in HUG.

I compiled the binary in lucid (using Bacon beta 1.30 and hug 0.83) and then UPX'd it, so it is not large (23k).

The compile line was:

Code: Select all

bacon -o -s -o -Os -o -fdata-sections -o -ffunction-sections -o -Wl,--gc-sections psol-1
Have fun.... :)

With kind regards,
vovchik

PS. The game is winnable, but it ain't easy. Press the Help button for instructions on how to play. The archive contains a compiled binary and the source.

Posted: Fri 01 Mar 2013, 16:02
by e_mattis
@ Vovchik

That was exactly what I have been searching for! :D Never thought it would be listed as 'edit'. Thanks so much!

Also like the 'getword function'. may make it easier to accomplish what I will need. I will give it a shot!

Nice game, too! Haven't gotten to play it much yet, no wins :( but it may just replace my old "time-killer" solitaire card game at this rate!

You, my friend, are awsome! 8)

@everyone

I really appreciate all your inputs. It is important to me that I learn how to make a 'program' for Puppy as I intend for this OS to be my goto in the future. Thank you so much!

Thanks!

E

PS: So you guys will get an idea, here is a screen of what I'm working on.

Posted: Fri 01 Mar 2013, 17:48
by L18L
e_mattis wrote:PS: So you guys will get an idea, here is a screen of what I'm working on.
No country, no internationalization.
Globalisation disabled. :wink:

Posted: Fri 01 Mar 2013, 17:58
by sunburnt
The commands are:

Code: Select all

TEXT for entering or changing text in a widget.
GRAB$ for getting text from a widget.
This transfers text from widget to widget by widget`s index ( List or Combo ):

Code: Select all

TEXT(widget, GET(index))
Transfer text from widget to widget by widget`s text ( Button, Mark, List, Combo, etc.):

Code: Select all

TEXT(widget, GRAB$(widget))
It sounded like you were looking for a Label widget, sorry...

Looking at your GUI, it looks like it could be for both display and entry.
To enter or edit an item use a ENTRY, to display text only use a MARK.

Posted: Sat 02 Mar 2013, 02:20
by e_mattis
@L18L

Yea, sorry bud, haven't gotten to putting in the internationalization yet. Gotta get my coding right first for the basis, then I can get 'fancy' :D

@sunburnt

Thanks m8, that should help make my coding a little prettier when I feel comfortable that I understand it properly. :) And you are correct, it will be used to both enter and view information. Figure editing can be done by changing displayed info and then saving.

Thanks you guys - all the help has made it possible for me to actually write stuff! I know I will need your inputs as I trudge through on this journey. It is great to know I can count on some assistance along the way!

Thanks!

E

.

Posted: Sun 03 Mar 2013, 03:44
by e_mattis
Hey guys,

Well, i'm back again :D I have run into a situation I can't resolve with my limited knowledge.

I have an ENTRY box t input a web address. When the entry is reviewed, if desired, I have a button to launch the web browser to the address listed in the ENTRY box.

Here is how I have it set up at the present. it opens the browser but instead of the web page I get the 'FILE:///' index:

Code: Select all

webz$=GRAB$(webaddy)
IF LEFT$(webz$,7) = "http://" THEN doit
   webz$=CONCAT$("http://",webz$)
END IF

LABEL doit

SYSTEM "exec defaultbrowser webz$ &"


would it work better to just use the GRAB$ in the SYSTEM cmd? If the http:// is not included in webaddy, would this disrupt the flow?

Thanks!

E

.

Posted: Sun 03 Mar 2013, 08:30
by vovchik
Dear e_mattis,

Just a little mod to your code:

Code: Select all

SUB LAUNCH_BROWSER(STRING my_url$)
  SYSTEM CONCAT$("exec defaultbrowser ",  my_url$, " &")
END SUB

webz$=GRAB$(webaddy)
IF LEFT$(webz$, 7) = "http://" AND LEN(CHOP$(webz)) > 7 THEN
  LAUNCH_BROWSER(webz$)
ELIF LEN(CHOP$(webz$)) > 1 THEN
  webz$ = CONCAT$("http://", webz$)
  LAUNCH_BROWSER(webz$)
ELSE
  PRINT "Bad URL. Try again."
END IF
I am assuming you want to make sure that you include the "http://" before you pass the URL to the browser, so you want a properly formatted URL. The tests for validity above are, of course, not good or exhaustive. You could "ping" the site to ensure that it exists first - or use BaCon's networking function - to see that it is responding before launching your browser.

With kind regards,
vovchik

Posted: Sun 03 Mar 2013, 22:34
by e_mattis
Thanks Vovchik!

That was exactly what I needed :D You are AWSOME!

Now all that is left is to construct the 'remove record', 'edit record', and add internationalization. 8)

Almost there! :wink:

Thanks!

E

.

Posted: Mon 04 Mar 2013, 03:48
by e_mattis
:evil: ok, so i've been working on this like the past 5 hours....

I have created the SUB to remove the unwanted record. The flow I am following is this:

clear gui workarea
find the record selected in list
confirm removal of record
find record in database file
remove record from database file and list
tidy up

I am at the 'confirm removal of record' task. Here is the code I have thus far for this section:

Code: Select all

  killmsg$=CONCAT$("You are about to delete ",kilme$," !")
  kilme_dlg= MSGDIALOG(killmsg$,350,110,1,1)
  SHOW(kilme_dlg)
  CALLBACK(kilme_dlg,killme_btn)
  PRINT kmv
I have the 'killme_btn' FUNCTION outside the above SUB.

Code: Select all

  FUNCTION killme_btn( NUMBER value)
     HIDE (kilme_dlg)
     IF value = GTK_RESPONSE_OK THEN
         kmv = 0
     ELIF value = GTK_REPONSE_DELETE_EVENT THEN
         kmv=1
    END IF
    RETURN kmv
  END FUNCTION
My problem is two-fold; 1. KMV shows '0' as soon as the selection is made in the listbox and does not change after the MSGDIALOG FUCTION :( (value kmv not being returned?) and 2. - this is most likely why there is a problem #1 :oops: - I cannot figure out the process of using buttons with MSGDIALOG (ie how they react/respond or how to manipulate the result of the button being pushed).

I have also tried CALLBACKX(kilme_dlg,killme_btn,dmv) which gave compile errors because dmv is not assigned yet (?) - even when I set it to 0 (dmv=0) beforehand.

In the Winbloze basic i'm familiar with, the code would be :

Code: Select all

CONFIRM"Delete this file?";a$
LOWERCASE$(a$)
  IF a$ = "y" OR a$ = 'yes" THEN dmv=0:GOTO next
  dmv=1
[next]
this would send kmv to the PRINT line as '0' if OK_BTN was pushed or as '1' if the window were closed without the button being pushed.

I would prefer that the yes/no buttons be used in the dialog and want to set it up so that only the 'yes' button would go through to find the selected file in the database.

I have consulted these references for help:

http://www.basic-converter.org/documentation.html

http://www.basic-converter.org/hugdoc.html

http://basic-converter.proboards.com

I still cannot seem to put it all together :cry: Can someone, anyone, please explain how I might get this to work and how to use the MSGDIALOG buttons? All help is greatly appreciated!

Thanks!

E

.

Posted: Mon 04 Mar 2013, 04:18
by Mobeus
E
Could this be the problem? From http://www.basic-converter.org/hugdoc.html#MSGDIALOG
The dialog can be connected to a callback function which should have two arguments, the first for the dialog and the second for the button.
SUB HandleError(NUMBER dialog, int button)
Your function def is

Code: Select all

FUNCTION killme_btn( NUMBER value) 
Regards,
Mobeus

Posted: Mon 04 Mar 2013, 05:11
by e_mattis
Thanks Mobeus,

Yea, I finally figured that part out :oops: my sloppy coding :roll: :lol:

I think I have it working now, however, I need the program to wait, halt, or stop until the MSGDIALOG decision is made (ie. wait until either the 'yes' or the 'no' button are pushed; or the window is closed indicating not to delete the record)

At present, it continues execution while the MSGDIALOG is present, continuing on to the 'END SUB'. Here is what I have atm (kmv is now being returned :D ):

Code: Select all

  killmsg$=CONCAT$(Are yo usure you want to delete ",kilme$," ?")
  kilme_dlg=MSGDIALOG(killmsg$,300,110,1,4)
  SHOW(kilme_dlg)
  CALLBACK(kilme_dlg,killme_btn)
  IF kmv = 1 THEN
      GOTO findrec
  END IF
  GOTO nokill
LABEL findrec
  PRINT "at finding record"
LABEL nokill
PRINT "ending"
END SUB
'ending' is being printed while the MSGDIALOG is being shown. I click the 'yes' button,GUI hides, then nothing happens. I re-click the button on the gui to go into the delete SUB and then the 'at finding record' prints followed by the 'ending' message while the new MSGDIALOG is being shown. :?

I'm familiar with the 'WAIT' command, but how and where do you set it up to pause the program until the MSGDIALOG buttons are pressed? :? :?:

I am thinking of trying this:

Code: Select all

  dmv = 3
  REPEAT
      SHOW(kilme_dlg)
      CALLBACK(kilme_dlg,killme_btn)
       dmv=WAIT(killme_btn, 30)
  UNTIL dmv < 3
OR

Code: Select all

  dmv = 3
  WHILE dmv >= 3
      SHOW(kilme_dlg)
      CALLBACK(kilme_dlg,killme_btn)
  WEND
It is late here, so I will try them and post what happens in the next few minutes or so. Then Ima going to bed!

Thanks!

E

.

[UPDATE]

Both failed :cry:

Using the WHILE/WEND method caused the MSGDIALOG window to pop up with nothing inside it and locked the system up. Strike one :(

Using the REPEAT/UNTIL with 'dmv=WAIT(kilme_dlg,30)' would not compile due to a segmentation fault. Strike Two :evil:

Using REPEAT/UNTIL with 'dmv=WAIT(killme_btn,30)' would not compile due to an integer from pointer error. Strike three- I'm out! :twisted:

Well, off to bed...I'll see what happens with it tomorrow. Meanwhile, any solutions , feel free to post them for me :D

Thanks all!


E

.

pausing to get MSGDIALOG input (solved?)

Posted: Tue 05 Mar 2013, 16:11
by e_mattis
Hey all,

Well, after a couple of days working at it, I finally got the result I was looking for. :D Here is how I got the program to 'pause' until the MSGDIALOG button was pressed:

Code: Select all

  killmsg$=CONCAT$("Are yo sure you want to delete record ",kilme$," ?")
  kill_dlg=MSGDIALOG(killmsg$,300,100,1,4)
  SHOW(kill_dlg)
  CALLBACK(kill_dlg,killit)
END SUB


SUB killit (NUMBER kill_dlg, int button)
  HIDE(kill_dlg)
  IF button = GTK_RESPONSE_YES THEN
      CALL kilrec
  END IF
END SUB


SUB kilrec
  PRINT "killing record"
END SUB
I want to thank all those who helped me understand how this works. All the responses and inputs were very helpful!

Thanks!

E

.

manufacturer db completed

Posted: Wed 06 Mar 2013, 16:49
by e_mattis
Hey guys,

Finally completed my first BaCon prog! :D Wo0h0o!

@L18L

Thought you might want to give it a look over with the international finished on it (I hope :roll: ). So here's the whole thing, the prog, the code, and the '.pot' file. Hope you like it! Fair warning, the code is going to be repdative and at times jumpy - but like I said, my first in Bacon :)

Thanks!

E

.

manufacturer db completed

Posted: Wed 06 Mar 2013, 16:49
by e_mattis
Hey guys,

Finally completed my first BaCon prog! :D Wo0h0o!

@L18L

Thought you might want to give it a look over with the international finished on it (I hope :roll: ). So here's the whole thing, the prog, the code, and the '.pot' file. Hope you like it! Fair warning, the code is going to be repeatative and at times jumpy - but like I said, my first in Bacon :)

Thanks!

E

.

Posted: Sun 17 Mar 2013, 16:01
by vovchik
Dear all,

I have been doing a bit of label and svg coding recently and most of the examples are at http://basic-converter.proboards.com/in ... 314&page=3.

I was impressed with SFR's recent DYCP script and did a BaCon port/mod. Here is the source and a Lucid 32-bit binary.

With kind regards,
vovchik