Board Logo
« getting started, Pigeon Breeders Records program »

Welcome Guest. Please Login or Register.
Jan 21st, 2018, 12:56am


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Please use the forums Search feature before asking.
Please post code using the code box described in Format Your Messages.
This will keep indentation, separate it better form the message and prevent gibberish.
If the code is too long for one post or additional files are needed, upload a ZIP archive to the Just BASIC Files Archive Site.

« Previous Topic | Next Topic »
Pages: 1 2 3 4 5 6  ...  11 Notify Send Topic Print
 veryhotthread  Author  Topic: getting started, Pigeon Breeders Records program  (Read 10850 times)
stumpy
Full Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 148
xx Re: getting started with Prog for Pigeon Breeding
« Reply #45 on: Mar 18th, 2016, 1:51pm »

Richard thanks very much. To explain: I had hoped for something which would directly provide the 'n' from the arrays of items which had been put into the cock and hen Listboxes. I see now that it was only originally that they were c(n) or h$(n), so that the 'hope' was unreallistic smiley After all those bits of text had thus become part of a list, which itself had the only definition. They would have lost their string number designations from the arrays and would have needed fresh indexing, as Rod made clear above.

Unfortunately those commands would not quite fit the bill. I looked them up in the index where, for Textbox: "print #handle, !selection? selected$ ; -This command returns the highlighted text from the window. The result will be contained in the variable selected$." (That was probably in use in [select cock] and [select hen], and could not do what I wanted).
and for Listbox: "print #handle.ext, selectionindex? index - This will place the index of the currently selected string into index. If there is no selected item, then index will be set to 0." (as Rod has illustrated in the example 'select pairs')

I may next look at other possibilities like that of printing lists consisting of the raw C$() and h$() arrays in the main window, so each item could be addressed directly as designated, but have not discovered if this can instead be done in a graphics window to smarten things up a bit, with frames drawn around the lists etc. for the sake of appearance. Yes I need to try things out for it to sink in, so it has all helped, and have looked at and used bits from the exercises and examples but found it a bit boring to work all through the tutorials. I will try doing week four and five though.



« Last Edit: Mar 18th, 2016, 1:51pm by stumpy » User IP Logged

Rod
Administrator
ImageImageImageImageImage


member is offline

Avatar

Graphics = Goosebumps!


PM

Gender: Male
Posts: 3151
xx Re: getting started with Prog for Pigeon Breeding
« Reply #46 on: Mar 18th, 2016, 2:05pm »

Please focus on the list box code in the help file. Richard is perfectly correct in what he advises. Get the selection into a string.

Code:
print #handle.ext, "selection? selected$" 


That string will allow you to select the bird in the list

Code:
print #handle.ext, "select "; selected$ 


You really should set aside your project and play with the help file examples of the controls you wish to use so that you better understand how they can support your project.
User IP Logged

stumpy
Full Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 148
xx Re: getting started with Prog for Pigeon Breeding
« Reply #47 on: Mar 18th, 2016, 3:20pm »

Yes. Cheers for now while I do that
User IP Logged

stumpy
Full Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 148
xx Re: getting started with Prog for Pigeon Breeding
« Reply #48 on: Mar 27th, 2016, 05:08am »

Hi again. With apologies for needing to stick to the hi res screen for my own use, and after playing with examples and reading the Jerry Lee Ford JB book I have made progress and can add new birds to the list, or edit existing entries. Next is to work out how to load or save the essential string records, which I think is encompassed by week 3 of JB's built-in tutorials.

Done
Upon adding a new cock or hen, the character '#'; the str$(cindex/hindex); and appropriate number of spaces are designated as the first 5 characters of the newly listed c$(list number)/h$(list number).

With each addition the cindex/hindex is incremented. Because this first part of c$(list number)/h$(list number) is not 'editable' by the user, it will be retained as the unique identifier for linking as 'Pa'/'ma' with the buttons 'get Ma', 'get Pa', and 'get Sib' ....
Todo),
...which will eventually require two corresponding characters for 'Pa', and two for 'Ma', to be appended to the cock or hen strings by pressing one of the cock's or hen's buttons: 'get: Pa/Ma/Sib'

Meanwhile
I cannot figure out how to do the following:-

1.) e.g. In the section remmed '----ADD C O C K to EMPTY slot---'
"...textbox #hndl.txt, 16, 15, 220, 25 ' --- GET new text
button #hndl, "OK", [get_new_text_of_cock], LR, 15, 16...."

I would like the cursor automatically to be set at the start of the text in the box for user text input.

2.) Once a text box, such as that in 1., appears, it is currently possible to crash the program by pressing another button before entering the required details.
I have an inkling that 'set focus' would be useful, but cannot discover how, or if there is something else which could be done.

(the .bas file seems to be too big to go here)
https://www.filesanywhere.com/fs/v.aspx?v=8b70688961617476ae6d


« Last Edit: Mar 27th, 2016, 05:15am by stumpy » User IP Logged

Rod
Administrator
ImageImageImageImageImage


member is offline

Avatar

Graphics = Goosebumps!


PM

Gender: Male
Posts: 3151
xx Re: getting started with Prog for Pigeon Breeding
« Reply #49 on: Mar 27th, 2016, 05:45am »

You need a modal popup window, this holds the focus and stops the program reacting to other input. Setfocus moves the cursor to the textbox and you need to allow the user to abort the entry. So still that to fix because it adds a record even if you abort.

Code:
[adcock]  ' for Selectable Main# text buttons
'find listnoc and set cindex'
'cindex is initially 0, in the next empty c$(n)'
For x = 1 to 99
    x$ = left$(cock$(x),5)
 IF x$ = "empty" THEN
    cindex = cindex +1
   IF cindex<10 THEN
    cock$(x) = str$(cindex) + "  - ?"
   ELSE
    cock$(x) = str$(cindex) + " - ?"
   END IF
    listnoc = x
    x = 99
  END IF
next x
print #main.cocks, "reload" ' RELOAD

'get the title of the new cock
    UpperLeftX = 700: UpperLeftY = 46
    WindowWidth = 300 : WindowHeight = 100
    textbox #box.txt, 16, 15, 220, 25
    button #box, "OK", [getcontentsC], UL, 235, 15 'the ok button for the adcock box
    open "Add New Cock #" ; str$(cindex) for dialog_modal as #box 'modal holds focus till done
    print #box, "trapclose [abort]" 'bail out but dont close program
    print #box.txt, "!setfocus" 'setthe cursor in the textbox
    wait
' ADD INDEX$ to COCK DETAILS JUST ENTERED
    [getcontentsC]
    print #box.txt, "!contents? details$"
    index$ = left$ (cock$(listnoc), 5)
    IF cindex>9 THEN
        index$ = left$ (cock$(listnoc), 4)
        index$ = index$ + " "
    END IF
    cock$(listnoc) = index$ + details$ 
    print #main.cocks, "reload" ' RELOAD
    [abort]
    close #box
wait


 
User IP Logged

stumpy
Full Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 148
xx Re: getting started with Prog for Pigeon Breeding
« Reply #50 on: Mar 27th, 2016, 5:07pm »

That works beautifully - thank you
User IP Logged

stumpy
Full Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 148
xx Re: getting started with Prog for Pigeon Breeding
« Reply #51 on: Apr 2nd, 2016, 03:28am »

Getting on and can also now do save/load data and do the various swaps.
except for a couple of minor probs with saving/loading:-

Code:
'When I do the following it works unless there are any commas in cock$(n), 
'when for some reason they are treated as end markers for that cock$(n).
'(but it is ok with semicolons)
--------------------------
'...........
[saverecord]
g$ = "Save the current record?" + chr$(13)
g$ = g$ + "(it will overwrite the old one)"
confirm g$; answer$
if answer$ = "no" then [quitsave]
   cock$(100) = str$(cindex)
   open "Recordcocks.dat" for output as #cocksave
    for n= 0 to 100
    print #cocksave, cock$(n)
    next n
    close #cocksave
    print #main.cocks, "reload"
'...same for hens...
notice "The Record has been saved."
[quitsave]
wait

[loadrecord]
confirm "Load the saved record?"; answer$
if answer$ = "no" then [quitload]
open "Recordcocks.dat" for input as #loadc
    for n= 0 to 100
    input #loadc, cock$(n)
    next n
    close #loadc

cindex = val(cock$(100))
'...same for hens...

print #main.cocks, "reload"
print #main.hens, "reload"

[quitload]
wait

'------------------------------------
'so to get round it (1) is the start of an addition I tried:
'-------------------------------
' ADD INDEX$ to COCK DETAILS JUST ENTERED
[getcontentsC]
index$ = left$(cock$(listnoc), 3) + "_"
print #box.txt, "!contents? details$"
cock$(listnoc) = index$ + details$ 
'cock$(listnoc) = details$ 
,(1)
check$ = (cock$(listnoc))
for n = 1 to len(check$)
,(2)
if mid$(check$, n, 1,) = "," then mid$(check$, n, 1) = ";"
next n
cock$(listnoc) = check$

'- but the statement after (2) shows as an error and can't be compiled

'--------------------------------
'testing again on its own:
'------------------
check$ = "258,2015"
x = 4
'(1)
print mid$(check$, x, 1)
print check$
input a$
'(2)
mid$(check$, x, 1) = ";"
print check$
input a$

'- the same for the statement after (2) above
'------------------------------------
 


I could just avoid using commas, when it's ok so far but from the above can you see if there is there something I am missing please?
« Last Edit: Apr 2nd, 2016, 03:31am by stumpy » User IP Logged

ezprogramming
Guest
xx Re: getting started with Prog for Pigeon Breeding
« Reply #52 on: Apr 2nd, 2016, 04:18am »

Post deleted
« Last Edit: Sep 15th, 2016, 2:04pm by ezprogramming » User IP Logged

stumpy
Full Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 148
xx Re: getting started with Prog for Pigeon Breeding
« Reply #53 on: Apr 2nd, 2016, 04:32am »

Aha. Many thanks
User IP Logged

stumpy
Full Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 148
xx Re: getting started with Prog for Pigeon Breeding
« Reply #54 on: Apr 10th, 2016, 4:41pm »

https://www.filesanywhere.com/fs/v.aspx?v=8b70688f60627077b06e

This is a zip with tkn, readme, and recordcocks.dat & recordhens.dat for loading the example records, etc. in case you would help to sort out a couple of bugs which have proved troublesome to fix.

1.) 'Show pedigrees' only works as far as parents of a subject but thus far, if sire and dam have been got by using 'pick parents', a press of the 'show pedigree' button works fine after 'clear selection' but otherwise the sire h./c. persists on screen, even when the next entry has no parents recorded.

2.) It may be rudimentary, but I can't see how to stop the crash which happens when another button is clicked while editing an entry from cock$(n) or hen$(n), which happens after double clicking on an entry in one of the listboxes before the textbox is closed.



« Last Edit: Apr 10th, 2016, 4:54pm by stumpy » User IP Logged

Rod
Administrator
ImageImageImageImageImage


member is offline

Avatar

Graphics = Goosebumps!


PM

Gender: Male
Posts: 3151
xx Re: getting started with Prog for Pigeon Breeding
« Reply #55 on: Apr 11th, 2016, 04:50am »

We can only guess since there is no .bas file. If the print is not showing is it being printed off screen, ie below the last printed text?

If buttons and clicks are taking you where you don't want to be you must disable them whilst you are doing a particular task. That was what the modal window did, it blocked everything else bar the controls on the open pop up window.

You can enable and disable buttons and turn off mouse and keyboard events. So you need a strategy to manage the controls you place on screen.
User IP Logged

stumpy
Full Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 148
xx Re: getting started with Prog for Pigeon Breeding
« Reply #56 on: Apr 11th, 2016, 05:39am »

here it is Rod, https://www.filesanywhere.com/fs/v.aspx?v=8b70688f616573a7a7a9

The Recordcocks.dat and Recordhens.dat in the previous zip were to give working info by using the Load button.

I think bug 1.) is now fixed. It was because the sire and dam textboxes were not being updated properly, which only showed up in some circumstances...

Thanks for your comments about bug 2.) Points taken. I started out with only a vague handle on handles etc. and obviously still haven't got it
« Last Edit: Apr 11th, 2016, 07:39am by stumpy » User IP Logged

stumpy
Full Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 148
xx Re: getting started with Prog for Pigeon Breeding
« Reply #57 on: Apr 11th, 2016, 12:54pm »

Yes those dialog_modal and trapclose [abort] cured bug 2.) as well, and understood that method a bit better.

I discovered DefaultDir$, added a box to use that, expanded the width of buttons, and now have to set up the pedigrees to go back to more predecessors.

https://www.filesanywhere.com/fs/v.aspx?v=8b7069865b606dbdab9d
User IP Logged

stumpy
Full Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 148
xx Re: getting started with Prog for Pigeon Breeding
« Reply #58 on: Apr 12th, 2016, 05:22am »

(edited) Plenty of rough edges but mainly just 'get sib' and full pedigrees to do
https://www.filesanywhere.com/fs/v.aspx?v=8b7069865f646eb3a16b

« Last Edit: Apr 12th, 2016, 12:03pm by stumpy » User IP Logged

Facundo
Board Moderator


member is offline

Avatar




PM

Gender: Male
Posts: 1303
xx Re: getting started with Prog for Pigeon Breeding
« Reply #59 on: Apr 12th, 2016, 12:33pm »

Hi stumpy. A couple of things:

At global variables declarations hen$ has an extra "$"

At the "Add new Cock" window you could use a Default button, then you can also press the enter key to use it.
Code:
button #box.default, "OK", [getcontentsC], UL, 380, 17 'the adcock box
 


Better do not modify the DefaultDir$ contents and use a separate variable to hold the path. Currently the code didn't run at first try for me because you have a folder I don't have, better use a sub folder inside DefaultDir$ if you want to make this work for other people. Or do not hard-code paths.
Something like DefaultDir$;"\data" should work.
You can also check for the user's screen resolution with DisplayWidth and DisplayHeight.
User IP Logged

cundo aka MSlayer
Pages: 1 2 3 4 5 6  ...  11 Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls