summaryrefslogtreecommitdiff
path: root/tmplate.bas
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeffrey.armstrong@approximatrix.com>2016-10-11 16:22:25 -0400
committerJeffrey Armstrong <jeffrey.armstrong@approximatrix.com>2016-10-11 16:22:25 -0400
commita0d4ccd465865a4b70be8f4ca254c27f1fd2aaf7 (patch)
tree620febdca086184f7706440c4bda9a4f5e1285af /tmplate.bas
downloadgwblog-a0d4ccd465865a4b70be8f4ca254c27f1fd2aaf7.tar.gz
gwblog-a0d4ccd465865a4b70be8f4ca254c27f1fd2aaf7.zip
Initial commit
Diffstat (limited to 'tmplate.bas')
-rw-r--r--tmplate.bas49
1 files changed, 49 insertions, 0 deletions
diff --git a/tmplate.bas b/tmplate.bas
new file mode 100644
index 0000000..4a4331f
--- /dev/null
+++ b/tmplate.bas
@@ -0,0 +1,49 @@
+100 TMPLATE$ = "TEST.TXT"
+110 DIM LBL$[1]
+120 DIM REPL$[1]
+130 LBL$[1] = "title"
+140 REPL$[1] = "JEFFS BLOG"
+150 ILBL = 1
+160 GOSUB 18000
+165 PRINT TTEXT$
+170 STOP
+18000 REM ============================
+18001 REM Template processing
+18002 REM
+18003 REM INPUT - TMPLATE$ File to open
+18004 REM LBL$ Label array
+18005 REM REPL$ Replacements
+18006 REM ILBL Label array
+18007 REM length
+18008 REM OUTPUT - TTEXT$ Text with
+18009 REM ============================
+18010 OPEN TMPLATE$ FOR INPUT AS #3
+18020 TTEXT$ = ""
+18030 WHILE NOT EOF(3)
+18040 LINE INPUT#3, L$
+18050 GOSUB 18100
+18060 TTEXT$ = TTEXT$ + CHR$(13) + L$
+18070 WEND
+18080 CLOSE #3
+18090 RETURN
+18100 REM Search for key
+18105 IF LEN(L$) < 7 THEN RETURN
+18110 FOR IL = 1 TO LEN(L$)-2
+18120 IF MID$(L$, IL, 3) = "{% " THEN GOSUB 18150:GOTO 18100
+18130 NEXT IL
+18140 RETURN
+18150 REM Find the end of the string
+18160 FOR IJ = IL TO LEN(L$)-2
+18170 IF MID$(L$, IJ, 3) = " %}" THEN GOTO 18200
+18180 NEXT IJ
+18190 RETURN
+18200 REM Attempt replacement
+18210 FOUNDLBL$ = MID$(L$, IL+3, IJ-(IL+3))
+18220 FOR LBLINDEX = 1 TO ILBL
+18230 IF LBL$[LBLINDEX] = FOUNDLBL$ THEN GOTO 18260
+18240 NEXT LBLINDEX
+18250 RETURN
+18260 LNEW$ = LEFT$(L$, IL-1) + REPL$[LBLINDEX] + RIGHT$(L$, LEN(L$)-IJ-2)
+18270 L$ = LNEW$
+18280 RETURN
+ \ No newline at end of file