Board Logo
« getting started, Pigeon Breeders Records program »

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


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 ... 3 4 5 6 7  ...  11 Notify Send Topic Print
 veryhotthread  Author  Topic: getting started, Pigeon Breeders Records program  (Read 10849 times)
stumpy
Full Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 148
xx Re: getting started with Prog for Pigeon Breeding
« Reply #60 on: Apr 12th, 2016, 3:22pm »

on Apr 12th, 2016, 12:33pm, Facundo wrote:
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.

Thank you very much bothering to check it out!

That's interesting about your spotting 'hen$$', although maybe it did not apply to the hen$() string array anyway, which I have indeed used everywhere without problems so far, rather than plain old string variable Hen$ ? ..... I must look up the global thing again now I am getting to be such an advanced programmer ::) Really I was chuffed, delighted with JB, surprised to have nearly got there, and it is FFFFast in spite of my spaghetti code, which is a great let-off too. JB is all amazingly well developed and 'just what I always wanted'

Re. "Add new Cock", point taken and I would look into that, in the unlikely event that any other pigeon fancier wanted to try it. On the con side, I need to rely upon confirm messages and to keep things consistent, so I am not sure. Incidentally I have since found bugs associated with 'delete' an entry in conjunction with 'add' and cindex/hindex and the way they are saved with the rest. Still rough but perhaps improved in the current version.

Ditto for DefaultDir$ which you have mentioned as a very important point. Before I saw your post I tried to address that. If you have the time what do you think of that aspect now? in the following zip there are also a couple of example saves to play with if you don't mind. https://www.filesanywhere.com/fs/v.aspx?v=8b706986616475abaf98

PS - Yes thanks for that. In the zipped prog, I couldn't seem to save a 'dir.whatever' which would be used automatically, and which will appear in the box on screen

Obviously it is a great help for someone else to try it and the resolution thing has been raised before, although I am not clear from your advice how to get round that, while still using the format I have really designed for moi.


« Last Edit: Apr 13th, 2016, 02:05am 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 #61 on: Apr 13th, 2016, 03:38am »

Yes I got in a bit of a muddle with DefaultDir$ but here is the latest effort
https://www.filesanywhere.com/fs/v.aspx?v=8b706987596371789ea0

I would like to retain the facility to change directories so would you spell out how to use a separate variable to define the path?
« Last Edit: Apr 13th, 2016, 03:41am 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 #62 on: Apr 13th, 2016, 05:36am »

No one that takes your program will have the same directory set up as you do. They may not even install your code to a drive called c:\

The answer is to use relative paths. A relative path is one stored below the install directory. So if your user installs the software to d:\birds d:\birds will become the DefaultDir$ when the program is run.

You don't need to care about that because a relative path does not care. A relative path looks like this \pathname

So if you want info filed simply use a \relativepath when you programmatically save the file "\relativepath\myfile.dat"

It gets more complicated very quickly because Windows has started protecting the users environment. Data should be stored in the users %APPDATA% location.

You can create directories and store files there using the Windows Variable %APPDATA%

Code:
print DefaultDir$
result = mkdir( "%APPDATA%test")

open "%APPDATA%test\test.dat" for output as #1
#1 "hello"
close #1
open "%APPDATA%test\test.dat" for input as #1
i$=input$(#1,lof(#1))
 


So two choices keep it simple, but the simple method requires that your code is NOT stored in the Program Files Directory. The more complex method is recommended.
User IP Logged

tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3636
xx Re: getting started with Prog for Pigeon Breeding
« Reply #63 on: Apr 13th, 2016, 05:45am »

on XP, this code creates
Code:
%APPDATA%test 
directrory in DefaultDir$
XD

Does it work in some other Windows?
« Last Edit: Apr 13th, 2016, 05:46am by tsh73 » User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
Rod
Administrator
ImageImageImageImageImage


member is offline

Avatar

Graphics = Goosebumps!


PM

Gender: Male
Posts: 3151
xx Re: getting started with Prog for Pigeon Breeding
« Reply #64 on: Apr 13th, 2016, 05:52am »

Sorry my mistake, I assumed it was working. Need to get the actual contents of %APPDATA% that was a batch file kludge if I remember. Keep it simple then \relativepath.

EDIT actually no, get %APPDATA% once with this method then use it in place of %APPDATA% to make directories and save files in the user area where they are supposed to be.

So the first step would be to create a program directory like myAppName.

Code:
'all of these files will be created in DefaultDir$
open "test.bat" for output as #test
#test "echo %APPDATA% > test.txt"
close #test
run "test.bat /q" ,hide
open "test.txt" for input as #test
line input #test, appdata$
close #test
appdata$=trim$(appdata$)+"\"
'use this variable in place of %APPDATA%
print appdata$

 


Code:
print DefaultDir$
result = mkdir( appdata$;"test")

open appdata$;"test\test.dat" for output as #1
#1 "hello"
close #1
open appdata$;"test\test.dat" for input as #1
i$=input$(#1,lof(#1))


 
« Last Edit: Apr 13th, 2016, 06:26am by Rod » User IP Logged

stumpy
Full Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 148
xx Re: getting started with Prog for Pigeon Breeding
« Reply #65 on: Apr 24th, 2016, 2:31pm »

This is the result so far with readme, example record, pedigree and pairs list pdf outputs

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


Really it was the forum which kept me going grin
« Last Edit: Apr 26th, 2016, 11:47am by stumpy » User IP Logged

stumpy
Full Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 148
xx Problem with fileExists
« Reply #66 on: May 1st, 2016, 02:45am »

The latest version can display an image of the actual cock or hen, the subject of a family tree which was called up by pressing a 'show Ped. Cock/hen' button. https://www.filesanywhere.com/fs/v.aspx?v=8b70698e5c646da970a0

photos

User Image

Upon starting up, a default cock image, and one for a hen, are displayed

default pics

User Image

Code:
[getpictureC] 'from fullpedC: pictureC$ = left$(q$,3) + ".bmp" i.e. the index number of the selected cock

  LOADBMP "splash1", pictureC$
  PRINT #main.bird1, "down"
  PRINT #main.bird1, "drawbmp splash1"
  return

return
 


pictureC$ is e.g. "05C.bmp", the title of the specific image for the cock being displayed, which has the same prefix/unique index number "05C_......" in its cock$(number in the list)

the problem
This works fine as long as there are .bmp copies of the default cock and hen images present in the source folder, each entitled "01C.bmp", "02C.bmp" etc. and "01H.bmp" etc. but this is rather cumbersome.

- then, in JB help, I found 'fileExists':-

Quote:
Here is a short user-defined function which can be used to test if a file exists on disk. It is important to know if a file exists because attempting to access a nonexistent file can cause a program to crash.

function fileExists(path$, filename$)
'dimension the array info$( at the beginning of your program
files path$, filename$, info$()
fileExists = val(info$(0, 0)) 'non zero is true
end function

If the file is to be in the default directory, and named users.dat this example shows how to test for its existence with the fileExists function:

dim info$(10, 10)
if fileExists(DefaultDir$, "users.dat") then
notice "It's alive!"
else
notice "Igor! I need more power!"
end if

The dim info$(10, 10) statement is important because the files command in the function needs to have a double dimensioned array ready to accept its list of files and their information. See FILES.


This seemed just right for the default image to be used instead whenever a .bmp is not present for the actual bird, and have tried everything I can think of with it, but just cannot get it to work!

I found a smaller example in my Jerry Lee Ford book:
Quote:
dim fileInfo$(0, 0)
files "C:\temp\", "Application.log", fileInfo$()

if val(fileInfo$(0,0)) = 0 then
print "file not found!"
end if

However I cannot get that to work either!!

With the second method, I used "C:\users\public\public documents" in place of "C:\temp\", and pictureC$ in place of "Application.log"

I also tried e.g. "03C.bmp" and "03C", in case the string variable pictureC$ would not do in place of "Application.log", but still no go...

1.) Why is it 'dim info$(10, 10)' in JB help, and 'dim fileInfo$(0, 0)' in the book please?

2.) What have I missed and how should this be done?

PS
Found plenty of examples of using the function and am working through them....


« Last Edit: May 1st, 2016, 03:21am 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 #67 on: May 1st, 2016, 03:43am »

Its just about getting path right, print DefaultDir$ whilst you have your program in the editor. Put it as a line at the top of the code with a wait after it. Nomainwin should be active. You will be shown the directory that the program file and .bmp pictures reside in. Use that as the path for your files statement.

The dim files issue does not matter, the files statement redims the array as it searches so it does not matter if it is 0,0 or 10,10
User IP Logged

stumpy
Full Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 148
xx Re: getting started with Prog for Pigeon Breeding
« Reply #68 on: May 1st, 2016, 05:46am »

on May 1st, 2016, 03:43am, Rod wrote:
Its just about getting path right, print DefaultDir$ whilst you have your program in the editor. Put it as a line at the top of the code with a wait after it. Nomainwin should be active. You will be shown the directory that the program file and .bmp pictures reside in. Use that as the path for your files statement.

The dim files issue does not matter, the files statement redims the array as it searches so it does not matter if it is 0,0 or 10,10

Thanks very much again Rod, spot on.

It's working now grin

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

stumpy
Full Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 148
xx Re: getting started with Prog for Pigeon Breeding
« Reply #69 on: May 1st, 2016, 4:29pm »

Moved things around a bit for v1.07

User Image

More info can be added by editing individual entries of birds, apparently without a practical limit, and for viewing in the text boxes by putting the cursor there or by double clicking the entry, or to the breeding season's pdf output of pairs, with Foxit Reader for a running account of: hatching, ring numbers of offspring, and progress.

Dummy entries can be used to deliminate the breeding pairs, but that does require one-off customisation of the output to suit.

Thanks again for all the help.

If only there were not so many peregrine falcons about shocked
« Last Edit: May 1st, 2016, 4:50pm 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 #70 on: May 10th, 2016, 03:04am »

User Image
User IP Logged

stumpy
Full Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 148
xx [SPC] Pigeon Breeding Records 1920 x 1080
« Reply #71 on: May 14th, 2016, 03:42am »

Once more apologies for the high resolution.

After a few more versions, and in the unlikely event that any other pigeon fancier might like to use or modify it, I would like to be able to offer a download in Just Basic's shared programs section, rather than just 'filesanywhere'

Edited: removed outdated link
« Last Edit: Aug 10th, 2016, 04:31am 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 #72 on: Aug 10th, 2016, 03:50am »

edited:
Link deleted, with apologies for earlier defunct links.
Please see next post for the update
« Last Edit: Sep 7th, 2016, 05:40am 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 #73 on: Sep 7th, 2016, 05:43am »

The two efforts have been enhanced and combined with an intro screen and built-in help pages, as 'BreedersRecords', with both tkn and bas files in the zip.

Still working on it but this is the current version...(deleted)

Please see next post for the update, which includes better handling of directories
« Last Edit: Sep 9th, 2016, 1:05pm 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 #74 on: Sep 9th, 2016, 1:03pm »

11.9.2016 outdated link removed see next post
« Last Edit: Sep 11th, 2016, 03:47am by stumpy » User IP Logged

Pages: 1 ... 3 4 5 6 7  ...  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