TiddlyWiki very handy for generating code in any programming language

56 views
Skip to first unread message

Charlie Veniot

unread,
Aug 12, 2023, 1:25:28 AM8/12/23
to TiddlyWiki
Just an example of a macro to generate lines of BASIC code.

Results first, followed by the code.

Results
Screenshot 2023-08-12 2.20.28 AM.png
Code (if viewing in Google Groups, ignore the leading and trailing triple-backticks)
```
\define AREA(string)

<$let points="$string$"
         count={{{ [[$string$]split[ - ]] +[count[]] }}}>

<$list variable="element" filter="[range[1],<count>]">
<$text text={{{ [<element>match[1]then<points>split[ - ]nth[1]addprefix[PSET ]] +[addsuffix[ : AreaStartX = POINT(0) : AreaStartY = POINT(1)]]  }}}/>
<$text text={{{ [<element>!match[1]then<points>split[ - ]nth<element>addprefix[LINE - ]] }}}/><br>
</$list>
LINE - (AreaStartX, AreaStartY)

</$let>

\end

<Main 🟠🟠🟠>

`<<AREA "(25,10) - (50,20) - (0,20)">>`
<<AREA "(25,10) - (50,20) - (0,20)">>

`<<AREA "(50,25) - STEP (20,15) - STEP (-10,15) - STEP (-10,-10)">>`
<<AREA "(50,25) - STEP (20,15) - STEP (-10,15) - STEP (-10,-10)">>
```
Reply all
Reply to author
Forward
0 new messages