Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Tabs to Spaces
Message
 
 
À
13/02/1999 00:06:59
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00187332
Message ID:
00187406
Vues:
20
>One of our clients wants some reports that come from one of his vendors imported into his database. The reports come in an ASCII file and we use low-level file functions to import the file. The problem is that some times the report has tabs in instead of spaces. Is there a way to figure out how many spaces a tab takes up? Depending on when it tabs the tab could take up 5 spaces to just 1 but how do you know?

Is the file delimited or fixed length? If it is delimited, you might could use strtran() to replace all the tabs with a single space. Otherwise, you may have to keep track of how many characters you import before a tab, then use the mod() function on the length of that string divided by 5. Take the decimal part of the return value remainder, multiply that by 5 to see how many spaces that tab represents.

lnRetVal = mod(len(lcString), 5)
lnDecimal = lnRetVal - int(lnRetVal)
lnSpaces = lnDecimal * 5
lcString = lcString + space(lnSpaces)

You would have to contruct lcString a piece at a time up to each tab found.
Mark McCasland
Midlothian, TX USA
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform