Pls, What is the diff between #DQ$ and DQ$ ? Thanksskywalk wrote:Code: Select all
#DQ$ = Chr(34) MyString$ = #DQ$ + "Hello" + #DQ$ debug MyString$
How to get a doubleQuote into a string ?
Re: How to get a doubleQuote into a string ?
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
"All things in moderation , except for love and forgiveness."
Re: How to get a doubleQuote into a string ?
Oh, ya, ThanksStarBootics wrote:Another way around :
Code: Select all
MyString$ = Chr(34) + "Hello" + Chr(34) Debug MyString$
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
"All things in moderation , except for love and forgiveness."
Re: How to get a doubleQuote into a string ?
Ah, What fun! I have downloaded this whole page.idle wrote:wrapping it in a macro is perhaps more convenient
Code: Select all
Macro DQ(text) #DQUOTE$ + text + #DQUOTE$ EndMacro mystring.s = DQ("foo") + "," + DQ("bar") Debug mystring
Thanks All..
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
"All things in moderation , except for love and forgiveness."
Re: How to get a doubleQuote into a string ?
And now for the other shoe:
Outputting Html-code from a PB program.
I am still having trouble writing DoubleQuotes into Html code.
Input file looks like this:
0,0,E6E9FE
1,0,E7EAFF
2,0,E7EBFE
3,0,E8ECFF
Variables:
DQ$ = Chr(34)
TBox02dot$ contains E6E9FE (after 1st record is read in.)
OneLine$ contains 0,0,E6E9FE (after 1st record is read in.)
The line of code that transforms the above variables into
<TR><TD style=height:50px; background-color:#E6E9FE;>0,0,E6E9FE</TD>
is this code:
LTTD01$ = "<TR><TD style="+DQ$+"height:50px; background-color:#"+TBox02dot$+";"+DQ$+">"+OneLine$+"</TD>"
But that isn't what I want.
I want the code above to transform the input file into this:
<TR><TD style="height:50px; background-color:#E6E9FE;">0,0,E6E9FE</TD>
See the doubleQuotes!
But the html that gets generated is this:
<!DOCTYPE HTML PUBLIC-//W3C//DTD HTML 4.01 Transitional//EN >
<html><head>
<meta charset=utf-8><title>xRainbow-Project</title>
<style>
table td {border: 1px solid black; color: Black;}</style>
</head><body>
<TABLE>
<TR><TD style=height:50px; background-color:#E6E9FE;>0,0,E6E9FE</TD>
<TR><TD style=height:50px; background-color:#E7EAFF;>1,0,E7EAFF</TD>
<TR><TD style=height:50px; background-color:#E7EBFE;>2,0,E7EBFE</TD>
<TR><TD style=height:50px; background-color:#E8ECFF;>3,0,E8ECFF</TD>
</TABLE></body></html>
ie., No doubleQuotes.
Here is the whole program code:
Outputting Html-code from a PB program.
I am still having trouble writing DoubleQuotes into Html code.
Input file looks like this:
0,0,E6E9FE
1,0,E7EAFF
2,0,E7EBFE
3,0,E8ECFF
Variables:
DQ$ = Chr(34)
TBox02dot$ contains E6E9FE (after 1st record is read in.)
OneLine$ contains 0,0,E6E9FE (after 1st record is read in.)
The line of code that transforms the above variables into
<TR><TD style=height:50px; background-color:#E6E9FE;>0,0,E6E9FE</TD>
is this code:
LTTD01$ = "<TR><TD style="+DQ$+"height:50px; background-color:#"+TBox02dot$+";"+DQ$+">"+OneLine$+"</TD>"
But that isn't what I want.
I want the code above to transform the input file into this:
<TR><TD style="height:50px; background-color:#E6E9FE;">0,0,E6E9FE</TD>
See the doubleQuotes!
But the html that gets generated is this:
<!DOCTYPE HTML PUBLIC-//W3C//DTD HTML 4.01 Transitional//EN >
<html><head>
<meta charset=utf-8><title>xRainbow-Project</title>
<style>
table td {border: 1px solid black; color: Black;}</style>
</head><body>
<TABLE>
<TR><TD style=height:50px; background-color:#E6E9FE;>0,0,E6E9FE</TD>
<TR><TD style=height:50px; background-color:#E7EAFF;>1,0,E7EAFF</TD>
<TR><TD style=height:50px; background-color:#E7EBFE;>2,0,E7EBFE</TD>
<TR><TD style=height:50px; background-color:#E8ECFF;>3,0,E8ECFF</TD>
</TABLE></body></html>
ie., No doubleQuotes.
Here is the whole program code:
Code: Select all
;From: OpenFile_Example.pb , Author: wayne1 (updated for PB4.00 by blbltheworm)
;input data generated fron ProgramName: xRainbow-vera.pb
Define.s OneLines = "Z00,000,FAE0D9"
Define.s TBox02$ , DQ$ = Chr(34)
Define.i OneLinei , x , y , CommaCnt , CountLinesOut
Global FileOpen = 0 , OneLine$="" , OneLiner$="" , OneLineByte$=""
Global TableBeg$ = "<TABLE>"
Global LTTD01$,LTTD02$,QTGT01$,TD02$,TD01$,TBox02dot$
;Structure TableRow
; TRbeg.s = "<TR>"
; TDbeg01a.s = "<TD style= + DQ$ + color:black + DQ$ + "
; TBox01.s = "000,000,FFFFFF"
; TDbeg01b.s = ">"
; TDbeg02a.s = "<TD BGCOLOR = + DQ$ + #"
; TBox02.s ; = "FFFFFF"
; TDbeg02b.s = ">"
; TDend.s = "</TD>"
; TRend.s = "</TR>"
;EndStructure
Procedure LoadHexColor(OneLine$)
OneLinei = StringByteLength(OneLine$, #PB_Ascii)
CommaCnt = 0 : TBox02$ = ""
For x = 1 To OneLinei
OneLineByte$ = Mid(OneLine$, x, 1)
If OneLineByte$ = ","
CommaCnt = CommaCnt +1
EndIf
If OneLineByte$ <> ","
If CommaCnt > 1
TBox02$ = TBox02$ + OneLineByte$
EndIf
EndIf
Next
TBox02.s = TBox02$ ; loadup TableRow.TBox02.s
TBox02dot$ = TBox02$
EndProcedure ; LoadHexColor()
Procedure FileOut(OneLine$)
If FileOpen = 0
If CreateFile(2, "ColorTable.html")
FileOpen = 1
WriteStringN(2,"<!DOCTYPE HTML PUBLIC" + DQ$ + "-//W3C//DTD HTML 4.01 Transitional//EN " + DQ$ + ">")
WriteStringN(2,"<html><head>")
WriteStringN(2,"<meta charset=" + DQ$ + "utf-8" + DQ$ + "><title>xRainbow-Project</title>")
WriteStringN(2,"<style>")
WriteStringN(2,"table td {border: 1px solid black; color: Black;}</style>")
WriteStringN(2,"</head><body>")
WriteStringN(2,TableBeg$)
Else
MessageRequester("PureBasic", "Error: can't Create file", 0)
End
EndIf ; CreateFile(2,
EndIf ; FileOpen = 0
LoadHexColor(OneLine$)
LTTD01$ = "<TR><TD style="+DQ$+"height:50px; background-color:#"+TBox02dot$+";"+DQ$+">"+OneLine$+"</TD>"
TD01$ = LTTD01$ + TBox01.s ;+ "</TD>"
WriteStringN(2, TD01$)
OneLine$ = ""
EndProcedure ;FileOut(OneLine$)
Procedure OFile(file.s)
d=ReadFile(1, file)
If d
While Eof(1)=0
Text$ = ReadString(1) ; +Chr(13)+ Chr(10)
OneLine$ = Text$ ; "testing line"+"<br>" ; TableRow
TBox01.s = OneLine$
CountLinesOut+1
FileOut(OneLine$)
If CountLinesOut > 3
Break
EndIf
Wend
CloseFile(1)
WriteStringN(2,"</TABLE></body></html>")
CloseFile(2)
SetGadgetText(2, Text$)
Else
MessageRequester("Error","No valid file was selected.",#MB_ICONERROR)
EndIf
MessageRequester("#Lines Out =",Str(CountLinesOut))
EndProcedure ;OFile(file.s)
If OpenWindow(0, 100, 200, 495, 260, "Open Small Files Example", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
ButtonGadget(1,210,20,80,25,"Open File")
StringGadget(2,10,60,480,185,"",#ES_MULTILINE | #ES_AUTOVSCROLL|#WS_VSCROLL|#WS_HSCROLL)
Repeat
EventID.l = WaitWindowEvent()
If EventID = #PB_Event_CloseWindow
Quit = 1
EndIf
If EventID = #PB_Event_Gadget
Select EventGadget()
Case 1
file$ = "xRainbow-Vera-CommaS.txt"
OFile(file$)
EndSelect
EndIf
Until Quit = 1
EndIf
Endvmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
"All things in moderation , except for love and forgiveness."
Re: How to get a doubleQuote into a string ?
#DQ$ is a constant I defined to keep a shorter name than the existing #DQUOTE$. DQ$ is a string variable. A variable can be changed, the constant cannot(without trickery in a DataSection).vmars316 wrote:Pls, What is the diff between #DQ$ and DQ$ ? Thanks
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: How to get a doubleQuote into a string ?
Aha, when I plugged the #DQ$ in there ,
the doubleQuotes now show up in the html-code
and the TD box is now colored.
Thanks All!..
the doubleQuotes now show up in the html-code
and the TD box is now colored.
Thanks All!..
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
"All things in moderation , except for love and forgiveness."
Re: How to get a doubleQuote into a string ?
vmars316 wrote:I am still having trouble writing DoubleQuotes into Html code.
Hi vmars316. The DQ$ variable did not work because it was utilised within the FileOut() procedure, but declared outside of that scope. It would work if it is declared as a global variable, or a local variable within the procedure itself; like so:vmars316 wrote:Aha, when I plugged the #DQ$ in there, the doubleQuotes now show up in the html-code...
Code: Select all
Define.s OneLines = "Z00,000,FAE0D9"
Define.s TBox02$
Global DQ$ = Chr(34)
...Code: Select all
Procedure FileOut(OneLine$)
Define DQ$ = Chr(34)
...Further, the [$] suffix is a self-declarative string symbol which does not require an explicit string definition; the same way any undefined variable defaults to an integer.
Code: Select all
a = 1 ;a is an integer by default
a$ = "Hello" ;a$ is a string by default
b = "Hello" ;raises error [Trying to write a string into a numerical variable]
b.s = "Hello" ;must be explicitly defined with the string type suffix [.s]Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 
Re: How to get a doubleQuote into a string ?
Hello Vern,
to me the 'TBox02dot$' stays empty (using the code you send me).
To grab each hex-letter (character) one by one and to add them up again is not really necessary as it can be done like this:
In your example I've changed the 'html' line as follows, to color the cell-backgrounds too:
have a nice day ~ cheers Vera 
to me the 'TBox02dot$' stays empty (using the code you send me).
To grab each hex-letter (character) one by one and to add them up again is not really necessary as it can be done like this:
Code: Select all
OneLine$ = "0,0,E6E9FE"
Debug OneLine$
Debug Right(OneLine$, 6)Code: Select all
; LTTD01$ = "<TR><TD style="+#DQ$+"height:50px; background-color:#"+TBox02dot$+";"+#DQ$+">"+OneLine$+"</TD>"
LTTD01$ = "<TR><TD style=" + #DQ$ + "height:20px; background-color:#" + Right(OneLine$, 6) + ";" + #DQ$ + ">" + OneLine$ + "</TD>"
Two growing code-collections: WinApi-Lib by RSBasic ~ LinuxAPI-Lib by Omi
Missing a download-file on the forums? ~ check out this backup page.
Missing a download-file on the forums? ~ check out this backup page.
-
IdeasVacuum
- Always Here

- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: How to get a doubleQuote into a string ?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: How to get a doubleQuote into a string ?
Hey Folks,
I really appreciate your support,
especially when you show 'why/how' things work,
and show 'alternative ways' of doing things.
Thank you...Vern
I really appreciate your support,
especially when you show 'why/how' things work,
and show 'alternative ways' of doing things.
Thank you...Vern
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
"All things in moderation , except for love and forgiveness."

