Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sys(3) and sys(2015)
Message
From
10/11/2011 13:46:48
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01528576
Message ID:
01528580
Views:
87
This message has been marked as a message which has helped to the initial question of the thread.
>Hi everybody,
>
>I see that we're using sys(3) in one place which may return non-unique numbers. Does sys(2015) have the same problem?
>
>Say, I see this comment in Help
>
>Remarks
>Use SYS(2015) to create unique names for items such as procedures, functions, files, tables or cursors. You can add a prefix or change the length of the name using the SUBSTR( ) function. For example, the code "tmp"+SUBSTR(SYS(2015),4,3) returns tmpCIOS.
>
>The name that SYS(2015) returns is created from the system date and system time. Calling SYS(2015) more than once during the same millisecond interval returns a unique character string.
>
>So, can I 100% trust sys(2015)?
>
>Thanks in advance.

Tried the following code:
lbPass = .T.
lcLast = ""
FOR lnTry = 1 TO 100000
    lcNow = SUBSTR(SYS(2015),3,10)
    IF m.lcLast==m.lcNow THEN
        ? "Fail at "+TRANSFORM(m.lnTry)+" try."
        lbPass = .F.
    ENDIF
    lcLast = m.lcNow
ENDFOR
IF m.lbPass THEN
    ? "Passed"
END
it displayed "Passed"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform