Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 02-09-2018, 08:26 PM
FreakaZoid2 FreakaZoid2 is offline
Senior Member
 
Join Date: Jul 2009
Posts: 314
Default 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.
  #2  
Old 02-12-2018, 10:08 AM
lex lex is offline
Junior Member
 
Join Date: Feb 2012
Posts: 23
Default

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.....

Last edited by lex; 02-12-2018 at 10:10 AM. Reason: addtion
  #3  
Old 02-13-2018, 11:01 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,268
Default

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...
  #4  
Old 02-13-2018, 04:03 PM
FreakaZoid2 FreakaZoid2 is offline
Senior Member
 
Join Date: Jul 2009
Posts: 314
Default 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.
  #5  
Old 02-14-2018, 05:44 AM
lex lex is offline
Junior Member
 
Join Date: Feb 2012
Posts: 23
Default

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.
  #6  
Old 02-14-2018, 07:54 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,268
Default

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).
  #7  
Old 02-14-2018, 02:31 PM
FreakaZoid2 FreakaZoid2 is offline
Senior Member
 
Join Date: Jul 2009
Posts: 314
Default

Quote:
Originally Posted by lex View Post
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.
  #8  
Old 02-14-2018, 02:44 PM
FreakaZoid2 FreakaZoid2 is offline
Senior Member
 
Join Date: Jul 2009
Posts: 314
Default

Quote:
Originally Posted by Norrit View Post
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.
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 08:16 PM.


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