trying with tdatabase

Re: trying with tdatabase

Postby nageswaragunupudi » Thu Jan 24, 2019 7:44 pm

How it could be a function to open an archive and all its indexes (cdx) with tdatabase

When you open and DBF via "DBFCDX", the main index file (cdx) with all the index tags is automatically opened and you do not have to (and should not) write any separate code to open the indexes. This is the case whether you open the DBF using the USE command or you use TDatabase class.

If you want that when you open any DBF, the first index tag is to be used, you may set a global setting
SET AUTORDER TO 1 at the beginning of the main function.
This eliminates the need to use
:SetOrder( 1 )
:GoTop()
every time.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: trying with tdatabase

Postby TimStone » Thu Jan 24, 2019 7:51 pm

Rao,

In your original comments you suggested removing all additional libraries related to tDatabase including tData.

I was simply pointing out that was not necessary because tData works fine with tDatabase.

Perhaps I could do everything now with just tDatabase but that would involve rewriting code, and I wouldn't want to devote time to that process unless it was necessary.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2904
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: trying with tdatabase

Postby TimStone » Thu Jan 24, 2019 8:03 pm

Silvio,

When I first started re-coding into data objects and classes, it took a lot of work, and I had to rethink how I was coding. The more I finished, the easier it became. The result is a faster program, MUCH easier updating, and it is very easy to add new features. It also reduced my total code size very significantly.

It is very clear that you want to stick with how you have done it years ago. As a result, you may continue to hit walls where things don't work your way. However, it is not the fault of FWH, or modern programming methods.

The point is that most of us have used FWH with Harbour or xHarbour, using Borland, Pelles, or Microsoft C compilers and linkers, and created fully functional multi-user programs far more complex than what you seem to need. In my case, I have done it for well over 30 years.

We have tried to share with you how to do it, but that does require changes on your part. We are not tricking you. I have people who run my application on 20 workstations, all against one database, and their data entry is non-stop all day long. We've tried to help, but we can't use your way of programming. I followed James guidance and rewrote my entire code base ( rather large ) in OOPS. It took a year to master and complete the rewrite and extensive testing, but the results were fantastic and thrilled my clients.

I hope you find a solution that works your way, but I won't confuse conversations any further in the future. I'll simply not share any more thoughts with you.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2904
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: trying with tdatabase

Postby James Bott » Thu Jan 24, 2019 8:28 pm

Nages,

If you want that when you open any DBF, the first index tag is to be used, you may set a global setting
SET AUTORDER TO 1 at the beginning of the main function.
This eliminates the need to use
:SetOrder( 1 )
:GoTop()
every time


Thank you for pointing that out. I suspect that many don't know about SET AUTORDER TO.

The one drawback is that if someone forgets to put SET AUTORDER TO 1 at the start of their program, they may HAVE a really hard time figuring out why things aren't working the way they expected.

There is also another way to write the code only once, and that is to put that code into a super class and then inherit all the database classes from it. Then you only write the code once.

In this case I didn't do it that way because I had no idea about the structures of the databases that Silvio was using so this gives the option to set each one differently. Granted this could also be done by passing nOrder to the superclass, but it is still harder to grasp if a new user can't visualize exactly what is happening.

All the ways are workable solutions.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: trying with tdatabase

Postby James Bott » Thu Jan 24, 2019 8:36 pm

Silvio

this evening I did this test in 3 minutes and it works without any classes (tServizi->txdata->tdata->tdatabase)


OK. But that has nothing to do with creating a multi-user application. It is a good example of how you can design common code to handle multiple things. This is one of the basic principles of OOP.

As I mentioned in my last email, one of the errors you were experiencing was a coding syntax error which had nothing to do with database objects. The same code would have caused the same error if you were not using database objects. But because you are not used to using objects you tend to blame the object before even looking for syntax errors.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: trying with tdatabase

Postby Silvio.Falconi » Thu Jan 24, 2019 9:50 pm

tim

I have only said that my application works and runs only that it can not be used on the network.

I do not care what tool to use but I'm interested in a tool that works.

If I have to build a car and the desire for 5 doors I can not do it only with 4 doors or only with two mirrors because the third one is not used ..or not need it :)

said this

I tried and spend the nights to convert with the tdata but I do not go forward, I see no improvement, I have been trying for 2 months, I have done countless tests and James can say how many tests I have sent him.

Another thing .. if in the old program I have created certain procedures to do specific things I can not overwhelm the program now because James does not like it and according to him it is not functional.

For example,
returning to my application for the beach,

I have an archive to do, an archive with all the prices that I call "rates" is like an archive with the items to sell and with the price, specifically I have to create a record for each number of days from the first day of the month to the last one for all the months of the season (May, June, July, September) and for all the elements that are located on the beach (umbrellas, hawaysani, tents and cabins) for all price lists default 2,
because it is so,
because it was created in this way,
because from the customer order can easily calculate the cost of rental and special packages

but James does not like this reasoning and we are still for a week, he sent me an email with a calculation of how many records I should enter as if I did not know,
we talk about at least 1800 records but it is so there is no other way and as if they were items to be put on the bill but to James not we like them and we do not go on

and meanwhile the management of the services do not work (single and multiple) especially the rescues and the orders

and I am very disheartened because I do not know what "fish to take".

I will do the tests and then try them in a LAN network and they do not work,

I asked everyone for help to solve my problem

what should I do?

Help me !!!!
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: trying with tdatabase

Postby James Bott » Thu Jan 24, 2019 10:06 pm

Silvio,

I have been helping you, I sent you answers to almost every issue and they have all been coding syntax errors, not database object errors.

Many of the things I have written to you about I am not saying I don't like. I was first trying to just figure out how the program works, and second I sometimes offered alternatives that might be easier. In one instance you said "it is easy," but then I figured is was probably generating hundreds if not thousands of records. I was then wondering that if the records could be automatically generated using calculations, then maybe the data could be calculated WITHOUT making all the records. That would seem to be easier.

Most of your issues are just due to you not yet understanding the use of database objects. Thus you tend to immediately blame the objects rather than looking for a coding error. It is not that the objects don't work. But the alternative (not using objects) is going to be foreign to you also, and it is going to require a lot more coding.
Last edited by James Bott on Mon Jan 28, 2019 6:57 pm, edited 1 time in total.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: trying with tdatabase

Postby TimStone » Fri Jan 25, 2019 4:22 pm

Silvio,

I'm sorry but I actually do not understand your beach example. It sounds like a combination of an inventory control, and calendar, program. I don't understand all the needed records. However, if it works single user, then it should work multi user.

A comment was made earlier that you need to use SET EXCLUSIVE OFF at the very beginning of your program. You do not need Exclusive to do a single user system. The only times I use Exclusive are when I Zap, Pack, or Index files, and that is very rare. In those cases, I provide a warning to insure ALL other users are out of the program, and then open each file exclusive mode ( when called ), perform that operation, and close it. Otherwise, the files are ALWAYS opened in shared mode. This works if you are only calling it from one computer, or many.

I also only lock the RECORD, and do it only when Saving the changes. I open the record and the data is stored in buffers ( automatically by the object ). All editing is done, and then when the save button is pushed, the record is locked, the data saved, and the record unlocked, all as part of the ::save() method. This just takes milliseconds. If there were two computers accessing the save at the exact same time ( fraction of a second ), one locks, and the other retries automatically. I NEVER have anyone tell me they actually see a system display an error on locking. It's all handled by the class, and as I said, as many as 20 people could be working on this at the same time.

Again, with SET EXCLUSIVE OFF at the very beginning of the program ( preferably in the MAIN( ) procedure that starts your application ), everything by default is available in shared mode. You only have to declare the mode thereafter IF you need to go into EXCLUSIVE mode with a file, and that should be very rare.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2904
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: trying with tdatabase

Postby Otto » Fri Jan 25, 2019 4:54 pm

Silvio,
can you please post here a foto/copy of the printed price list from the beach "Listino prezzi".
Then it is easier to understand.
Best regards
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: trying with tdatabase

Postby James Bott » Fri Jan 25, 2019 5:01 pm

I would add to Tim's locking explanation, that there are times when I do a file lock. This way the file can be in shared mode, so users can at least look at the records.

When you have multiple records to update at the same time, a file-lock insures that all of them will get updated. If you lock each record instead you risk failure of one or more records.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: trying with tdatabase

Postby Silvio.Falconi » Sat Jan 26, 2019 9:08 am

James Bott wrote:Silvio,

I have been helping you, I sent you answers to almost every issue and they have all be coding syntax errors, not database object errors.

Many of the things I have written to you about I am not saying I don't like. I was first trying to just figure out how the program works, and second I sometimes offered alternatives that might be easier. In one instance you said "it is easy," but then I figured is was probably generating hundreds if not thousands of records. I was then wondering that if the records could be automatically generated using calculations, then maybe the data could be calculated WITHOUT making all the records. That would seem to be easier.

Most of your issues are just due to you not yet understanding the use of database objects. Thus you tend to immediately blame the objects rather than looking for a coding error. It is not that the objects don't work. But the alternative (not using objects) is going to be foreign to you also, and it is going to require a lot more coding.


James,
do you remember XBROWSES of Servizi ?
We stayed at least 6 days to understand how to display the images because the aliases that created the Txdata class did not allow to show the images
the services program is an easy procedure,There are basic services (chair, cot, deckchair),and multiple services.
in a xbrowse I wanted the individual ones in the other the multpli, but the service archive is unique

Now there is another problem when I insert a new record i not see the number of the code
you wrote me it is normal but then when I save it not save the code on archive servizi.dbf

because you erase the section where I increment the code

Code: Select all  Expand view


Function NuovoServizioID(nMode,oServiziSingoli,cfilter1)
     Local cNewId
    local nRecPtr := oServiziSingoli:RecNo()
    local nOrden  := oServiziSingoli:OrdNumber()

   IF nMode == 1  .or.  nMode == 3

     If !empty(cFilter1)
         oServiziSingoli:clearFilter()
         oServiziSingoli:gotop()
      Endif
      oServiziSingoli:SetOrder(1 )
      oServiziSingoli:GoBottom()

      IF oServiziSingoli:EOF()
         cNewId := strzero(oServiziSingoli:RecNo(),4)
      ELSE
         cNewId := strzero((VAL(oServiziSingoli:ID)+1),4)
      ENDIF

      If !empty(cFilter1)
         oServiziSingoli:setFilter( cFilter1)
         oServiziSingoli:gotop()
      Endif

      oServiziSingoli:SetOrder( nOrden )
      oServiziSingoli:GoTo(nRecPtr)

   endif // mode = 1 or 3

   return cNewId
 


why I canno t use it ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: trying with tdatabase

Postby Silvio.Falconi » Sat Jan 26, 2019 9:23 am

TimStone wrote:Silvio,

I'm sorry but I actually do not understand your beach example. It sounds like a combination of an inventory control, and calendar, program. I don't understand all the needed records. However, if it works single user, then it should work multi user.

A comment was made earlier that you need to use SET EXCLUSIVE OFF at the very beginning of your program. You do not need Exclusive to do a single user system. The only times I use Exclusive are when I Zap, Pack, or Index files, and that is very rare. In those cases, I provide a warning to insure ALL other users are out of the program, and then open each file exclusive mode ( when called ), perform that operation, and close it. Otherwise, the files are ALWAYS opened in shared mode. This works if you are only calling it from one computer, or many.

I also only lock the RECORD, and do it only when Saving the changes. I open the record and the data is stored in buffers ( automatically by the object ). All editing is done, and then when the save button is pushed, the record is locked, the data saved, and the record unlocked, all as part of the ::save() method. This just takes milliseconds. If there were two computers accessing the save at the exact same time ( fraction of a second ), one locks, and the other retries automatically. I NEVER have anyone tell me they actually see a system display an error on locking. It's all handled by the class, and as I said, as many as 20 people could be working on this at the same time.

Again, with SET EXCLUSIVE OFF at the very beginning of the program ( preferably in the MAIN( ) procedure that starts your application ), everything by default is available in shared mode. You only have to declare the mode thereafter IF you need to go into EXCLUSIVE mode with a file, and that should be very rare.

Tim



Tim,
>The only times I use Exclusive are when I Zap, Pack, or Index files, and that is very rare

On oldest application I use dbpack and Dbzap when :
I draw the beach
I create the order for Elements, Services, and other archives
I create the price list

Now I cannot use dbpack and dbzap and sincerely I not understood how make it , I must rewrite all my sources

: Save ()
I tried to make James understand that there are some fields that need special save


then I'm used to loading the example fields into variables:

cName: = CU-> First
CCognome: CU => Last

and then to treat them in the dialog

example
@ 10.10 get aGet [1] var cName

and then to save them

Replace cu-> First with cName

But James erased all
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: trying with tdatabase

Postby Silvio.Falconi » Sat Jan 26, 2019 9:33 am

James Bott wrote:I would add to Tim's locking explanation, that there are times when I do a file lock. This way the file can be in shared mode, so users can at least look at the records.

When you have multiple records to update at the same time, a file-lock insures that all of them will get updated. If you lock each record instead you risk failure of one or more records.



It is all right. I started from the beginning of the basic dbf

I have to create spiaggia.dbf, elementi.dbf, servizi.dbf, listini.dbf, tariffe.dbf

Spiaggia.dbf
I created the beach and there is a problem because I can not use Dbzap and Dbpack and I do not know how to do it because when I create the beach I work with an array, then I have to delete all the records on the beach.dbf to insert the new data from the array . Basic configuration is 25X18 => 450 records
I tried the Nages function but sometimes it works and sometimes it does not

Servizi
I have to create services that are single and multiple what is difficult to understand yet you tell me that there are problems in programming not for your calsse tdata but in reality it is not so I answered above: to autoincrement a code of 4 characters I have always done


  oServiziSingoli: SetOrder (1)
       oServiziSingoli: GoBottom ()

       IF oServiziSingoli: EOF ()
          cNewId: = strzero (oServiziSingoli: RecNo (), 4)
       ELSE
          cNewId: = strzero ((VAL (oServiziSingoli: ID) +1), 4)
       ENDIF

now I cannot use it , why ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: trying with tdatabase

Postby TimStone » Mon Jan 28, 2019 5:52 pm

You don't need all of that code. You use the example of one field, but consider if there are 10 fields.

Step 1: Open the data object with one line
oDbf := tdata():new(, "cust" )

Step 2: The values are loaded in buffers, so edit them directly
@ 10,10 GET oDbf:abc
.... Do all the other edits the same way

Step 3: Save ALL the fields with one line
oDbf:save()

For 10 fields, this eliminates at least 23 lines of code needed for your way. It handles ALL locking automatically and works PERFECTLY in Single, or Multi User.

Yes, you would re-write code, but you would have much BETTER code, and less of it. To re-write the code this way would not take days, but rather would be done in minutes at each spot.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2904
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: trying with tdatabase

Postby Silvio.Falconi » Mon Jan 28, 2019 6:03 pm

tim,
perhaps you not understood the problem

I have a FIELD 4 CR called ID sample "0001"

I wish add a new record

and the ID FIELD must be incremental sample "0002"
it is calculate with

IF oServiziSingoli: EOF ()
cNewId: = strzero (oServiziSingoli: RecNo (), 4)
ELSE
cNewId: = strzero ((VAL (oServiziSingoli: ID) +1), 4)
ENDIF

if james erase this step how calculate the new id ?

how you make it ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 86 guests