Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Way to create unique ID
Message
 
 
To
21/01/2003 03:38:37
Dorin Vasilescu
ALL Trans Romania
Arad, Romania
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00743532
Message ID:
00743741
Views:
10
Hi Dorin,

Thanks a lot to you and everyone for the ideas and code samples. For now I coded the simplest solution (just take the max number between source and BldMstr file and then increment the maximum). Since it's a single user application, this approach should work.

I would keep all suggestions for the future use.

Thanks again.

>Here is the code I use to generate some kind of numeric GUID.
>Double type column is nedeed as primary key
>
>
>FUNCTION MyGuid
>IF VARTYPE(nDriveSerialNumber) = 'U'
>	PUBLIC nDriveSerialNumber
>	IF DRIVETYPE(SYS(5)) <> 3
>		nDriveSerialNumber = DriveInfo('C:','SerialNumber')
>	ELSE
>		nDriveSerialNumber = DriveInfo(SYS(5),'SerialNumber')
>	ENDIF
>	
>ENDIF
>return Bin2Num( RIGHT(SYS(2015),9) )+ VAL(SYS(2007, SYS(0)))+ nDriveSerialNumber
>
>
>
>
>FUNCTION Bin2Num
>LPARAMETERS cString
>LOCAL lnRetNumber, lcChars, i , lncCharsLength, lcCurrentCh, lnPosition
>lcChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789"
>lncCharsLength=LEN(lcChars)
>lnRetNumber = 0
>FOR i=1 TO LEN(cString)
>	lcCurrentCh=SUBSTR(cString,LEN(cString)- i + 1 , 1 )
>	lnPosition = AT( lcCurrentCh , lcChars )-1
>	lnRetNumber = lnRetNumber + lnPosition * (lncCharsLength**( i - 1 ))
>NEXT
>RETURN lnRetNumber
>
>
>
>FUNCTION DriveInfo
>LPARAMETERS tcDrive, tcRequiredInfo
>*
>* parameters :	tcDrive		drive ( "C:","D:", etc. , any type)
>*		tcRequiredInfo	AvailableSpace, DriveLetter, DriveType, FileSystem, FreeSpace
>*				IsReady, Path, RootFolder, SerialNumber, ShareName, TotalSize
>*				VolumeName								
>*		
>LOCAL oFs as "Scripting.FilesystemObject" , oDrv , lReturnValue , cInfo
>
>oFs = CREATEOBJECT("Scripting.FilesystemObject")
>oDrv = oFs.GetDrive(tcDrive)
>cInfo = "oDrv."+tcRequiredInfo
>lReturnValue = EVALUATE(cInfo)
>RELEASE oDrv,oFs
>
>RETURN lReturnValue
>
>
>
>>Hi everybody,
>>
>>Here is my situation:
>>
>>I've created Electronic Data Entry piece of Data Entry application. We receive files from registries in some text formats. I created a conversion program for each registry, that creates "source" file. Then another program processes this Source file and creates a work file, called BldMstr. This file has ID field called RecNum.
>>
>>There are some records in the source file, which should not go to the BldMstr file (nominal sales, for example). However, these records should go to "DoNotProcess" file.
>>
>>I number records in Source file sequentually.
>>
>>So, here is a scenario:
>>
>>BldMstr
>>   RecNum - 1
>>   RecNum - 2
>>   RecNum - 5
>>DoNotProcess
>>   RecNum - 3
>>   RecNum - 4
>>
>>
>>Source File
>>   RecNum - 1
>>   ...
>>   RecNum - 5
>>*************************************************************
>>In the Electronic Data Entry I allow some manipulations with BldMstr file, which basically allow to add new records. My problem is, I don't know, how to ensure, that each time, I add a record to this BldMstr file, I add a new unique ID.
>>
>>The DE application is stand-alone (not multiuser), so I was not using additional table (NextID table) idea...
>>
>>============================================================
>>Can you advise something in my situation, please?
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform