Fixed Text In ASMDATA

Demo Source Code

(What it does, and code section "how" or "why" remarks stay in source code comments for now. Going to be busy using it myself.)

'Fixed text in ASMDATA block(s).
'
'Particularly useful for instructions/help and license statements. It may seem
'more needed by PBWin for TEXTBOXes and LABALs, but in PBCC might be for
'writing to files, to TCP for CGI (Common Gateway Interface) HTML (HyperText
'Markup Language) and CSS (Cascading Style Sheet) sections.
'
'For short things like button tops, I find string literals or equates
'satisfactory but . . .
'
'A disadvantage of string equates is the 255 character limit on ANSI (8 bit)
'strings, and 127 character limit on wide (16 bit) strings. A work-around is
'$$Text1=, and $$Text2, etcetera; then BUILD$($$Text1, $$Text2) in procedure or
'statement. The intent here is to not quess when to start a new equate, and to
'eliminate BUILD$() from run-time code. (Again, speed not everything; but why
'not when faster is so easy?) With ASMDATA just add another DW line to avoid
'right scrolling the IDE. (DB for ANSI, but IMO you should get used to WIDE.)
'((Don't "get" DW or DB, see Help for ASMDATA))
'
'Putting ASMDATA {label} code pointer plus 4 in the WSTRING VARPTR() puts the
'WSTRING's first character location there (what STRPTR() returns).
'
'Sometimes during tests I was getting asian characters instead of the Latin
'based ones. #ALIGN 2 fixed that. Had not noticed a problem with string size
'being mis-read, but changed to #ALIGN 4.
'
'It was ignoring string size in MSGBOX tests. "Ding", MessageBox API takes "Z"
'strings. Put a $$NUL at the end (not counted in string size); and switched to
'TXT.WINDOW. Allows this demo to run in PBCC too.
'
'Comments thread:
'
'My web page for this (may have extended comments/explanation (someday)):
' http://www.yarker-dsyc2023/D_Notebook/Programs/Ancillary/TextInASMDATA.html
'
'!!!!!!!!!!!!!! A STRING WITH POINTER SET TO ASMDATA IS READ ONLY !!!!!!!!!!!!!!
'                          DO NOT ATTEMPT TO CHANGE
'[code]
'demo - Text stored in ASMDATA
'(no loading into string variable to use)
#compile exe
#dim all
#if %def(%pb_cc32) 'will be ignored in PBWin
  #console off     'no uneeded console in PBCC
#endif
function pbmain () as long
  local MyStr as wstring
  local hTWin as dword
  txt.window "", 100, 100, 20, 80 to hTWin
  poke dword, varptr(MyStr), codeptr(LargeStr) + 4
  txt.print MyStr
  txt.print
  txt.print "CRLFs are ignored by TXT.WINDOW. They still count for two "
  txt.print "characters each in string length (and could be needed for "
  txt.print "formating elsewhere). "
  txt.print : txt.color = &h000000E0
  poke dword, varptr(MyStr), codeptr(ExitHint) + 4
  txt.print MyStr
  txt.waitkey$
  txt.end
end function
'Next lines are 100 characters (not counting the leading apostrophe).
'The quick brown fox jumps over the lazy dog's back. 0123456789 How now brown cow? Sule benim karim.[
'The quick brown fox jumps over the lazy dog's back. 0123456789 How now brown cow? Sule'yi seviyorum!
'The quick brown fox jumps over the lazy dog's back. 0123456789 How now brown cow? @#$%^&  is300 no304
  #align 4
asmdata LargeStr
  dd 610 '305 wide characters (8 bytes for two embedded CRLFs, two for a space)
  dw "The quick brown fox jumps over the lazy dog's back. 0123456789 How now "$$
  dw "brown cow? ", chr$$(&h015E, "ule benim kar"$$, &h0131, "m.["$$), $$crlf
  dw "The quick brown fox jumps over the lazy dog's back. 0123456789 How now "$$
  dw "brown cow? ", chr$$(&h015E, "ule'yi seviyorum!"$$), $$crlf, "The quick "$$
  dw "brown fox jumps over the lazy dog's back. 0123456789 How now brown "$$
  dw "cow? @#$%^&  is300 no304"$$ + $$nul
end asmdata
'((The "fox" is an early typing practice line. I first show it with the digits
'added as a teleprinter test. It has all letters of English alphabet, number
'characters, and multiple letters and figures shifts. The "brown cow" was very
'early slang for "does the beer barrel still have beer in it?"; later an
'elocution practice line. Slipped in about wife to get a couple characters
'above 255, and use CHR$$().))
'
asmdata ExitHint
  dd 42
  dw "any key to exit . . ." 'cuz I could, and show multiples in one app
end asmdata

Created on 17 October 2023

To Domain Home.

home
To Dale's Notebook index.
notebook
To Programs index.
programs