Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best practice for concatenating with null character fiel
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00483187
Message ID:
00483427
Views:
8
I would use something like the following

LOCAL lcString, i, lcResult, lcTest, lcVar
lcResult = ""
lcString = "address1, address2, address3" &&you know the rest
FOR i = 1 TO WORDS(lcString) && Words is a foxtools function.
lcVar = WORDNUM(lcString,i) && Wordnum is also a foxtools function
lcTest = "IF !EMPTY("+lcVar+")"
&lcTest
lcString = lcString + &lcVar
ENDIF
ENDFOR

Now, I know its a few lines, but it can easily be modified to work with different lists of varying lengths. If you don't want to use foxtools, I have native VFP code versions of both words() and wordnum() that I use to avoid the use of foxtools.

>If I was wanting to concatenate two character fields and one of them could potentially be empty, what code can I use for that? I have worked with this:
>
>allt(address1)+IIF(!empty(address2),address2,'')
>
>Is there any simpler code that you can use? That is quite simple itself, but If you have a long concatenation, your code gets quite long.
>
>Thanks.
Cy Welch
Senior Programmer/Analyst
MetSYS Inc
Previous
Reply
Map
View

Click here to load this message in the networking platform