MaxScipt to html

Hi,
im atm making a little script to convert maxscipt files to html formating so they look the exact same way as in the MS editor after seing many ppl complain and much unreadable code. Works all well and easy,
only question i got is: how would you like to interface it?
what would your preffered workflow be to convert a MS script to html?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Graph's picture

--this is what i got so far,

--this is what i got so far, have fun

(
 
 
	local filePath = "C:\\Program Files\\Autodesk\\3ds Max 2010\\Scripts\\INTools\\MStoHTML.ms"
 
 
	clearListener()
 
	--sort the coloring functions in such a way that the shortest come last
 
	--seperarte UI and other stuff
	--
 
 
	fn addTabs text = 
	(
		local res =""
		local theArr = filterString text "\t" splitEmptyTokens:true
 
		for i in theArr do res += (i+"    ")
 
		res
	)
 
 
	fn addCommentsColor text = 
	(
		local res =""
		local fString = "--"
		local found = findString text fString
 
		if found != undefined then
		(
			res += replace text found fString.count ("<font color=\"#017f01\"><i>"+fString)
			res += "</i></font>"
		)else
		(
			res = text
		)
		res
	)	
 
 
	-------------------------------------
	-------------------------------------
	fn addLOCALColor text =
	(
		local res =""
		local fString = "local"
		local found = findString text fString
 
		if found != undefined then
		(
			res += replace text found fString.count ("<font color=\"#00007e\"><b>"+fString+"</b></font>")
		)else
		(res = text)
		res
	)
 
	fn addGLOBALColor text =
	(
		local res =""
		local fString = "global"
		local found = findString text fString
 
		if found != undefined then
		(
			res += replace text found fString.count ("<font color=\"#00007e\"><b>"+fString+"</b></font>")
		)else
		(res = text)
		res
	)
 
	fn addIFColor text =
	(
		local res =""
		local fString = "if"
		local found = findString text fString
 
		if found != undefined then
		(
			res += replace text found fString.count ("<font color=\"#00007e\"><b>"+fString+"</b></font>")
		)else
		(res = text)
		res
	)
 
	fn addTHENColor text =
	(
		local res =""
		local fString = "then"
		local found = findString text fString
 
		if found != undefined then
		(
			res += replace text found fString.count ("<font color=\"#00007e\"><b>"+fString+"</b></font>")
		)else
		(res = text)
		res
	)
 
	fn addELSEColor text =
	(
		local res =""
		local fString = "else"
		local found = findString text fString
 
		if found != undefined then
		(
			res += replace text found fString.count ("<font color=\"#00007e\"><b>"+fString+"</b></font>")
		)else
		(res = text)
		res
	)
 
	fn addDOColor text =
	(
		local res =""
		local fString = "do"
		local found = findString text fString
 
		if found != undefined then
		(
			res += replace text found fString.count ("<font color=\"#00007e\"><b>"+fString+"</b></font>")
		)else
		(res = text)
		res
	)
 
	fn addUNDOColor text =
	(
		local res =""
		local fString = "undo"
		local found = findString text fString
 
		if found != undefined then
		(
			res += replace text found fString.count ("<font color=\"#00007e\"><b>"+fString+"</b></font>")
		)else
		(res = text)
		res
	)
 
	fn addFORColor text =
	(
		local res =""
		local fString = "for"
		local found = findString text fString
 
		if found != undefined then
		(
			res += replace text found fString.count ("<font color=\"#00007e\"><b>"+fString+"</b></font>")
		)else
		(res = text)
		res
	)
 
	fn addINColor text =
	(
		local res =""
		local fString = "in"
		local found = findString text fString
 
		if found != undefined then
		(
			res += replace text found fString.count ("<font color=\"#00007e\"><b>"+fString+"</b></font>")
		)else
		(res = text)
		res
	)
 
 
	-----------------UI ITEMS
	---------------------------
	fn addBUTTONColor text =
	(
		local res =""
		local fString = "BUTTON"
		local found = findString text fString
 
		if found != undefined then
		(
			res += replace text found fString.count ("<font color=\"#000000\"><b>"+fString+"</b></font>")
		)else
		(res = text)
		res  
	)
 
	fn addSLIDERColor text =
	(
		local res =""
		local fString = "SLIDER"
		local found = findString text fString
 
		if found != undefined then
		(
			res += replace text found fString.count ("<font color=\"#000000\"><b>"+fString+"</b></font>")
		)else
		(res = text)
		res  
	)
 
	fn addSPINNERColor text =
	(
		local res =""
		local fString = "SPINNER"
		local found = findString text fString
 
		if found != undefined then
		(
			res += replace text found fString.count ("<font color=\"#000000\"><b>"+fString+"</b></font>")
		)else
		(res = text)
		res  
	)
 
	fn addPICKBUTTONColor text =
	(
		local res =""
		local fString = "PICKBUTTON"
		local found = findString text fString
 
		if found != undefined then
		(
			res += replace text found fString.count ("<font color=\"#000000\"><b>"+fString+"</b></font>")
		)else
		(res = text)
		res  
	)
 
	fn addSUBROLLOUTColor text =
	(
		local res =""
		local fString = "SUBROLLOUT"
		local found = findString text fString
 
		if found != undefined then
		(
			res += replace text found fString.count ("<font color=\"#000000\"><b>"+fString+"</b></font>")
		)else
		(res = text)
		res  
	)
 
	fn addCHECKBUTTONColor text =
	(
		local res =""
		local fString = "CHECKBUTTON"
		local found = findString text fString
 
		if found != undefined then
		(
			res += replace text found fString.count ("<font color=\"#000000\"><b>"+fString+"</b></font>")
		)else
		(res = text)
		res  
	)
 
	fn addLABELColor text =
	(
		local res =""
		local fString = "LABEL"
		local found = findString text fString
 
		if found != undefined then
		(
			res += replace text found fString.count ("<font color=\"#000000\"><b>"+fString+"</b></font>")
		)else
		(res = text)
		res  
	)
 
 
 
	local theFile = openFile filePath mode:"r"
 
	seek theFile #eof
	local maxlen=filepos theFile
	seek theFile 0
 
	local theMSText = (readChars theFile maxlen errorAtEOF:false) as string
 
 
	local res = "" --"<code>"
	local theLines = filterString theMSText "\n" splitEmptyTokens:true
 
	for i in theLines do 
	(
		--COLORING
		i = addCHECKBUTTONColor i	
		i = addSUBROLLOUTColor i
		i = addPICKBUTTONColor i
		i = addSPINNERColor i
		i = addBUTTONColor i
		i = addGLOBALColor i
		i = addSLIDERColor i
		i = addLOCALColor i
		i = addUNDOColor i
		i = addLABELColor i
		i = addTHENColor i
		i = addELSEColor i
		i = addFORColor i
		i = addDOColor i
		i = addIFColor i
		i = addINColor i
-- 			i = addASColor i
 
 
 
		i = addCommentsColor i  --make multiLine comments first
 
		i = addTabs i
 
		res += (i+"\n<br>")
	)
	--res += "

"

setclipboardText res
--print res
--theMSText = addLineBreaks theMSText

-- theLines

)

Raphael Steves

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.