Discussion:
Warning: SYS(2015)
(too old to reply)
Eric den Doop
2003-07-15 16:58:44 UTC
Permalink
Hello, All!

In many apps, I use the SYS(2015) to generate temporary file names and
cursor names. I use the trick that is described in VFP Help for SYS(3):
valid_filename = SUBSTR(SYS(2015), 3, 10)

Since yesterday the SUBSTR(SYS(2015), 3, 10) function returns file names
that begin with a number which is ok for files but really screws up your app
if you, like me, are using it for cursor names. I was able to fix this
problem quite easily by using the search and replace feature in VFP to add a
"_":

valid_filename = "_" + SUBSTR(SYS(2015), 3, 10)

Just wanted to share this information with you.

By the way: does anybody know how the SYS(2015) algorithm works?
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
Lee Mitchell
2003-07-15 17:46:16 UTC
Permalink
Hi Eric:

I saw an internal thread on this issue yesterday. It seems the Help file
mentions this behavior for SYS(3) but not for SYS(2015). We have entered a
doc bug regarding the SYS(2015) topic.

Sorry, I don't know how the algorithm for SYS92015) works.

I hope this helps.

This posting is provided "AS IS" with no warranties, and confers no rights.

Sincerely,
Microsoft FoxPro Technical Support
Lee Mitchell

*-- VFP8 HAS ARRIVED!! --*
Read about all the new features of VFP8 here:
http://www.universalthread.com/VisualFoxPro/News/VFP8Release.asp
Purchase VFP8 here:
http://shop.microsoft.com/Referral/Productinfo.asp?siteID=11518

Keep an eye on the product lifecycle for Visual FoxPro here:
http://support.microsoft.com/default.aspx?id=fh;[ln];lifeprodv
- VFP5 Mainstream Support retires June 30th, 2003
- VFP6 Mainstream Support retires Sept. 30th, 2003
Post by Eric den Doop
Hello, All!
In many apps, I use the SYS(2015) to generate temporary file names and
valid_filename = SUBSTR(SYS(2015), 3, 10)
Since yesterday the SUBSTR(SYS(2015), 3, 10) function returns file names
that begin with a number which is ok for files but really screws up your app
if you, like me, are using it for cursor names. I was able to fix this
problem quite easily by using the search and replace feature in VFP to add a
valid_filename = "_" + SUBSTR(SYS(2015), 3, 10)
Post by Eric den Doop
Just wanted to share this information with you.
By the way: does anybody know how the SYS(2015) algorithm works?
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
Eric den Doop
2003-07-15 18:06:48 UTC
Permalink
Hello, Lee!
You wrote on Tue, 15 Jul 2003 17:46:16 GMT:

LM> I saw an internal thread on this issue yesterday. It seems the Help
LM> file mentions this behavior for SYS(3) but not for SYS(2015). We have
LM> entered a doc bug regarding the SYS(2015) topic.

Thanks Lee for the info.
(still wondering how the algorithm works, so if anybody knows or has a
theory about it...)
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
John
2003-07-16 07:39:40 UTC
Permalink
Eric,

There is a download on the UT called Convert2015 which reverse engineers the
algorythm, I don't know how accurate it is though.

John
Post by Eric den Doop
Hello, Lee!
LM> I saw an internal thread on this issue yesterday. It seems the Help
LM> file mentions this behavior for SYS(3) but not for SYS(2015). We have
LM> entered a doc bug regarding the SYS(2015) topic.
Thanks Lee for the info.
(still wondering how the algorithm works, so if anybody knows or has a
theory about it...)
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
Eric den Doop
2003-07-16 08:40:25 UTC
Permalink
Hello, John!
You wrote on Wed, 16 Jul 2003 08:39:40 +0100:

J> There is a download on the UT called Convert2015 which reverse engineers
J> the algorythm, I don't know how accurate it is though.

Will take a look at it. Thanks.
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
Jeff Bowman
2003-07-18 07:03:52 UTC
Permalink
Hi Eric

SYS(2015) is loosely based on the system clock, and increments once every millisecond. Exceptions to that frequency occur when the
function is called more than once during a millisecond-in that case, it increments in a raw sequence in order to guarantee
uniqueness.

The algorithm itself is very simple, just like an odometer in a car-each column counts from 0 to 9 and then from A to Z, and then
starts over again with the column to its left incremented by one unit.

SYS(2015) starts at roughly _0011DCX00 at the beginning of every century.

HTH,
Jeff
--
mail2 jbowman at jeffbowman daught com
Post by Eric den Doop
Hello, Lee!
LM> I saw an internal thread on this issue yesterday. It seems the Help
LM> file mentions this behavior for SYS(3) but not for SYS(2015). We have
LM> entered a doc bug regarding the SYS(2015) topic.
Thanks Lee for the info.
(still wondering how the algorithm works, so if anybody knows or has a
theory about it...)
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
Eric den Doop
2003-07-18 08:56:39 UTC
Permalink
Hello, Jeff!
You wrote on Thu, 17 Jul 2003 23:03:52 -0800:

JB> SYS(2015) is loosely based on the system clock, and increments once
JB> every millisecond. Exceptions to that frequency occur when the function
JB> is called more than once during a millisecond-in that case, it
JB> increments in a raw sequence in order to guarantee uniqueness.

JB> The algorithm itself is very simple, just like an odometer in a
JB> car-each column counts from 0 to 9 and then from A to Z, and then
JB> starts over again with the column to its left incremented by one unit.

JB> SYS(2015) starts at roughly _0011DCX00 at the beginning of every
JB> century.

JB> HTH,
JB> Jeff

Makes sense. Thanks for your info.
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
Erich TODT
2003-07-15 17:52:19 UTC
Permalink
Hi Eric,
Post by Eric den Doop
Just wanted to share this information with you.
Many thanks.

This problem occurs because the first character of your file name is numeric
zero, and according to VFP product documentation, cursor names have to begin
with a letter ("A".."Z") or an underscore ("_"). The leading Zero makes VFP
create a different, valid alias name.
Post by Eric den Doop
I was able to fix this
problem quite easily by using the search and replace feature in VFP to add a
valid_filename = "_" + SUBSTR(SYS(2015), 3, 10)
MS Documentation recommends SUBSTR(..,3,10) to get 8 characters just for 8.3
file naming compatibility. If adding "_" works for you (supposing you are
running the app on a system that supports long file names, since your
valid_filename generates 9 characters), you can simply forget the SUBSTR().

hth
Erich


--

Erich TODT
e-mail: ***@tz-com.at
web: http://www.todt.at/
Dan Freeman
2003-07-15 18:46:29 UTC
Permalink
I think it's date/time-based. Someone on Compuserve said it'll be July 2004
before the old SUBSTR() trick is safe again.

Dan
Post by Eric den Doop
Hello, All!
In many apps, I use the SYS(2015) to generate temporary file names and
valid_filename = SUBSTR(SYS(2015), 3, 10)
Since yesterday the SUBSTR(SYS(2015), 3, 10) function returns file names
that begin with a number which is ok for files but really screws up your app
if you, like me, are using it for cursor names. I was able to fix this
problem quite easily by using the search and replace feature in VFP to add a
valid_filename = "_" + SUBSTR(SYS(2015), 3, 10)
Just wanted to share this information with you.
By the way: does anybody know how the SYS(2015) algorithm works?
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
Mike Pratt
2003-07-15 21:06:29 UTC
Permalink
Hi Eric,

Happened before, apparently.

See KB article Q199647. I went to MS and was unable to search for the
article. I found it initially in the Oct 2001 MSDN Library. It alludes
to sys(2015) being date derived.

Later,

Mike

On Tue, 15 Jul 2003 18:58:44 +0200, "Eric den Doop"
Post by Eric den Doop
Hello, All!
In many apps, I use the SYS(2015) to generate temporary file names and
valid_filename = SUBSTR(SYS(2015), 3, 10)
Since yesterday the SUBSTR(SYS(2015), 3, 10) function returns file names
that begin with a number which is ok for files but really screws up your app
if you, like me, are using it for cursor names. I was able to fix this
problem quite easily by using the search and replace feature in VFP to add a
valid_filename = "_" + SUBSTR(SYS(2015), 3, 10)
Just wanted to share this information with you.
By the way: does anybody know how the SYS(2015) algorithm works?
Later,

Mike
Michel Levy
2003-07-17 13:44:06 UTC
Permalink
here's just i had prepared to send :
when you need to create a temporary cursor, Foxhelp
specifies it's better to use SUBSTR(SYS(2015), 3, 10) than
sys(3).

So, i did it for 4 years, in 2 programs with VFP6 wich
are running (in exe file) on more than 15 customers.

No problem, but !!!
on 2003 July, 13th, it does'nt run. and on 2003/07/04 and
following, it does'nt run...

Why : now, SUBSTR(SYS(2015), 3, 10) = 030XCOKB

yesterday, it was something like 020...

And it's not a good name for a file, if begining with a
number
So, simple to add "A" before the expression, and re-
compile all the programs, and send it to all customers,
isn't it?

Did anybody see that problem?
-----Original Message-----
Hello, All!
In many apps, I use the SYS(2015) to generate temporary
file names and
cursor names. I use the trick that is described in VFP
valid_filename = SUBSTR(SYS(2015), 3, 10)
Since yesterday the SUBSTR(SYS(2015), 3, 10) function
returns file names
that begin with a number which is ok for files but really
screws up your app
if you, like me, are using it for cursor names. I was
able to fix this
problem quite easily by using the search and replace
feature in VFP to add a
valid_filename = "_" + SUBSTR(SYS(2015), 3, 10)
Just wanted to share this information with you.
By the way: does anybody know how the SYS(2015) algorithm
works?
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts -
Powered By VFP8
.
David Frankenbach
2003-07-17 16:20:13 UTC
Permalink
Michael,

Yesterday it was something like ZZZ... not 020.

It's perfectly fine for a filename to start with 0.

it's not good for a table name to start with 0 because that's invalid and
VFP is going to make it a legal character for the alias name, but your code
isn't going to realize unless you look to see how VFP changed it:

create table 0123 ( c1 c(10) )

works just great, although the alias is not 0123 it's A

A cursor has to have a valid alias name right from the start. You should
just simply use the whole return value from sys(2015) for your cursor names.
--
df - Microsoft MVP FoxPro http://www.geocities.com/df_foxpro
Post by Michel Levy
when you need to create a temporary cursor, Foxhelp
specifies it's better to use SUBSTR(SYS(2015), 3, 10) than
sys(3).
So, i did it for 4 years, in 2 programs with VFP6 wich
are running (in exe file) on more than 15 customers.
No problem, but !!!
on 2003 July, 13th, it does'nt run. and on 2003/07/04 and
following, it does'nt run...
Why : now, SUBSTR(SYS(2015), 3, 10) = 030XCOKB
yesterday, it was something like 020...
And it's not a good name for a file, if begining with a
number
So, simple to add "A" before the expression, and re-
compile all the programs, and send it to all customers,
isn't it?
Did anybody see that problem?
-----Original Message-----
Hello, All!
In many apps, I use the SYS(2015) to generate temporary
file names and
cursor names. I use the trick that is described in VFP
valid_filename = SUBSTR(SYS(2015), 3, 10)
Since yesterday the SUBSTR(SYS(2015), 3, 10) function
returns file names
that begin with a number which is ok for files but really
screws up your app
if you, like me, are using it for cursor names. I was
able to fix this
problem quite easily by using the search and replace
feature in VFP to add a
valid_filename = "_" + SUBSTR(SYS(2015), 3, 10)
Just wanted to share this information with you.
By the way: does anybody know how the SYS(2015) algorithm
works?
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts -
Powered By VFP8
.
David Frankenbach
2003-07-17 22:35:40 UTC
Permalink
Michel,

Yes, if you have an app out in production using substr( sys(2015), 3, 10 )
you will have to deploy a fixed version of your code. You could also tell
your users to just stop using the app for a few weeks *bg*

sys(2015) generates perfectly valid cursor names 100% of the time if you do
it like this:

lcCursor = sys(2015)
create cursor (lcCursor) ...
--
df - Microsoft MVP FoxPro http://www.geocities.com/df_foxpro
David,
perhaps it runs with create table (i've not verified it),
but it does'nt with create cursor, because alias name is
automatically created by Fox.
I've sent this message on the french forum (i'm french,
sorry) and i'm not alone to have the same problem.
the only way is really to modify the program, re-compile,
and re-send all to all users... A lot of work and a lot of
time
Olaf Doschke
2003-07-22 23:25:20 UTC
Permalink
Hi Eric,
Post by Eric den Doop
In many apps, I use the SYS(2015) to generate temporary file names and
valid_filename = SUBSTR(SYS(2015), 3, 10)
Well, the help to SYS(3) says

a) SYS(3) can produce identical names when run on fast computers, so there
is the mentioning of SYS(2015).

b) The hint to use SUBSTR(SYS(2015),3) is given to create FILEnames
with a length of 8 chars!

c) There is a warning, that SUBSTR(SYS(2015),3) can begin with a number
which is not allowed for a tablename. Because of that there is a hint to
use "_"+SUBSTR(SYS(2015),4) instead.

d) For OSes which support long file names there is a hint to use SYS(2015)
directly, because it always begins with "_"

e) They should have given the hint to use LEFT(SYS(2015),8) to produce
a valid table name beginning with "_" instead of c). Why should you first
cut off a "_" and then put it back !?!?

The help is quite okay here, but a bit complicated, taken into account,
that nowadays SYS(2015) should be fine anyway...

I don't know how SYS(2015) works, but it has something to do with
the system date/time, it's pobably just a conversion to such a string with
A-Z and 0-9 as possible chars. And it must use a buffer in case you'll call
it again within the same millisecond interval it just adds 1 to the previous
"number" (how yould you call a number system with 36 possible digits?
hexatridecimal system??

Now the 3rd char of SYS(2015) is "0", before (up to 14. July) it was "Z".

Bye, Olaf.
Erich TODT
2003-07-23 00:35:44 UTC
Permalink
Hi, Olaf,
Post by Olaf Doschke
Well, the help to SYS(3) says
< [..]
Post by Olaf Doschke
e) They should have given the hint to use LEFT(SYS(2015),8) to produce
a valid table name beginning with "_" instead of c). Why should you first
cut off a "_" and then put it back !?!?
That's definitely wrong. When calling SYS(2015) twice, it may happen that
the result differs in the last character only. However, your suggested code
LEFT(SYS(2015),8) would produce two identical strings in this case. That's
far away from uniqueness!

Best greetings
Erich


--

Erich TODT
e-mail: ***@tz-com.at
web: http://www.todt.at/
a***@gmail.com
2012-12-14 15:09:45 UTC
Permalink
Si bien el sys(2015) es la opción más adecuada, la ayuda indica que repite valores si se llama dentro del mismo milisegundo; según la lógica de tu programa, podes obviar esto, a riesgo propio.

Para garantizar un 100% en cualquier caso, podes hacer una función (desde http://fox.wikis.com/wc.dll?Wiki~FunctionSys2015)

m.UniqueString=UniqueString()

FUNCTION UniqueString
LOCAL m.Result
m.Result=SYS(2015)
DO WHILE m.Result=SYS(2015)
ENDDO
RETURN m.Result

Saludos
Post by Eric den Doop
Hello, All!
In many apps, I use the SYS(2015) to generate temporary file names and
valid_filename = SUBSTR(SYS(2015), 3, 10)
Since yesterday the SUBSTR(SYS(2015), 3, 10) function returns file names
that begin with a number which is ok for files but really screws up your app
if you, like me, are using it for cursor names. I was able to fix this
problem quite easily by using the search and replace feature in VFP to add a
valid_filename = "_" + SUBSTR(SYS(2015), 3, 10)
Just wanted to share this information with you.
By the way: does anybody know how the SYS(2015) algorithm works?
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
Continue reading on narkive:
Loading...