Page 1 of 1

Code window in forum posts

Posted: Tue Feb 23, 2021 1:31 pm
by PeterN
Hi CiccioCB,

fortunately you found a possibility to include the code=annex window in the forum.
That works best with short code snippets, but finds its limmitations in readabylity if the code has more than 100 lines.
In the old forum we could paste the syntax-colored code with its window hight from the toolkit. That is not supportet by bbCode now.

I did not find a hint for a solution at my first quick internet search.

Re: Code window in forum posts

Posted: Tue Feb 23, 2021 5:12 pm
by cicciocb
Hi Peter,
I experimented with the addition of another bbcode

I included [height=xxx] [/height] to limit the height of the text.

For that you can include this around the [code) bbcode.

Example of code as before

Code: [Local Link Removed for Guests]

onhtmlchange changeme
DTMF "0"

wait

freq:
print counter.freq(1), counter.freq(2)
return

butpress:
print "butpress", HtmlEventButton$
DTMF HtmlEventButton$
return

changeme:
print "changeme", HtmlEventVar$
return

sub DTMF(sim$)
  local z
  for z = 0 to 15
    if (SYMB$(z) = ucase$(sim$)) then
      pin.tone pin_T1, cols(z and 3)
      pin.tone pin_T2, rows(z >> 2)
      pause 2500 ' duration of the tone
      pin.tone pin_T1, 0
      pin.tone pin_T2, 0
      exit for
    end if
  next z
end sub
And the same limited to 200 pixels

Code: [Local Link Removed for Guests]

onhtmlchange changeme
DTMF "0"

wait

freq:
print counter.freq(1), counter.freq(2)
return

butpress:
print "butpress", HtmlEventButton$
DTMF HtmlEventButton$
return

changeme:
print "changeme", HtmlEventVar$
return

sub DTMF(sim$)
  local z
  for z = 0 to 15
    if (SYMB$(z) = ucase$(sim$)) then
      pin.tone pin_T1, cols(z and 3)
      pin.tone pin_T2, rows(z >> 2)
      pause 2500 ' duration of the tone
      pin.tone pin_T1, 0
      pin.tone pin_T2, 0
      exit for
    end if
  next z
end sub
Another solution could be to limit automatically at a given height.
This is probably the best choice but I need to investigate how do it (probably in the php code)

Re: Code window in forum posts

Posted: Tue Feb 23, 2021 5:38 pm
by PeterN
Ah!!
Thanks, the [height=xxx] [/height] does the job perfect!!