Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Does VFP have problem with nbsp?
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01539945
Message ID:
01539960
Vues:
31
>>>>Hi,
>>>>
>>>>If you run this code below you will see that the column fld1_fld2 of the resulting query does not have the entry in FLD2 for the first 3 records. The difference is that the first 3 records have 6 charecter entry and they are padded with more of & nbsp. Anybody see why?
>>>>
>>>>
>>>>CREATE CURSOR test (fld1 c(15), fld2 c(35))
>>>>INSERT INTO test (fld1, fld2) VALUES ("123456","Descripton of 123456")
>>>>INSERT INTO test (fld1, fld2) VALUES ("334343","Descripton of 334343")
>>>>INSERT INTO test (fld1, fld2) VALUES ("337743","Descripton of 337743")
>>>>INSERT INTO test (fld1, fld2) VALUES ("3343430000000","Descripton of 3343430000000")
>>>>
>>>>select *, ALLTRIM(FLD1) + REPLICATE( ' ', 15-LEN(ALLTRIM(FLD1)) ) +  ' ' + ALLTRIM(FLD2) AS FLD1_FLD2 from test 
>>>>
>>>
>>>Because the field initial length is too short:
>>>
>>>select *, ;
>>>  padr(ALLTRIM(FLD1) + REPLICATE( ' ', 15-LEN(ALLTRIM(FLD1)) ) +  ' ' + ALLTRIM(FLD2),200) ;
>>>        AS FLD1_FLD2 ;
>>>from test
>>>
>>
>>Interesting. I don't understand why PADR() makes all the difference. But it works. Thank you.
>
>BTW, instead of PADR you can also use CAST (my expression as varchar(200))
>
>That's the trick I recently used when I made a similar mistake (forgot to define a length for the final column in the select statement).

Thank you.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform