I have got a table of items, and I need to produce a unique but recognisable
8-character descriptor for each one. The problem is that the items might be
so similar that the first 8 characters are the same. Is there a way of
generating a 8-character descriptor like this. I am imagining something
similar to the shortname function in filesystemobject to get a result like
this:

Widgets white (Widget~1)
Widgets black (Widget~2)
Acme (Acme)
General (General)
Grommets small (Gromme~1)
Grommets large (Gromme~2)

etc

Many thanks

Stephen

Re: something similar to shortname function in filesystemobject by Imaginecorp

Imaginecorp
Sat Jun 03 15:00:48 CDT 2006

Yes but in involves coding.
Are you saving the short names in a table? Are you setting the short name in
a form or the SP of the dbc?
If yes to storing in a table and yes to... in a form, its simple. If doing
it in the SP (stored procedures) its complicated.
Let me know and I will walk you through it
Mohammed
www.imaginecorp.com/whatwedo.htm

"Stephen Ibbs" <stephen@datadevelopments.co.uk> wrote in message
news:euNlTclhGHA.4896@TK2MSFTNGP05.phx.gbl...
>I have got a table of items, and I need to produce a unique but
>recognisable 8-character descriptor for each one. The problem is that the
>items might be so similar that the first 8 characters are the same. Is
>there a way of generating a 8-character descriptor like this. I am
>imagining something similar to the shortname function in filesystemobject
>to get a result like this:
>
> Widgets white (Widget~1)
> Widgets black (Widget~2)
> Acme (Acme)
> General (General)
> Grommets small (Gromme~1)
> Grommets large (Gromme~2)
>
> etc
>
> Many thanks
>
> Stephen
>



Re: something similar to shortname function in filesystemobject by Josh

Josh
Sat Jun 03 15:38:03 CDT 2006

While not Ideal in any stretch this would do it:

lcItem = "Widgest, large White"
mkdir "&lcItem"
?getshortname( lcItem )
rmdir "&lcItem"

FUNC GetShortPath
LPARAM tcLongFile
LOCAL lcShortPath, lcBuffer, lnBufferSize, lnShortPathLen

DECLARE INTEGER GetShortPathName IN Win32API ;
STRING @cLongPath, ;
STRING @cShortPathBuff, ;
INTEGER nBuffSize

lnBufferSize = LEN(tcLongFile)
lcBuffer = SPACE(lnBufferSize)
lnShortPathLen = GetShortPathName(tcLongFile, @lcBuffer, @lnBufferSize)

lcShortPath = LEFT(lcBuffer, lnShortPathLen)

RETURN IIF(EMPTY(lcShortPath), tcLongFile, lcShortPath)

ENDFUNC


On Fri, 2 Jun 2006 16:11:29 +0100, "Stephen Ibbs"
<stephen@datadevelopments.co.uk> wrote:

>I have got a table of items, and I need to produce a unique but recognisable
>8-character descriptor for each one. The problem is that the items might be
>so similar that the first 8 characters are the same. Is there a way of
>generating a 8-character descriptor like this. I am imagining something
>similar to the shortname function in filesystemobject to get a result like
>this:
>
>Widgets white (Widget~1)
>Widgets black (Widget~2)
>Acme (Acme)
>General (General)
>Grommets small (Gromme~1)
>Grommets large (Gromme~2)
>
>etc
>
>Many thanks
>
>Stephen
>


--- AntiSpam/harvest ---
Remove X's to send email to me.

Re: something similar to shortname function in filesystemobject by Stephen

Stephen
Sun Jun 04 02:21:28 CDT 2006

Sorry for late reply

Yes I am saving them in a table, and yes I am setting the short name in a
form.

Thanks

Stephen

"Imaginecorp" <imaginecorp@msn.com> wrote in message
news:%23p7$qh0hGHA.1264@TK2MSFTNGP05.phx.gbl...
> Yes but in involves coding.
> Are you saving the short names in a table? Are you setting the short name
> in a form or the SP of the dbc?
> If yes to storing in a table and yes to... in a form, its simple. If doing
> it in the SP (stored procedures) its complicated.
> Let me know and I will walk you through it
> Mohammed
> www.imaginecorp.com/whatwedo.htm
>
> "Stephen Ibbs" <stephen@datadevelopments.co.uk> wrote in message
> news:euNlTclhGHA.4896@TK2MSFTNGP05.phx.gbl...
>>I have got a table of items, and I need to produce a unique but
>>recognisable 8-character descriptor for each one. The problem is that the
>>items might be so similar that the first 8 characters are the same. Is
>>there a way of generating a 8-character descriptor like this. I am
>>imagining something similar to the shortname function in filesystemobject
>>to get a result like this:
>>
>> Widgets white (Widget~1)
>> Widgets black (Widget~2)
>> Acme (Acme)
>> General (General)
>> Grommets small (Gromme~1)
>> Grommets large (Gromme~2)
>>
>> etc
>>
>> Many thanks
>>
>> Stephen
>>
>
>



Re: something similar to shortname function in filesystemobject by Stephen

Stephen
Sun Jun 04 02:25:13 CDT 2006

Thanks Josh - clever idea - but I had hoped to avoid creating directories -

Sincerely

Stephen

"Josh Assing" <XjoshX@jAssing.com> wrote in message
news:hls382l2cokjr3a6v1jpmvvfk3pfhgg3kv@4ax.com...
> While not Ideal in any stretch this would do it:
>
> lcItem = "Widgest, large White"
> mkdir "&lcItem"
> ?getshortname( lcItem )
> rmdir "&lcItem"
>
> FUNC GetShortPath
> LPARAM tcLongFile
> LOCAL lcShortPath, lcBuffer, lnBufferSize, lnShortPathLen
>
> DECLARE INTEGER GetShortPathName IN Win32API ;
> STRING @cLongPath, ;
> STRING @cShortPathBuff, ;
> INTEGER nBuffSize
>
> lnBufferSize = LEN(tcLongFile)
> lcBuffer = SPACE(lnBufferSize)
> lnShortPathLen = GetShortPathName(tcLongFile, @lcBuffer, @lnBufferSize)
>
> lcShortPath = LEFT(lcBuffer, lnShortPathLen)
>
> RETURN IIF(EMPTY(lcShortPath), tcLongFile, lcShortPath)
>
> ENDFUNC
>
>
> On Fri, 2 Jun 2006 16:11:29 +0100, "Stephen Ibbs"
> <stephen@datadevelopments.co.uk> wrote:
>
>>I have got a table of items, and I need to produce a unique but
>>recognisable
>>8-character descriptor for each one. The problem is that the items might
>>be
>>so similar that the first 8 characters are the same. Is there a way of
>>generating a 8-character descriptor like this. I am imagining something
>>similar to the shortname function in filesystemobject to get a result
>>like
>>this:
>>
>>Widgets white (Widget~1)
>>Widgets black (Widget~2)
>>Acme (Acme)
>>General (General)
>>Grommets small (Gromme~1)
>>Grommets large (Gromme~2)
>>
>>etc
>>
>>Many thanks
>>
>>Stephen
>>
>
>
> --- AntiSpam/harvest ---
> Remove X's to send email to me.



Re: something similar to shortname function in filesystemobject by Olaf

Olaf
Sun Jun 04 03:01:36 CDT 2006

> Thanks Josh - clever idea - but I had hoped to avoid creating
> directories -
Yes, and removing the directory afterward
will also give you the same short name (~1)
for names with similar first 8 characters.

If you don't really care about the short name
beginning like tho long filename, then you could
either simply use an autoinc or sys(3) to get
a random 8 char long valid file name. and
store the long file name in a memo field.

Bye, Olaf.



Re: something similar to shortname function in filesystemobject by Imaginecorp

Imaginecorp
Sun Jun 04 09:13:31 CDT 2006

Ok, now it is simple.
Lets say; you have a field in a form that asks for a name of something,
"Widget White Large" (longname) and you have an
algorithm that takes the first 5 ,or a mixture of, characters of the name
then adds a tildi "~" and a number. so "widget white large" becomes
"widge~39. Important to have a range of upto at least 99, unless you are
sure there will never be more than 9 items.

Lets assume this shortname is in a table called "Items" and 2 fields
"longnames" and "shortnames"

Create an index on "shortnames" and "longnames".

set talk off in the Init of your form

In your form in the valid event of the longnames textbox put the following:



if !empty(this.value)

local cOldTag, cOldVal,nRecno,nMax,cNewShortName

select items

***** we dont want this to run all the time, only if the value has
changed

coldval = nvl(oldval("longnames","items"),"")

if coldval = this.value

return

endif

***************

coldtag = tag()
nRecno = recno()

set order to tag shortnames

cNewShortName = << your algorithm(this.value) >>
Calculate max(val(strextract(items.shortnames,"~"))) for
strextract(items.shortnames,"~") = cNewshortname to nMax
cNewShortName = cNewShortname+"~"+transform(nmax+1)
iif(!empty(coldval),goto nrecno,go bottom)
***to ovoid error "record is out of range" for a new record
Set order to tag (coldtag)
endif

Thats it. I have not tested this, but you get the idea....
Good Luck
Mohammed
www.imaginecorp.com/whatedo.htm


"Stephen Ibbs" <stephen@ibbs.org.uk> wrote in message
news:%23qFeAe6hGHA.3860@TK2MSFTNGP02.phx.gbl...
> Sorry for late reply
>
> Yes I am saving them in a table, and yes I am setting the short name in a
> form.
>
> Thanks
>
> Stephen
>
> "Imaginecorp" <imaginecorp@msn.com> wrote in message
> news:%23p7$qh0hGHA.1264@TK2MSFTNGP05.phx.gbl...
>> Yes but in involves coding.
>> Are you saving the short names in a table? Are you setting the short name
>> in a form or the SP of the dbc?
>> If yes to storing in a table and yes to... in a form, its simple. If
>> doing it in the SP (stored procedures) its complicated.
>> Let me know and I will walk you through it
>> Mohammed
>> www.imaginecorp.com/whatwedo.htm
>>
>> "Stephen Ibbs" <stephen@datadevelopments.co.uk> wrote in message
>> news:euNlTclhGHA.4896@TK2MSFTNGP05.phx.gbl...
>>>I have got a table of items, and I need to produce a unique but
>>>recognisable 8-character descriptor for each one. The problem is that the
>>>items might be so similar that the first 8 characters are the same. Is
>>>there a way of generating a 8-character descriptor like this. I am
>>>imagining something similar to the shortname function in filesystemobject
>>>to get a result like this:
>>>
>>> Widgets white (Widget~1)
>>> Widgets black (Widget~2)
>>> Acme (Acme)
>>> General (General)
>>> Grommets small (Gromme~1)
>>> Grommets large (Gromme~2)
>>>
>>> etc
>>>
>>> Many thanks
>>>
>>> Stephen
>>>
>>
>>
>
>



Re: something similar to shortname function in filesystemobject by Imaginecorp

Imaginecorp
Sun Jun 04 09:18:31 CDT 2006

Sorry forgot to include:
Replace items.shortnames with cNewShortName
Mohammed

"Imaginecorp" <imaginecorp@msn.com> wrote in message
news:eci0QE%23hGHA.4892@TK2MSFTNGP02.phx.gbl...
> Ok, now it is simple.
> Lets say; you have a field in a form that asks for a name of something,
> "Widget White Large" (longname) and you have an
> algorithm that takes the first 5 ,or a mixture of, characters of the name
> then adds a tildi "~" and a number. so "widget white large" becomes
> "widge~39. Important to have a range of upto at least 99, unless you are
> sure there will never be more than 9 items.
>
> Lets assume this shortname is in a table called "Items" and 2 fields
> "longnames" and "shortnames"
>
> Create an index on "shortnames" and "longnames".
>
> set talk off in the Init of your form
>
> In your form in the valid event of the longnames textbox put the
> following:
>
>
>
> if !empty(this.value)
>
> local cOldTag, cOldVal,nRecno,nMax,cNewShortName
>
> select items
>
> ***** we dont want this to run all the time, only if the value has
> changed
>
> coldval = nvl(oldval("longnames","items"),"")
>
> if coldval = this.value
>
> return
>
> endif
>
> ***************
>
> coldtag = tag()
> nRecno = recno()
>
> set order to tag shortnames
>
> cNewShortName = << your algorithm(this.value) >>
> Calculate max(val(strextract(items.shortnames,"~"))) for
> strextract(items.shortnames,"~") = cNewshortname to nMax
> cNewShortName = cNewShortname+"~"+transform(nmax+1)
> iif(!empty(coldval),goto nrecno,go bottom)
> ***to ovoid error "record is out of range" for a new record
> Set order to tag (coldtag)
> endif
>
> Thats it. I have not tested this, but you get the idea....
> Good Luck
> Mohammed
> www.imaginecorp.com/whatedo.htm
>
>
> "Stephen Ibbs" <stephen@ibbs.org.uk> wrote in message
> news:%23qFeAe6hGHA.3860@TK2MSFTNGP02.phx.gbl...
>> Sorry for late reply
>>
>> Yes I am saving them in a table, and yes I am setting the short name in a
>> form.
>>
>> Thanks
>>
>> Stephen
>>
>> "Imaginecorp" <imaginecorp@msn.com> wrote in message
>> news:%23p7$qh0hGHA.1264@TK2MSFTNGP05.phx.gbl...
>>> Yes but in involves coding.
>>> Are you saving the short names in a table? Are you setting the short
>>> name in a form or the SP of the dbc?
>>> If yes to storing in a table and yes to... in a form, its simple. If
>>> doing it in the SP (stored procedures) its complicated.
>>> Let me know and I will walk you through it
>>> Mohammed
>>> www.imaginecorp.com/whatwedo.htm
>>>
>>> "Stephen Ibbs" <stephen@datadevelopments.co.uk> wrote in message
>>> news:euNlTclhGHA.4896@TK2MSFTNGP05.phx.gbl...
>>>>I have got a table of items, and I need to produce a unique but
>>>>recognisable 8-character descriptor for each one. The problem is that
>>>>the items might be so similar that the first 8 characters are the same.
>>>>Is there a way of generating a 8-character descriptor like this. I am
>>>>imagining something similar to the shortname function in
>>>>filesystemobject to get a result like this:
>>>>
>>>> Widgets white (Widget~1)
>>>> Widgets black (Widget~2)
>>>> Acme (Acme)
>>>> General (General)
>>>> Grommets small (Gromme~1)
>>>> Grommets large (Gromme~2)
>>>>
>>>> etc
>>>>
>>>> Many thanks
>>>>
>>>> Stephen
>>>>
>>>
>>>
>>
>>
>
>



Re: something similar to shortname function in filesystemobject by Stephen

Stephen
Sun Jun 04 09:29:36 CDT 2006

Many thanks for all contributions, and your code Mohammed has pointed the
way forward for me. Thanks again

Sincerely

Stephen

"Imaginecorp" <imaginecorp@msn.com> wrote in message
news:uluGEH%23hGHA.2208@TK2MSFTNGP05.phx.gbl...
> Sorry forgot to include:
> Replace items.shortnames with cNewShortName
> Mohammed
>
> "Imaginecorp" <imaginecorp@msn.com> wrote in message
> news:eci0QE%23hGHA.4892@TK2MSFTNGP02.phx.gbl...
>> Ok, now it is simple.
>> Lets say; you have a field in a form that asks for a name of something,
>> "Widget White Large" (longname) and you have an
>> algorithm that takes the first 5 ,or a mixture of, characters of the name
>> then adds a tildi "~" and a number. so "widget white large" becomes
>> "widge~39. Important to have a range of upto at least 99, unless you are
>> sure there will never be more than 9 items.
>>
>> Lets assume this shortname is in a table called "Items" and 2 fields
>> "longnames" and "shortnames"
>>
>> Create an index on "shortnames" and "longnames".
>>
>> set talk off in the Init of your form
>>
>> In your form in the valid event of the longnames textbox put the
>> following:
>>
>>
>>
>> if !empty(this.value)
>>
>> local cOldTag, cOldVal,nRecno,nMax,cNewShortName
>>
>> select items
>>
>> ***** we dont want this to run all the time, only if the value has
>> changed
>>
>> coldval = nvl(oldval("longnames","items"),"")
>>
>> if coldval = this.value
>>
>> return
>>
>> endif
>>
>> ***************
>>
>> coldtag = tag()
>> nRecno = recno()
>>
>> set order to tag shortnames
>>
>> cNewShortName = << your algorithm(this.value) >>
>> Calculate max(val(strextract(items.shortnames,"~"))) for
>> strextract(items.shortnames,"~") = cNewshortname to nMax
>> cNewShortName = cNewShortname+"~"+transform(nmax+1)
>> iif(!empty(coldval),goto nrecno,go bottom)
>> ***to ovoid error "record is out of range" for a new record
>> Set order to tag (coldtag)
>> endif
>>
>> Thats it. I have not tested this, but you get the idea....
>> Good Luck
>> Mohammed
>> www.imaginecorp.com/whatedo.htm
>>
>>
>> "Stephen Ibbs" <stephen@ibbs.org.uk> wrote in message
>> news:%23qFeAe6hGHA.3860@TK2MSFTNGP02.phx.gbl...
>>> Sorry for late reply
>>>
>>> Yes I am saving them in a table, and yes I am setting the short name in
>>> a form.
>>>
>>> Thanks
>>>
>>> Stephen
>>>
>>> "Imaginecorp" <imaginecorp@msn.com> wrote in message
>>> news:%23p7$qh0hGHA.1264@TK2MSFTNGP05.phx.gbl...
>>>> Yes but in involves coding.
>>>> Are you saving the short names in a table? Are you setting the short
>>>> name in a form or the SP of the dbc?
>>>> If yes to storing in a table and yes to... in a form, its simple. If
>>>> doing it in the SP (stored procedures) its complicated.
>>>> Let me know and I will walk you through it
>>>> Mohammed
>>>> www.imaginecorp.com/whatwedo.htm
>>>>
>>>> "Stephen Ibbs" <stephen@datadevelopments.co.uk> wrote in message
>>>> news:euNlTclhGHA.4896@TK2MSFTNGP05.phx.gbl...
>>>>>I have got a table of items, and I need to produce a unique but
>>>>>recognisable 8-character descriptor for each one. The problem is that
>>>>>the items might be so similar that the first 8 characters are the same.
>>>>>Is there a way of generating a 8-character descriptor like this. I am
>>>>>imagining something similar to the shortname function in
>>>>>filesystemobject to get a result like this:
>>>>>
>>>>> Widgets white (Widget~1)
>>>>> Widgets black (Widget~2)
>>>>> Acme (Acme)
>>>>> General (General)
>>>>> Grommets small (Gromme~1)
>>>>> Grommets large (Gromme~2)
>>>>>
>>>>> etc
>>>>>
>>>>> Many thanks
>>>>>
>>>>> Stephen
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Re: something similar to shortname function in filesystemobject by Josh

Josh
Sun Jun 04 13:41:21 CDT 2006

>Yes, and removing the directory afterward
>will also give you the same short name (~1)
>for names with similar first 8 characters.


EXCELLENT point!


--- AntiSpam/harvest ---
Remove X's to send email to me.

Re: something similar to shortname function in filesystemobject by Josh

Josh
Sun Jun 04 18:01:27 CDT 2006

How about this, I didn't work too hard on optimizing it (well; at all) just to
get the idea out there.

This should work for you no matter what.....


* GetShortName.prg

* These restrctions are not enforced in the code!!!
* Restrictions nShortName > nUnque + 1
* Unique must be >= 1
* unique msut be <= 7

#DEFINE nShortName 8 && How many characters do we want the "shortname" to be?
#DEFINE nUnique 2 && how many do we anticipate, 2 characters = 255
collisions
#DEFINE cDataFile "ShortNameList"

FUNCTION GetShortName
LPARAMETERS tcLongName
* Thanks to josh of vfpcoding.com for this code

LOCAL lcShortName AS STRING, ;
loSession AS SESSION,;
lnCurrentDataSession AS INTEGER,;
lnCount AS INTEGER,;
lcDataFile AS STRING

lnCurrentDataSession = SET("DataSession")
loSession=CREATEOBJECT("Session")
SET DATASESSION TO loSession.DATASESSIONID
IF !FILE(FORCEEXT(cDataFile,"DBF"))
lcDataFile = cDataFile && Goofy;but it's the only way with the #define
CREATE TABLE &lcDataFile (;
LongName M,;
ShortName c(nShortName) )
INDEX ON PADR(LongName,nShortName) TAG LongName
INDEX ON ShortName TAG ShortName
USE
ENDIF
USE ShortName SHARED ORDER LongName
IF !SEEK(PADR(tcLongName, nShortName))
* Not found quickly; add it
lnCount = 0
ELSE
* It was found... rats, this might take a bit longer
LOCATE FOR tcLongName == LongName
IF FOUND()
lcShortName = ShortName
lnCount = -1 && Signal we found it.
ELSE
COUNT ;
FOR PADR(tcLongName, nShortName-nUnique) ==
PADR(LongName,nShortName-nUnique);
TO lnCount
ENDIF
ENDIF
IF lnCount # -1
lcShortName =
LEFT(PADR(tcLongName,nShortName),nShortName-nUnique)+RIGHT(TRANSFORM(lnCount,"@0"),nUnique)
INSERT INTO ShortName;
(LongName, ShortName) ;
VALUES;
(tcLongName, lcShortName)
ENDIF
USE IN ShortName
SET DATASESSION TO lnCurrentDataSession

RETURN lcShortName
ENDFUNC



--- AntiSpam/harvest ---
Remove X's to send email to me.

Re: something similar to shortname function in filesystemobject by Imaginecorp

Imaginecorp
Sun Jun 04 19:03:17 CDT 2006

Pardon me,
But all this when simple VFP code will do... Like using a 100lb sledge
hammer to swat a fly don't you think..
Mohammed
www.imaginecorp.com/whatwedo.htm

"Josh Assing" <XjoshX@jAssing.com> wrote in message
news:80p682dkdqi3lqulcbkqvgirbhcai4a00g@4ax.com...
> How about this, I didn't work too hard on optimizing it (well; at all)
> just to
> get the idea out there.
>
> This should work for you no matter what.....
>
>
> * GetShortName.prg
>
> * These restrctions are not enforced in the code!!!
> * Restrictions nShortName > nUnque + 1
> * Unique must be >= 1
> * unique msut be <= 7
>
> #DEFINE nShortName 8 && How many characters do we want the "shortname" to
> be?
> #DEFINE nUnique 2 && how many do we anticipate, 2 characters = 255
> collisions
> #DEFINE cDataFile "ShortNameList"
>
> FUNCTION GetShortName
> LPARAMETERS tcLongName
> * Thanks to josh of vfpcoding.com for this code
>
> LOCAL lcShortName AS STRING, ;
> loSession AS SESSION,;
> lnCurrentDataSession AS INTEGER,;
> lnCount AS INTEGER,;
> lcDataFile AS STRING
>
> lnCurrentDataSession = SET("DataSession")
> loSession=CREATEOBJECT("Session")
> SET DATASESSION TO loSession.DATASESSIONID
> IF !FILE(FORCEEXT(cDataFile,"DBF"))
> lcDataFile = cDataFile && Goofy;but it's the only way with the #define
> CREATE TABLE &lcDataFile (;
> LongName M,;
> ShortName c(nShortName) )
> INDEX ON PADR(LongName,nShortName) TAG LongName
> INDEX ON ShortName TAG ShortName
> USE
> ENDIF
> USE ShortName SHARED ORDER LongName
> IF !SEEK(PADR(tcLongName, nShortName))
> * Not found quickly; add it
> lnCount = 0
> ELSE
> * It was found... rats, this might take a bit longer
> LOCATE FOR tcLongName == LongName
> IF FOUND()
> lcShortName = ShortName
> lnCount = -1 && Signal we found it.
> ELSE
> COUNT ;
> FOR PADR(tcLongName, nShortName-nUnique) ==
> PADR(LongName,nShortName-nUnique);
> TO lnCount
> ENDIF
> ENDIF
> IF lnCount # -1
> lcShortName =
> LEFT(PADR(tcLongName,nShortName),nShortName-nUnique)+RIGHT(TRANSFORM(lnCount,"@0"),nUnique)
> INSERT INTO ShortName;
> (LongName, ShortName) ;
> VALUES;
> (tcLongName, lcShortName)
> ENDIF
> USE IN ShortName
> SET DATASESSION TO lnCurrentDataSession
>
> RETURN lcShortName
> ENDFUNC
>
>
>
> --- AntiSpam/harvest ---
> Remove X's to send email to me.



Re: something similar to shortname function in filesystemobject by Josh

Josh
Sun Jun 04 20:14:52 CDT 2006

On Sun, 4 Jun 2006 20:03:17 -0400, "Imaginecorp" <imaginecorp@msn.com> wrote:

>Pardon me,
>But all this when simple VFP code will do... Like using a 100lb sledge
>hammer to swat a fly don't you think..


I dunno -- sometimes puzzles are fun.
Besides -- simple vfp code ? mine was pretty simple....
the original post was to emulate windows type getshort name, such that the
begining X characters are like the original name, with a different end
number....

anyway; puzzles are fun sometimes


>Mohammed
>www.imaginecorp.com/whatwedo.htm
>
>"Josh Assing" <XjoshX@jAssing.com> wrote in message
>news:80p682dkdqi3lqulcbkqvgirbhcai4a00g@4ax.com...
>> How about this, I didn't work too hard on optimizing it (well; at all)
>> just to
>> get the idea out there.
>>
>> This should work for you no matter what.....
>>
>>
>> * GetShortName.prg
>>
>> * These restrctions are not enforced in the code!!!
>> * Restrictions nShortName > nUnque + 1
>> * Unique must be >= 1
>> * unique msut be <= 7
>>
>> #DEFINE nShortName 8 && How many characters do we want the "shortname" to
>> be?
>> #DEFINE nUnique 2 && how many do we anticipate, 2 characters = 255
>> collisions
>> #DEFINE cDataFile "ShortNameList"
>>
>> FUNCTION GetShortName
>> LPARAMETERS tcLongName
>> * Thanks to josh of vfpcoding.com for this code
>>
>> LOCAL lcShortName AS STRING, ;
>> loSession AS SESSION,;
>> lnCurrentDataSession AS INTEGER,;
>> lnCount AS INTEGER,;
>> lcDataFile AS STRING
>>
>> lnCurrentDataSession = SET("DataSession")
>> loSession=CREATEOBJECT("Session")
>> SET DATASESSION TO loSession.DATASESSIONID
>> IF !FILE(FORCEEXT(cDataFile,"DBF"))
>> lcDataFile = cDataFile && Goofy;but it's the only way with the #define
>> CREATE TABLE &lcDataFile (;
>> LongName M,;
>> ShortName c(nShortName) )
>> INDEX ON PADR(LongName,nShortName) TAG LongName
>> INDEX ON ShortName TAG ShortName
>> USE
>> ENDIF
>> USE ShortName SHARED ORDER LongName
>> IF !SEEK(PADR(tcLongName, nShortName))
>> * Not found quickly; add it
>> lnCount = 0
>> ELSE
>> * It was found... rats, this might take a bit longer
>> LOCATE FOR tcLongName == LongName
>> IF FOUND()
>> lcShortName = ShortName
>> lnCount = -1 && Signal we found it.
>> ELSE
>> COUNT ;
>> FOR PADR(tcLongName, nShortName-nUnique) ==
>> PADR(LongName,nShortName-nUnique);
>> TO lnCount
>> ENDIF
>> ENDIF
>> IF lnCount # -1
>> lcShortName =
>> LEFT(PADR(tcLongName,nShortName),nShortName-nUnique)+RIGHT(TRANSFORM(lnCount,"@0"),nUnique)
>> INSERT INTO ShortName;
>> (LongName, ShortName) ;
>> VALUES;
>> (tcLongName, lcShortName)
>> ENDIF
>> USE IN ShortName
>> SET DATASESSION TO lnCurrentDataSession
>>
>> RETURN lcShortName
>> ENDFUNC
>>
>>
>>
>> --- AntiSpam/harvest ---
>> Remove X's to send email to me.
>


--- AntiSpam/harvest ---
Remove X's to send email to me.

Re: something similar to shortname function in filesystemobject by Imaginecorp

Imaginecorp
Sun Jun 04 21:11:56 CDT 2006

Like they say, hundreds of ways to skin a cat...
I agree... a challenge is always fun...Keeps the brain sharp
Mohammed

"Josh Assing" <XjoshX@jAssing.com> wrote in message
news:dt0782hapa5kj8ja2g1lguoc969sn2jced@4ax.com...
> On Sun, 4 Jun 2006 20:03:17 -0400, "Imaginecorp" <imaginecorp@msn.com>
> wrote:
>
>>Pardon me,
>>But all this when simple VFP code will do... Like using a 100lb sledge
>>hammer to swat a fly don't you think..
>
>
> I dunno -- sometimes puzzles are fun.
> Besides -- simple vfp code ? mine was pretty simple....
> the original post was to emulate windows type getshort name, such that the
> begining X characters are like the original name, with a different end
> number....
>
> anyway; puzzles are fun sometimes
>
>
>>Mohammed
>>www.imaginecorp.com/whatwedo.htm
>>
>>"Josh Assing" <XjoshX@jAssing.com> wrote in message
>>news:80p682dkdqi3lqulcbkqvgirbhcai4a00g@4ax.com...
>>> How about this, I didn't work too hard on optimizing it (well; at all)
>>> just to
>>> get the idea out there.
>>>
>>> This should work for you no matter what.....
>>>
>>>
>>> * GetShortName.prg
>>>
>>> * These restrctions are not enforced in the code!!!
>>> * Restrictions nShortName > nUnque + 1
>>> * Unique must be >= 1
>>> * unique msut be <= 7
>>>
>>> #DEFINE nShortName 8 && How many characters do we want the "shortname"
>>> to
>>> be?
>>> #DEFINE nUnique 2 && how many do we anticipate, 2 characters = 255
>>> collisions
>>> #DEFINE cDataFile "ShortNameList"
>>>
>>> FUNCTION GetShortName
>>> LPARAMETERS tcLongName
>>> * Thanks to josh of vfpcoding.com for this code
>>>
>>> LOCAL lcShortName AS STRING, ;
>>> loSession AS SESSION,;
>>> lnCurrentDataSession AS INTEGER,;
>>> lnCount AS INTEGER,;
>>> lcDataFile AS STRING
>>>
>>> lnCurrentDataSession = SET("DataSession")
>>> loSession=CREATEOBJECT("Session")
>>> SET DATASESSION TO loSession.DATASESSIONID
>>> IF !FILE(FORCEEXT(cDataFile,"DBF"))
>>> lcDataFile = cDataFile && Goofy;but it's the only way with the
>>> #define
>>> CREATE TABLE &lcDataFile (;
>>> LongName M,;
>>> ShortName c(nShortName) )
>>> INDEX ON PADR(LongName,nShortName) TAG LongName
>>> INDEX ON ShortName TAG ShortName
>>> USE
>>> ENDIF
>>> USE ShortName SHARED ORDER LongName
>>> IF !SEEK(PADR(tcLongName, nShortName))
>>> * Not found quickly; add it
>>> lnCount = 0
>>> ELSE
>>> * It was found... rats, this might take a bit longer
>>> LOCATE FOR tcLongName == LongName
>>> IF FOUND()
>>> lcShortName = ShortName
>>> lnCount = -1 && Signal we found it.
>>> ELSE
>>> COUNT ;
>>> FOR PADR(tcLongName, nShortName-nUnique) ==
>>> PADR(LongName,nShortName-nUnique);
>>> TO lnCount
>>> ENDIF
>>> ENDIF
>>> IF lnCount # -1
>>> lcShortName =
>>> LEFT(PADR(tcLongName,nShortName),nShortName-nUnique)+RIGHT(TRANSFORM(lnCount,"@0"),nUnique)
>>> INSERT INTO ShortName;
>>> (LongName, ShortName) ;
>>> VALUES;
>>> (tcLongName, lcShortName)
>>> ENDIF
>>> USE IN ShortName
>>> SET DATASESSION TO lnCurrentDataSession
>>>
>>> RETURN lcShortName
>>> ENDFUNC
>>>
>>>
>>>
>>> --- AntiSpam/harvest ---
>>> Remove X's to send email to me.
>>
>
>
> --- AntiSpam/harvest ---
> Remove X's to send email to me.



Re: something similar to shortname function in filesystemobject by Stephen

Stephen
Mon Jun 05 08:37:54 CDT 2006

Just for feedback, I used code based on Mohammed's, but many thanks Josh. I
also added a double chrtran(chrtran()) function to strip out all the
unwanted characters and spaces from the original source name and eventually
got it working exactly as I required.

Thanks

Stephen

"Imaginecorp" <imaginecorp@msn.com> wrote in message
news:uqFYuVEiGHA.4044@TK2MSFTNGP03.phx.gbl...
> Like they say, hundreds of ways to skin a cat...
> I agree... a challenge is always fun...Keeps the brain sharp
> Mohammed
>
> "Josh Assing" <XjoshX@jAssing.com> wrote in message
> news:dt0782hapa5kj8ja2g1lguoc969sn2jced@4ax.com...
>> On Sun, 4 Jun 2006 20:03:17 -0400, "Imaginecorp" <imaginecorp@msn.com>
>> wrote:
>>
>>>Pardon me,
>>>But all this when simple VFP code will do... Like using a 100lb sledge
>>>hammer to swat a fly don't you think..
>>
>>
>> I dunno -- sometimes puzzles are fun.
>> Besides -- simple vfp code ? mine was pretty simple....
>> the original post was to emulate windows type getshort name, such that
>> the
>> begining X characters are like the original name, with a different end
>> number....
>>
>> anyway; puzzles are fun sometimes
>>
>>
>>>Mohammed
>>>www.imaginecorp.com/whatwedo.htm
>>>
>>>"Josh Assing" <XjoshX@jAssing.com> wrote in message
>>>news:80p682dkdqi3lqulcbkqvgirbhcai4a00g@4ax.com...
>>>> How about this, I didn't work too hard on optimizing it (well; at all)
>>>> just to
>>>> get the idea out there.
>>>>
>>>> This should work for you no matter what.....
>>>>
>>>>
>>>> * GetShortName.prg
>>>>
>>>> * These restrctions are not enforced in the code!!!
>>>> * Restrictions nShortName > nUnque + 1
>>>> * Unique must be >= 1
>>>> * unique msut be <= 7
>>>>
>>>> #DEFINE nShortName 8 && How many characters do we want the "shortname"
>>>> to
>>>> be?
>>>> #DEFINE nUnique 2 && how many do we anticipate, 2 characters = 255
>>>> collisions
>>>> #DEFINE cDataFile "ShortNameList"
>>>>
>>>> FUNCTION GetShortName
>>>> LPARAMETERS tcLongName
>>>> * Thanks to josh of vfpcoding.com for this code
>>>>
>>>> LOCAL lcShortName AS STRING, ;
>>>> loSession AS SESSION,;
>>>> lnCurrentDataSession AS INTEGER,;
>>>> lnCount AS INTEGER,;
>>>> lcDataFile AS STRING
>>>>
>>>> lnCurrentDataSession = SET("DataSession")
>>>> loSession=CREATEOBJECT("Session")
>>>> SET DATASESSION TO loSession.DATASESSIONID
>>>> IF !FILE(FORCEEXT(cDataFile,"DBF"))
>>>> lcDataFile = cDataFile && Goofy;but it's the only way with the
>>>> #define
>>>> CREATE TABLE &lcDataFile (;
>>>> LongName M,;
>>>> ShortName c(nShortName) )
>>>> INDEX ON PADR(LongName,nShortName) TAG LongName
>>>> INDEX ON ShortName TAG ShortName
>>>> USE
>>>> ENDIF
>>>> USE ShortName SHARED ORDER LongName
>>>> IF !SEEK(PADR(tcLongName, nShortName))
>>>> * Not found quickly; add it
>>>> lnCount = 0
>>>> ELSE
>>>> * It was found... rats, this might take a bit longer
>>>> LOCATE FOR tcLongName == LongName
>>>> IF FOUND()
>>>> lcShortName = ShortName
>>>> lnCount = -1 && Signal we found it.
>>>> ELSE
>>>> COUNT ;
>>>> FOR PADR(tcLongName, nShortName-nUnique) ==
>>>> PADR(LongName,nShortName-nUnique);
>>>> TO lnCount
>>>> ENDIF
>>>> ENDIF
>>>> IF lnCount # -1
>>>> lcShortName =
>>>> LEFT(PADR(tcLongName,nShortName),nShortName-nUnique)+RIGHT(TRANSFORM(lnCount,"@0"),nUnique)
>>>> INSERT INTO ShortName;
>>>> (LongName, ShortName) ;
>>>> VALUES;
>>>> (tcLongName, lcShortName)
>>>> ENDIF
>>>> USE IN ShortName
>>>> SET DATASESSION TO lnCurrentDataSession
>>>>
>>>> RETURN lcShortName
>>>> ENDFUNC
>>>>
>>>>
>>>>
>>>> --- AntiSpam/harvest ---
>>>> Remove X's to send email to me.
>>>
>>
>>
>> --- AntiSpam/harvest ---
>> Remove X's to send email to me.
>
>