PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → How to build such complex strings with double quotes easily?
How to build such complex strings with double quotes easily?
Iniciado por guest, 02,feb. 2016 11:44 - 6 respuestas
Publicado el 02,febrero 2016 - 11:44
Hello,

I am trying to build a string which is getting a bit too long as it contains double quotes.

Here is the code:
bufRetValueBuffer = Charact(34) + "ok" + Charact(34) + "," + Charact(34) + Charact(34) + "," + Charact(34) + Charact(34) + "," + Charact(34) + Charact(34) + "," + Charact(34) + Charact(34) I should the string like this:
Quote

"ok","","","",""

Is there any easier way to build strings with quotes (single as well as double)?

TIA

Yogi Yang
Publicado el 02,febrero 2016 - 13:46
Just doudle them or use the sintax:

my_string is string=[
aaa "bb" ccc
]

http://doc.windev.com/en-US/…
http://doc.windev.com/en-US/…
Publicado el 02,febrero 2016 - 13:48
Hi, Yogi.
Two suggestions:
1. The quick and dirty way is to define a 1-character string for double quotes
DQ is string=Charact(34)

Your command would look like
bufRetValueBuffer=DQ+"ok"+DQ+","+DQ+DQ+","+DQ+DQ+","

2. A fancier way would be to define a procedure (local or global)
PROCEDURE DQ(x)
RESULT Charact(34)+x+Charact(34)

Your command would look like
bufRetValueBuffer=DQ("ok")+","+DQ("")+","+DQ("")
Publicado el 02,febrero 2016 - 13:50
Hi Yogi,

I think you can use triple quotes.
For better readability you could also use:
bufRetValueBuffer = Replace("-ok-,--,--,--","-",Charact(34))
or
bufRetValueBuffer = StringBuild("%1ok%1,%1%1,%1%1,%1%1",Charact(34))

Regards,
Piet
Publicado el 02,febrero 2016 - 13:55
Hi Yogi

In addition to the other suggestions:
If the length of the line is a problem, as you said, you can cut it into two or more lines with ... (three periods). Like:

DQ is string=Charact(34) bufRetValueBuffer=DQ+"ok"+DQ+... ","+DQ+DQ+","+DQ... +DQ+","
best regards
Ola
Publicado el 02,febrero 2016 - 14:40
You could also try building a string that contains "%1","%2","%3",... as many as you need.

Then StringBuild(YourString,Forename,Surname,Address1...)

Then you would see something like "Fred","Bloggs","1 High Street",...

Don't forget, you can also use arrays to build the content :spos:

http://help.windev.com/en-US/…
Publicado el 02,febrero 2016 - 14:54
Quote
Paulo Oliveira

Just doudle them or use the sintax:

my_string is string=[

aaa "bb" ccc

]
Paulo,

Thanks for the hint. It works perfectly and as I need it. Instead of adopting suggestions by others I prefer to go with your suggestion. It is easier and cleaner.

Thank you,

Yogi Yang