Active Forums => QB64 Discussion => Topic started by: badger on October 06, 2020, 04:44:35 pm
Title: hope this routine is as good as i think it is
Post by: badger on October 06, 2020, 04:44:35 pm
Hello
this section of code will increment the record number by 1. I will covert the number to string and add zeros to it up to 9 to make it an id number in the format of 000000001 and save it as a string.
This will make and keep the id numbers in ascending order in sequence .
to to make an index of id and any information for the file you need to search on it will be in order by id number i hope i got my idea across lol Badger
not a master programmers touch but for me its pretty good
variables z is integer64, l is long, s is string, i is integer ifilenum =1 zcustrecnum at start will be 1 lcustreclen is 256
Just for fun, I used the numeric value, rather than converting it to a string length. Now, the important part, how did you dim the data tye for your variable: zcustrecnum? If you are really expecting to run up to 9-digits, you need a data type that won't end up in your string as scientific notation. For instance...
Of the data types I listed, only the Long (&) and Double (#) will work for a 9-digit number. There is also _INTEGER64, which would be && and can handle 18-digit numbers.
Check out the data types in the QB64 wiki, if you're not sure what I'm talking about here. http://www.qb64.org/wiki/Data_types
Naturally, you don't have to use the type suffix if you use DIM or make the variable a TYPE.
Pete
Title: Re: hope this routine is as good as i think it is
Post by: badger on October 06, 2020, 05:38:48 pm
Hello
and you are correct i am going to use 4 different instances of this. I have scustinfored, senventoryrec, sposalerec, ssystemrec. Except for ssystemrec they all have .id that cant have duplicates so i did it this way. once done i will look at what you did closer to see if i can combine and shrink the code.
Badger
Title: Re: hope this routine is as good as i think it is
Post by: badger on October 06, 2020, 05:40:58 pm
Hello
Forgot to answer your question anything thats starts with a z is dim as _integer64
Badger
Title: Re: hope this routine is as good as i think it is
Post by: Pete on October 06, 2020, 05:45:11 pm
Then get busy... Your wife will be able to fill up to a quintillion orders with that data type!
Pete :D
Title: Re: hope this routine is as good as i think it is
Post by: badger on October 06, 2020, 05:47:37 pm
Hello
Lmao she always says i do a little overkill
she will never use it but i like to program it to just say its there.