Skip to content

Instantly share code, notes, and snippets.

@hpcorona
Created October 28, 2011 21:16
Show Gist options
  • Save hpcorona/1323588 to your computer and use it in GitHub Desktop.
Save hpcorona/1323588 to your computer and use it in GitHub Desktop.
PROCEDURE TemplateBuild(LOCAL sTemplate is string, Variables is assosiative array of strings)
sOpenBrace is string = "${"
sCloseBrace is string = "}"
sNewStr is string = ""
nUPos is int = 1
nPos is int
nPos = Position(sTemplate,sOpenBrace)
nFin is int
WHILE nPos >= 1
sNewStr += sTemplate[[nUPos TO nPos - 1]]
nFin = Position(sTemplate,sCloseBrace,nPos)
sNewStr += Variables[sTemplate[[nPos + Length(sOpenBrace) TO nFin - 1]]]
nUPos = nFin + Length(sCloseBrace)
nPos = Position(sTemplate,sOpenBrace,nUPos)
END
sNewStr += sTemplate[[nUPos TO]]
RESULT sNewStr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment