User:Db2wiki

From GrunchWiki
Jump to navigation Jump to search
/* $VER: db2wiki 0.3 $
 * Convert a whole database in small wiki files
 * rx db2wiki.rexx <Grunch_MorphOS.db
 * © Stefan Haubenthal 2011
 */

do forever
	call open(file, "db2wiki", W)
	item=process_item()
	call writeln(file, "0a"x"[[Category:"apptype"]]")
	call close(file)
	address command rename "db2wiki" item
	say item
end
exit

process_item:
isitem=1
do while isitem
	if eof(stdin) then exit
	parse pull type line
	if abbrev(type, ";") then
		do
		call writeln(file, ""type""line)
		iterate
		end
	if type=## then
		do
		parse var line cmd arg args
		if cmd="ITEM" & arg~="END" then item=arg
		if cmd="APPTYPE" then apptype=strip(arg, , '"')
		if cmd="DEPENDENCIES" then
			do
				line=" "cmd
				do i=1 to words(arg args)
					line=line '"[['strip(word(arg args, i), , '"')']]"'
				end
			end
		if line="ITEM END" then isitem=0
		call writeln(file, "*"type""line)
		end
	else call writeln(file, " "type||line)
end
return item