Delphi Pages Forums

Delphi Pages Forums (http://www.delphipages.com/forum/index.php)
-   General (http://www.delphipages.com/forum/forumdisplay.php?f=2)
-   -   [SOLVED] Ideas for tracking/assigning a new number (http://www.delphipages.com/forum/showthread.php?t=217729)

FreakaZoid2 02-09-2018 08:26 PM

Ideas for tracking/assigning a new number
 
I am reading many xml files and currently displaying a treeview.
I have an object assigned to each node that has several bits of info including a number. this number is unique for each node. problem is that in the beginning these xml files were manually edited to keep these numbers unique. so the user would just pick some big number and use it to update these xml files with.

Now the question:
Is there a good way to load/track these numbers so that I can find any missing values.
say that 1 thru 3506 are used and then it starts back at 4001 thru 7569
I want to be able to assign 3507 to an added entry into these xml files. So any time in my program I allow users to add a new tree node and i want to auto-assign the next number available.
currently i have an array that has the number and a flag to indicate if it is used or not. problem is that some of the bogus numbers that user put in were like 888,888,888 so my array goes all the way to that number and i have to search it looking for any empty slot.

lex 02-12-2018 10:08 AM

This sounds a good project you have
their is so little info so I'm guessing
how about a TList and turn the integer into pointer for the list
reintroduce the conversion in a descendant object if you like may be
you mite use a bit or two for a flag.....

Norrit 02-13-2018 11:01 AM

This is a big problem if you mix logic in your UI what should be in your backend.
I'm guessing you've build some simple database structure using xml and want an id column. And instead of having some backend do the work (for example what SQL does with an autoinc) you want to do it manually in the UI.
I would say, back to the drawing board for this. Only way possible is if you loop through the nodes each time just to get your next free number. But again, this shouldn't be some UI job...

FreakaZoid2 02-13-2018 04:03 PM

yeah currently that is what i am doing.
 
this number id has to be unique but it didn't have to be sequential. the original xml files were created about 9 yrs ago and each time a new ITEM was needed the numeric id field was just manually decided. that's what happens when you let human decide, chaos. Since these files have been deployed to clients and due to some other outside issues they cannot be changed.
SO I am looping through all of the number ids and creating an array (number, string). the number is filled from 1 through the highest number I find in the files and the string is used to determine if in the program it is assigned (temporary, playing around adding new items) or if it is permanent from the files.
I don't normally deal with Delphi all that much so I thought I would ask if anyone had a better idea/way to determine if a number was already in use.

lex 02-14-2018 05:44 AM

Because you do not deal with Delphi, you are your own worst enemy
And this may be the real problem for you.
So may be this is what you must address first so you can communicate your real wishes into the project.

Norrit 02-14-2018 07:54 AM

Problem isn't the xml files, problem is that you do business logic in a UI!
Since you store the object data already in the treeview you don't need the array. It's not a matter of using both, it's a matter of choosing 1 and stick to that (or refactor).

FreakaZoid2 02-14-2018 02:31 PM

Quote:

Originally Posted by lex (Post 234037)
Because you do not deal with Delphi, you are your own worst enemy
And this may be the real problem for you.
So may be this is what you must address first so you can communicate your real wishes into the project.

Unfortunately my boss pays me to do COBOL and not Delphi.

FreakaZoid2 02-14-2018 02:44 PM

Quote:

Originally Posted by Norrit (Post 234038)
Problem isn't the xml files, problem is that you do business logic in a UI!
Since you store the object data already in the treeview you don't need the array. It's not a matter of using both, it's a matter of choosing 1 and stick to that (or refactor).

Personally I would have been happy to just use GUIID since the field only has one real purpose, and that is to give the other real client program a value to assign to each xml element. it is a home build menu processor that reads the xml files and build a menu for the users to interact with. Since these xml files have already been sent to clients and they can add in custom items that are based upon these xml files id value, I cannot change these xml files id tags. So in the past 8-9 yrs anytime we needed to make a change it has always been done manually and occasionally a duplicate entry got put into the works. That is why I decided to just write up this program to allow us (other devs, support) to add (correctly) any new items we may need as time goes by. For example, the new 1095 processing/printing was manually added a couple of years back and the xml file was sent out to our clients as a patch.
And now that I have gone down this long road according to the Dev (.Net, C#), who just came by to ask me a question about another program, said that the menu processing application reads those numbers as a string and a GUIID will actually work. So heck with the array idea.


All times are GMT. The time now is 07:56 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.