Test Forum -> code formatting to HTML formatting
1. To format your code in HTML, first use the SPIN -> BB FORUM formatter tool: http://www.phipi.com/format/
2. Post your code into a post somewhere and put the post up on the forums. Then view the page source and locate your code.
3. Copy your code between the < pre > < /pre > tags.
4. With the same original code, use the blogspot CODE -> HTML formatter tool: http://codeformatter.blogspot.com/
5. From the HTML from step 4, replace everything between the <pre> tags with the copied code from step 3
The advantage of this is that your HTML code post now has basic (ie bold keywords) code formatting.
Example forum post that has code from phipi code format:
___________________________________________________________________
2. Post your code into a post somewhere and put the post up on the forums. Then view the page source and locate your code.
3. Copy your code between the < pre > < /pre > tags.
4. With the same original code, use the blogspot CODE -> HTML formatter tool: http://codeformatter.blogspot.com/
5. From the HTML from step 4, replace everything between the <pre> tags with the copied code from step 3
The advantage of this is that your HTML code post now has basic (ie bold keywords) code formatting.
Example forum post that has code from phipi code format:
___________________________________________________________________
'' From Parallax Inc. Propeller Education Kit - Objects Lab v1.1
{{
────────────────────────────────────────────────────────────────────────────────────────
File: FullDuplexSerialPlus.spin
Version: 1.1
Copyright (c) 2008 Parallax, Inc.
See end of file for terms of use.
This is the FullDuplexSerial object v1.1 [b]from[/b] the Propeller Tool's Library
folder with modified documentation [b]and[/b] methods for converting text strings
into numeric values in several bases.
────────────────────────────────────────────────────────────────────────────────────────
Note: used by Anzhelka project
}}
[b]CON[/b] ''
''Parallax Serial Terminal Control Character Constants
''────────────────────────────────────────────────────
HOME = 1 ''HOME = 1
CRSRXY = 2 ''CRSRXY = 2
CRSRLF = 3 ''CRSRLF = 3
CRSRRT = 4 ''CRSRRT = 4
CRSRUP = 5 ''CRSRUP = 5
CRSRDN = 6 ''CRSRDN = 6
BELL = 7 ''BELL = 7
BKSP = 8 ''BKSP = 8
TAB = 9 ''TAB = 9
LF = 10 ''LF = 10
CLREOL = 11 ''CLREOL = 11
CLRDN = 12 ''CLRDN = 12
CR = 13 ''CR = 13
CRSRX = 14 ''CRSRX = 14
CRSRY = 15 ''CRSRY = 15
CLS = 16 ''CLS = 16
[b]VAR[/b]
[b]long[/b] cog 'cog flag/id
[b]long[/b] rx_head '9 contiguous longs
[b]long[/b] rx_tail
[b]long[/b] tx_head
[b]long[/b] tx_tail
[b]long[/b] rx_pin
[b]long[/b] tx_pin
[b]long[/b] rxtx_mode
[b]long[/b] bit_ticks
[b]long[/b] buffer_ptr
[b]byte[/b] rx_buffer[*16] 'transmit and receive buffers
[b]byte[/b] tx_buffer[*16]
[b]PUB[/b] start(rxpin, txpin, mode, baudrate) : okay
{{
Starts serial driver in a new cog
rxpin - input receives signals [b]from[/b] peripheral's TX pin
txpin - output sends signals to peripheral's RX pin
mode - bits in this variable configure signaling
bit 0 inverts rx
bit 1 inverts tx
bit 2 open drain/source tx
bit 3 ignor tx echo on rx
baudrate - bits per second
okay - returns [b]false[/b] [b]if[/b] no cog is available.
}}
stop
[b]longfill[/b](@rx_head, 0, 4)
[b]longmove[/b](@rx_pin, @rxpin, 3)
bit_ticks := clkfreq / baudrate
buffer_ptr := @rx_buffer
okay := cog := [b]cognew[/b](@entry, @rx_head) + 1
[b]PUB[/b] stop
'' Stops serial driver - frees a cog
[b]if[/b] cog
[b]cogstop[/b](cog~ - 1)
[b]longfill[/b](@rx_head, 0, 9)
[b]PUB[/b] tx(txbyte)
'' Sends byte (may wait for room in buffer)
[b]repeat[/b] [b]until[/b] (tx_tail <> (tx_head + 1) & $F)
tx_buffer[*tx_head] := txbyte
tx_head := (tx_head + 1) & $F
[b]if[/b] rxtx_mode & %1000
rx
[b]PUB[/b] rx : rxbyte
'' Receives byte (may wait for byte)
'' rxbyte returns $00..$FF
[b]repeat[/b] [b]while[/b] (rxbyte := rxcheck) < 0
[b]PUB[/b] rxflush
'' Flush receive buffer
[b]repeat[/b] [b]while[/b] rxcheck => 0
[b]PUB[/b] rxcheck : rxbyte
'' Check if byte received (never waits)
'' rxbyte returns -1 if no byte received, $00..$FF if byte
rxbyte--
[b]if[/b] rx_tail <> rx_head
rxbyte := rx_buffer[*rx_tail]
rx_tail := (rx_tail + 1) & $F
[b]PUB[/b] rxtime(ms) : rxbyte | t
'' Wait ms milliseconds for a byte to be received
'' returns -1 if no byte received, $00..$FF if byte
t := [b]cnt[/b]
[b]repeat[/b] [b]until[/b] (rxbyte := rxcheck) => 0 [b]or[/b] ([b]cnt[/b] - t) / (clkfreq / 1000) > ms
[b]PUB[/b] [b]str[/b](stringptr)
'' Send zero terminated string that starts at the stringptr memory address
[b]repeat[/b] [b]strsize[/b](stringptr)
tx([b]byte[/b][*stringptr++])
[b]PUB[/b] getstr(stringptr) | index
'' Gets zero terminated string and stores it, starting at the stringptr memory address
index~
[b]repeat[/b] [b]until[/b] (([b]byte[/b][*stringptr][*index++] := rx) == 13)
[b]byte[/b][*stringptr][*--index]~
[b]PUB[/b] dec(value) | i
'' Prints a decimal number
[b]if[/b] value < 0
-value
tx("-")
i := 1_000_000_000
[b]repeat[/b] 10
[b]if[/b] value => i
tx(value / i + "0")
value //= i
[b]result[/b]~~
[b]elseif[/b] [b]result[/b] [b]or[/b] i == 1
tx("0")
i /= 10
[b]PUB[/b] GetDec : value | tempstr[*11]
'' Gets decimal character representation of a number from the terminal
'' Returns the corresponding value
GetStr(@tempstr)
value := StrToDec(@tempstr)
[b]PUB[/b] StrToDec(stringptr) : value | char, index, multiply
'' Converts a zero terminated string representation of a decimal number to a value
value := index := 0
[b]repeat[/b] [b]until[/b] ((char := [b]byte[/b][*stringptr][*index++]) == 0)
[b]if[/b] char => "0" [b]and[/b] char =< "9"
value := value * 10 + (char - "0")
[b]if[/b] [b]byte[/b][*stringptr] == "-"
value := - value
[b]PUB[/b] bin(value, digits)
'' Sends the character representation of a binary number to the terminal.
value <<= 32 - digits
[b]repeat[/b] digits
tx((value <-= 1) & 1 + "0")
[b]PUB[/b] GetBin : value | tempstr[*11]
'' Gets binary character representation of a number from the terminal
'' Returns the corresponding value
GetStr(@tempstr)
value := StrToBin(@tempstr)
[b]PUB[/b] StrToBin(stringptr) : value | char, index
'' Converts a zero terminated string representaton of a binary number to a value
value := index := 0
[b]repeat[/b] [b]until[/b] ((char := [b]byte[/b][*stringptr][*index++]) == 0)
[b]if[/b] char => "0" [b]and[/b] char =< "1"
value := value * 2 + (char - "0")
[b]if[/b] [b]byte[/b][*stringptr] == "-"
value := - value
[b]PUB[/b] hex(value, digits)
'' Print a hexadecimal number
value <<= (8 - digits) << 2
[b]repeat[/b] digits
tx([b]lookupz[/b]((value <-= 4) & $F : "0".."9", "A".."F"))
[b]PUB[/b] GetHex : value | tempstr[*11]
'' Gets hexadecimal character representation of a number from the terminal
'' Returns the corresponding value
GetStr(@tempstr)
value := StrToHex(@tempstr)
[b]PUB[/b] StrToHex(stringptr) : value | char, index
'' Converts a zero terminated string representaton of a hexadecimal number to a value
value := index := 0
[b]repeat[/b] [b]until[/b] ((char := [b]byte[/b][*stringptr][*index++]) == 0)
[b]if[/b] (char => "0" [b]and[/b] char =< "9")
value := value * 16 + (char - "0")
[b]elseif[/b] (char => "A" [b]and[/b] char =< "F")
value := value * 16 + (10 + char - "A")
[b]elseif[/b](char => "a" [b]and[/b] char =< "f")
value := value * 16 + (10 + char - "a")
[b]if[/b] [b]byte[/b][*stringptr] == "-"
value := - value
[b]DAT[/b]
'***********************************
'* Assembly language serial driver *
'***********************************
[b]org[/b]
'
'
' Entry
'
entry [b]mov[/b] t1,[b]par[/b] 'get structure address
[b]add[/b] t1,#4 << 2 'skip past heads and tails
[b]rdlong[/b] t2,t1 'get rx_pin
[b]mov[/b] rxmask,#1
[b]shl[/b] rxmask,t2
[b]add[/b] t1,#4 'get tx_pin
[b]rdlong[/b] t2,t1
[b]mov[/b] txmask,#1
[b]shl[/b] txmask,t2
[b]add[/b] t1,#4 'get rxtx_mode
[b]rdlong[/b] rxtxmode,t1
[b]add[/b] t1,#4 'get bit_ticks
[b]rdlong[/b] bitticks,t1
[b]add[/b] t1,#4 'get buffer_ptr
[b]rdlong[/b] rxbuff,t1
[b]mov[/b] txbuff,rxbuff
[b]add[/b] txbuff,#16
[b]test[/b] rxtxmode,#%100 [b]wz[/b] 'init tx pin according to mode
[b]test[/b] rxtxmode,#%010 [b]wc[/b]
[b]if_z_ne_c[/b] [b]or[/b] [b]outa[/b],txmask
[b]if_z[/b] [b]or[/b] [b]dira[/b],txmask
[b]mov[/b] txcode,#transmit 'initialize ping-pong multitasking
'
'
' Receive
'
receive [b]jmpret[/b] rxcode,txcode 'run chunk of tx code, then return
[b]test[/b] rxtxmode,#%001 [b]wz[/b] 'wait for start bit on rx pin
[b]test[/b] rxmask,[b]ina[/b] [b]wc[/b]
[b]if_z_eq_c[/b] [b]jmp[/b] #receive
[b]mov[/b] rxbits,#9 'ready to receive byte
[b]mov[/b] rxcnt,bitticks
[b]shr[/b] rxcnt,#1
[b]add[/b] rxcnt,[b]cnt[/b]
:bit [b]add[/b] rxcnt,bitticks 'ready next bit period
:wait [b]jmpret[/b] rxcode,txcode 'run chunk of tx code, then return
[b]mov[/b] t1,rxcnt 'check if bit receive period done
[b]sub[/b] t1,[b]cnt[/b]
[b]cmps[/b] t1,#0 [b]wc[/b]
[b]if_nc[/b] [b]jmp[/b] #:wait
[b]test[/b] rxmask,[b]ina[/b] [b]wc[/b] 'receive bit on rx pin
[b]rcr[/b] rxdata,#1
[b]djnz[/b] rxbits,#:bit
[b]shr[/b] rxdata,#32-9 'justify and trim received byte
[b]and[/b] rxdata,#$FF
[b]test[/b] rxtxmode,#%001 [b]wz[/b] 'if rx inverted, invert byte
[b]if_nz[/b] [b]xor[/b] rxdata,#$FF
[b]rdlong[/b] t2,[b]par[/b] 'save received byte and inc head
[b]add[/b] t2,rxbuff
[b]wrbyte[/b] rxdata,t2
[b]sub[/b] t2,rxbuff
[b]add[/b] t2,#1
[b]and[/b] t2,#$0F
[b]wrlong[/b] t2,[b]par[/b]
[b]jmp[/b] #receive 'byte done, receive next byte
'
'
' Transmit
'
transmit [b]jmpret[/b] txcode,rxcode 'run chunk of rx code, then return
[b]mov[/b] t1,[b]par[/b] 'check for head <> tail
[b]add[/b] t1,#2 << 2
[b]rdlong[/b] t2,t1
[b]add[/b] t1,#1 << 2
[b]rdlong[/b] t3,t1
[b]cmp[/b] t2,t3 [b]wz[/b]
[b]if_z[/b] [b]jmp[/b] #transmit
[b]add[/b] t3,txbuff 'get byte and inc tail
[b]rdbyte[/b] txdata,t3
[b]sub[/b] t3,txbuff
[b]add[/b] t3,#1
[b]and[/b] t3,#$0F
[b]wrlong[/b] t3,t1
[b]or[/b] txdata,#$100 'ready byte to transmit
[b]shl[/b] txdata,#2
[b]or[/b] txdata,#1
[b]mov[/b] txbits,#11
[b]mov[/b] txcnt,[b]cnt[/b]
:bit [b]test[/b] rxtxmode,#%100 [b]wz[/b] 'output bit on tx pin
[b]test[/b] rxtxmode,#%010 [b]wc[/b] 'according to mode
[b]if_z_and_c[/b] [b]xor[/b] txdata,#1
[b]shr[/b] txdata,#1 [b]wc[/b]
[b]if_z[/b] [b]muxc[/b] [b]outa[/b],txmask
[b]if_nz[/b] [b]muxnc[/b] [b]dira[/b],txmask
[b]add[/b] txcnt,bitticks 'ready next cnt
:wait [b]jmpret[/b] txcode,rxcode 'run chunk of rx code, then return
[b]mov[/b] t1,txcnt 'check if bit transmit period done
[b]sub[/b] t1,[b]cnt[/b]
[b]cmps[/b] t1,#0 [b]wc[/b]
[b]if_nc[/b] [b]jmp[/b] #:wait
[b]djnz[/b] txbits,#:bit 'another bit to transmit?
[b]jmp[/b] #transmit 'byte done, transmit next byte
'
'
' Uninitialized data
'
t1 [b]res[/b] 1
t2 [b]res[/b] 1
t3 [b]res[/b] 1
rxtxmode [b]res[/b] 1
bitticks [b]res[/b] 1
rxmask [b]res[/b] 1
rxbuff [b]res[/b] 1
rxdata [b]res[/b] 1
rxbits [b]res[/b] 1
rxcnt [b]res[/b] 1
rxcode [b]res[/b] 1
txmask [b]res[/b] 1
txbuff [b]res[/b] 1
txdata [b]res[/b] 1
txbits [b]res[/b] 1
txcnt [b]res[/b] 1
txcode [b]res[/b] 1
{{
┌──────────────────────────────────────────────────────────────────────────────────────┐
│ TERMS OF USE: MIT License │
├──────────────────────────────────────────────────────────────────────────────────────┤
│Permission is hereby granted, free of charge, to any person obtaining a copy of this │
│software [b]and[/b] associated documentation files (the "Software"), to deal in the Software │
│without restriction, including without limitation the rights to use, copy, modify, │
│merge, publish, distribute, sublicense, [b]and[/b]/[b]or[/b] sell copies of the Software, [b]and[/b] to │
│permit persons to whom the Software is furnished to do so, subject to the following │
│conditions: │ │
│ │ │
│The above copyright notice [b]and[/b] this permission notice shall be included in all copies │
│[b]or[/b] substantial portions of the Software. │
│ │ │
│THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS [b]OR[/b] IMPLIED, │
│INCLUDING BUT [b]NOT[/b] LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A │
│PARTICULAR PURPOSE [b]AND[/b] NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS [b]OR[/b] COPYRIGHT │
│HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES [b]OR[/b] [b]OTHER[/b] LIABILITY, WHETHER IN AN ACTION │
│OF CONTRACT, TORT [b]OR[/b] OTHERWISE, ARISING [b]FROM[/b], OUT OF [b]OR[/b] IN CONNECTION WITH THE │
│SOFTWARE [b]OR[/b] THE USE [b]OR[/b] [b]OTHER[/b] DEALINGS IN THE SOFTWARE. │
└──────────────────────────────────────────────────────────────────────────────────────┘
}}

Comments
I don't think that works right anymore. Look at your subscripts. I need to revisit the code formater to be compatible with the new forum.
-Phil
Also, I notice that the phipi.com/format will format keywords inside of comments, eg "from" and "and" in the above FullDuplexSerialPlus.spin
Edit: Ah, you mean the subscripts in with the square brackets []? Yes, they do seem to be a bit off.
Edit: this is my post where I can paste my code...