buffer.inc - For buffering text and dumping all at once

A forum for macro code snippets to be used in writing other macros. Post routines or .inc files here only, completed macros go to the Macro Depot. MQ2Data format only!

Moderator: MacroQuest Developers

notadruid
a ghoul
a ghoul
Posts: 143
Joined: Mon Dec 08, 2003 6:02 pm

buffer.inc - For buffering text and dumping all at once

Post by notadruid » Tue Feb 22, 2005 5:20 pm

Coded primarily so I can do a post-fight report that reports DPS, Resists, Pet DPS, damage taken, DPM, and other data all in one line. What this does is adds subs to add text to a buffer, then add more to it, and intelligently check if it gets too long. ANother sub is to dump it to the screen. Simple and effective.

Code: Select all

|buffer.inc v1.1 by Notadruid
Sub initbuffer(int templength)
	/if (!${Defined[curbuffer]}) /declare curbuffer string outer empty
	/if (!${Defined[bufferlength]}) /declare bufferlength int outer 70
	/if (${Defined[templength]}) /varset bufferlength ${templength}
/return

Sub buffer(string tempbuffer)
	/if (${Defined[tempbuffer]}) {
		/if (${tempbuffer.Length}>=${bufferlength}) {
			/call dumpbuffer
			/varset curbuffer ${tempbuffer}
			/call dumpbuffer
			/return
		}
		/if (${curbuffer.Equal[empty]}) {
			/varset curbuffer ${tempbuffer}
			/return
		}
		/varset curbuffer ${curbuffer}${tempbuffer}
		/if (${curbuffer.Length}>=${bufferlength}) {
			/call dumpbuffer
		}
		/return
	}
	/echo Warning: buffer called without a parameter!
/return

Sub dumpbuffer
	/if (${curbuffer.NotEqual[empty]}) {
		/echo ${curbuffer}
		/varset curbuffer empty
	}
/return
v1.1: Updated to prevent it from generating errors if initbuffer is called twice
I am not a druid.