"Shortname" for FIELD of DBF

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

"Shortname" for FIELD of DBF

Post by AUGE_OHR »

hi,

when "read" XLSx via Excel ActiveX i often have "Header" which are longer than 10 Sign for FIELD in DBF
those "Header" Name can be equal on SUBSTR("Headername",1,10) so i need a "Shortname"

did somebody know a Way to get a unique "Shortname" from String which is longer than 10 Sign :?:
have fun
Jimmy
edk
Posts: 999
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: "Shortname" for FIELD of DBF

Post by edk »

I think you can store field names in an array and check if it already exist, if it does, change e.g. the last 2 characters to a random one (or some counter) and check again until they are unique.
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: "Shortname" for FIELD of DBF

Post by AUGE_OHR »

hi,
edk wrote: Sat Jan 14, 2023 4:00 pm if it does, change e.g. the last 2 characters to a random one (or some counter) and check again until they are unique.
OK, so i can use SUBSTR(x,1,8) + RANDSIGN(2) where last 2 Sign are random
thx for Idea :idea:
have fun
Jimmy
Post Reply