Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Warning: SYS(2015)

197 views
Skip to first unread message

Eric den Doop

unread,
Jul 15, 2003, 12:58:44 PM7/15/03
to
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


Erich TODT

unread,
Jul 15, 2003, 1:52:19 PM7/15/03
to
Hi Eric,

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

> 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: erich...@tz-com.at
web: http://www.todt.at/

Lee Mitchell

unread,
Jul 15, 2003, 1:46:16 PM7/15/03
to
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

Eric den Doop

unread,
Jul 15, 2003, 2:06:48 PM7/15/03
to
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...)

Dan Freeman

unread,
Jul 15, 2003, 2:46:29 PM7/15/03
to
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

"Eric den Doop" <ericd...@xspamblockxfoxite.com> wrote in message
news:eQCkcJvS...@TK2MSFTNGP12.phx.gbl...

Mike Pratt

unread,
Jul 15, 2003, 5:06:29 PM7/15/03
to
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"
<ericd...@xspamblockxfoxite.com> wrote:

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

Later,

Mike

John

unread,
Jul 16, 2003, 3:39:40 AM7/16/03
to
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

"Eric den Doop" <ericd...@xspamblockxfoxite.com> wrote in message
news:u$pbdvvSD...@TK2MSFTNGP12.phx.gbl...

Eric den Doop

unread,
Jul 16, 2003, 4:40:25 AM7/16/03
to
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.

Michel Levy

unread,
Jul 17, 2003, 9:44:06 AM7/17/03
to
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?

>.
>

David Frankenbach

unread,
Jul 17, 2003, 12:20:13 PM7/17/03
to
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

"Michel Levy" <lga_mic...@hotmail.com> wrote in message
news:0bc701c34c69$7dca1aa0$a101...@phx.gbl...

Michel Levy

unread,
Jul 17, 2003, 2:41:36 PM7/17/03
to
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

>.
>

David Frankenbach

unread,
Jul 17, 2003, 6:35:40 PM7/17/03
to
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


"Michel Levy" <lga_mic...@hotmail.com> wrote in message

news:011701c34c93$0d257d10$a501...@phx.gbl...

Jeff Bowman

unread,
Jul 18, 2003, 3:03:52 AM7/18/03
to
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


"Eric den Doop" <ericd...@xspamblockxfoxite.com> wrote in message news:u$pbdvvSD...@TK2MSFTNGP12.phx.gbl...

Eric den Doop

unread,
Jul 18, 2003, 4:56:39 AM7/18/03
to
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.

Olaf Doschke

unread,
Jul 22, 2003, 7:25:20 PM7/22/03
to
Hi Eric,

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

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

unread,
Jul 22, 2003, 8:35:44 PM7/22/03
to
Hi, Olaf,

"Olaf Doschke" <olaf.doschk...@t-online.de> schrieb im Newsbeitrag
news:bfkh4i$oif$00$2...@news.t-online.com...

> Well, the help to SYS(3) says

< [..]


> 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

agi...@gmail.com

unread,
Dec 14, 2012, 10:09:45 AM12/14/12
to
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
0 new messages