Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
My file to string does nor have CR characters
Message
 
À
29/10/2014 12:41:42
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01609739
Message ID:
01610167
Vues:
33
Naoto you said to to get rid of the extraneous lines with dashes, we could modify thusly: but I get errors with cbuf so what i did was

#DEFINE _CR_ CHR(13)
#DEFINE _LF_ CHR(10)
#DEFINE _NL_ _CR_+_LF_
SELECT eit
SCAN
narry=ALLTRIM(narry)
= strtofile(narry, 'c:\colineit.txt', 1)
= strtofile( _NL_,'c:\colineit.txt',1)
ENDSCAN

which produced this

"A","GOPT","COL123","10/13/2014","1028.01","HAYES","GBP","61.86","GB"
"B","1234567","10/06/2014","19.80","7220717","MERRILL CORPORATION LIMITED","CUSTOMER SERVICE","101 FINSBURY PAVEMENT 2ND FLOOR","LONDON EC2A 1ER","","","EC2A 1ER","GB","CREDIT SUISSE","","1 CABOT SQUARE","CANARY WHARF","LONDON","","","GB","UKSTD 20.
"B","2345678","10/06/2014","60.98","7220718","MERRILL CORPORATION LIMITED","CUSTOMER SERVICE","101 FINSBURY PAVEMENT 2ND FLOOR","LONDON EC2A 1ER","","","EC2A 1ER","GB","DEUTSCHE BANK","","3 AVENUE DE FRIEDLAND","PARIS 75008","PARIS","","","FR","UKST
"B","3456789","10/06/2014","58.30","7220719","MERRILL CORPORATION LIMITED","CUSTOMER SERVICE","101 FINSBURY PAVEMENT 2ND FLOOR","LONDON EC2A 1ER","","","EC2A 1ER","GB","BNP PARIBAS","","787 7TH AVENUE","NEW YORK","NEW YORK","","","US",""
"B","4567891","10/06/2014","187.44","7220720","MERRILL CORPORATION LIMITED","CUSTOMER SERVICE","101 FINSBURY PAVEMENT 2ND FLOOR","LONDON EC2A 1ER","","","EC2A 1ER","GB","JAGUAR CARS","","HALL 3.1 STAND A19","IAA FRANKFURT MESSEGELANDE","FRANKFURT","
"B","5678912","10/06/2014","102.96","7220721","MERRILL CORPORATION LIMITED","CUSTOMER SERVICE","101 FINSBURY PAVEMENT 2ND FLOOR","LONDON EC2A 1ER","","","EC2A 1ER","GB","MORGAN STANLEY","","C / SERRANO 55","MADRID 28006","MADRID","","","ES","UKSTD 2
"B","6789123","10/06/2014","61.91","7220722","MERRILL CORPORATION LIMITED","CUSTOMER SERVICE","101 FINSBURY PAVEMENT 2ND FLOOR","LONDON EC2A 1ER","","","EC2A 1ER","GB","POWER FINANCIAL DO BRASIL S.A.","","AV. MARECHAL CÂMARA,","271 / 1102 – 20020-08
"B","7897897","10/06/2014","19.80","7220723","MERRILL CORPORATION LIMITED","CUSTOMER SERVICE","101 FINSBURY PAVEMENT 2ND FLOOR","LONDON EC2A 1ER","","","EC2A 1ER","GB","POWER PLATE MEXICO SA DE C.V","","PRD.PASEO DE LOS CAURELES","458 201B","MEXICO
"B","4564567","10/06/2014","272.65","7220724","MERRILL CORPORATION LIMITED","CUSTOMER SERVICE","101 FINSBURY PAVEMENT 2ND FLOOR","LONDON EC2A 1ER","","","EC2A 1ER","GB","PT INDOKORES SAHABAT","","J L BUNI NO 61 RT 003 RW 05","CILAN GLAP","JAKARTA","
"B","7897897","10/06/2014","135.82","7220725","MERRILL CORPORATION LIMITED","CUSTOMER SERVICE","101 FINSBURY PAVEMENT 2ND FLOOR","LONDON EC2A 1ER","","","EC2A 1ER","GB","JAGUAR & LAND ROVER CHINA","","NO 211 CENTURY AVENUE","FLOORS 21 31 32 33","CHI
"B","4561234","10/06/2014","108.35","7220726","MERRILL CORPORATION LIMITED","CUSTOMER SERVICE","101 FINSBURY PAVEMENT 2ND FLOOR","LONDON EC2A 1ER","","","EC2A 1ER","GB","MAYER INTERNATIONAL LTD","","89 MILESKONE DELHI JAIPER HIGHWAY","SECTOR 35","IN

Can you tell me whether in your opinion this works or not - it looks Ok to me

Sorry to be such a nuisance but I can't seem to produce a file which my client accepts




Your solution
>
>#DEFINE _CR_   CHR(13)
>#DEFINE _LF_    CHR(10)
>#DEFINE _NL_   _CR_+_LF_
>SELECT eit
>SCAN
>    cBuf = CHRTRAN(ALLTRIM(narry),_LF_,_CR_)
>    DO WHILE _CR_+_CR_ $ m.cBuf
>        narry = STRTRAN(m.cBuf,_CR_+_CR_,_CR_)
>    ENDDO
>    cBuf = RTRIM(m.cBuf,_CR_," ")
>    cBuf = STRTRAN(m.cBuf_CR_,_NL_)
>    = strtofile(cBuf+_NL_, 'c:\colineit.txt', 1)
>ENDSCAN
>
>The effect of all those CHRTRAN() and STRTRAN() calls is to basically translate the instances of carriage return and linefeed and turning them into newline sequences of carriage return followed by newline. I'm also reducing repeated newlines into single ones (basically removing "blank" lines). Also at the end when appending string to file, I'm making sure that there is a newline at the end.
Specialist in Advertising, Marketing, especially Direct Marketing

I run courses in Business Management and Marketing
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform