GFreak45
I didnt slap you, i high 5'd your face.
- Reaction score
- 130
ok so heres my problem, im trying to create a data sorting system, and im having issues with my remove function
it uses 2 text macros to be implemented properly, i have included an example, i am posting the actual system, but im not looking for a critique on it, it is just the beginning and is nowhere near done, i just wanted to know what the problem is with static ifs, can textmacros not have static ifs inside? do the booleans for static ifs need to be defined before compile?
the error i get is: expected a name for the line: else
heres the code:
example:
system:
it uses 2 text macros to be implemented properly, i have included an example, i am posting the actual system, but im not looking for a critique on it, it is just the beginning and is nowhere near done, i just wanted to know what the problem is with static ifs, can textmacros not have static ifs inside? do the booleans for static ifs need to be defined before compile?
the error i get is: expected a name for the line: else
heres the code:
example:
JASS:
//! runtextmacro STDConstant("integer")
struct Example extends array
//! runtextmacro STD("thisUnit", "unit", "private", "kills", "integer", "private")
endstruct
system:
JASS:
/*
S.T.D.
Sort Titanic Data, stores vast ammounts of data in a sorted linked list allowing you to accurately sort vast datatypes and ammounts of data
*/
library STD
//! textmacro STDConstant takes VARTYPE
function $VARTYPE$_Number takes nothing returns boolean
return "$VARTYPE$" == "integer" or "$VARTYPE$" == "real" or "$VARTYPE$" == "unittype" or "$VARTYPE$" == "ability"
endfunction
//! endtextmacro
//! textmacro STD takes VARNAMEBASE, VARTYPEBASE, VISIBILITYBASE, VARNAME, VARTYPE, VISIBILITY
$VISIBILITYBASE$ $VARTYPEBASE$ $VARNAMEBASE$
$VISIBILITY$ $VARTYPE$ $VARNAME$
private integer basePosition
private integer next
private integer previous
private static integer array recycleList
private static integer lastRecycled
private static integer listCount
private static integer listSize
static method allocation takes nothing returns thistype
local thistype this = .recycleList[0]
if this == 0 then
debug if .listCount >= 8190 then
debug call BJDebugMsg("STD ERROR: Attempting to add another set of data higher than the max")
debug return 0
debug endif
set .listCount = .listCount + 1
set thistype(.listCount).basePosition = .listCount
return .listCount
endif
set thistype(thistype(0).previous).next = this
set thistype(0).previous = this
set .listSize = .listSize + 1
set this.basePosition = .listSize
return this
endmethod
static method deallocate takes integer i returns nothing
set thistype(thistype(i).previous).next = thistype(i).next
set thistype(thistype(i).next).previous = thistype(i).previous
set .recycleList[.lastRecycled] = i
set .lastRecycled = i
set .listSize = .listSize - 1
endmethod
static method sortThis takes integer a returns integer
local thistype this = a
local boolean bool = false
loop
exitwhen bool
if thistype(this.next).$VARNAME$ >= this.$VARNAME$ then
set this.basePosition = this.basePosition + 1
set thistype(this.next).basePosition = thistype(this.next).basePosition - 1
set thistype(this.previous).next = this.next
set thistype(this.next).previous = this.previous
set this.previous = this.next
set this.next = thistype(this.next).next
set thistype(this.previous).next = this
call thistype.sortThis(this.previous)
elseif thistype(this.previous).$VARNAME$ <= this.$VARNAME$ then
set this.basePosition = this.basePosition - 1
set thistype(this.previous).basePosition = thistype(this.previous).basePosition + 1
set thistype(this.next).previous = this.previous
set thistype(this.previous).next = this.next
set this.next = this.previous
set this.previous = thistype(this.previous).previous
set thistype(this.next).previous = this
call thistype.sortThis(this.next)
endif
if this.$VARNAME$ <= thistype(this.next).$VARNAME$ and this.$VARNAME$ >= thistype(this.previous).$VARNAME$ then
set bool = true
endif
endloop
return this.basePosition
endmethod
static method addTo$VARNAME$ takes $VARTYPEBASE$ $VARNAMEBASE$, $VARTYPE$ change returns nothing
local thistype this = thistype(0).previous
loop
exitwhen this.$VARNAMEBASE$ == $VARNAMEBASE$
set this = thistype(this).previous
endloop
set this.$VARNAME$ = this.$VARNAME$ + change
call thistype.sortThis(this)
endmethod
//======================================================================================================
//HERE is where i use the static if <-------------------------------------------------------------------
//======================================================================================================
static if $VARTYPE$_NUMBER
static method remove$VARNAMEBASE$ takes $VARTYPEBASE$ $VARNAMEBASE$ returns nothing
local thistype this = thistype(0).previous
loop
exitwhen this.$VARNAMEBASE$ == $VARNAMEBASE$
set this = thistype(this).previous
endloop
set this.$VARNAME$ = 0
call thistype.sortThis(this)
call thistype.deallocate(this)
endmethod
else
static method remove$VARNAMEBASE$ takes $VARTYPEBASE$ $VARNAMEBASE$ returns nothing
local thistype this = thistype(0).previous
loop
exitwhen this.$VARNAMEBASE$ == $VARNAMEBASE$
set this = thistype(this).previous
endloop
set this.$VARNAME$ = null
call thistype.sortThis(this)
call thistype.deallocate(this)
endmethod
endif
static method add$VARNAMEBASE$ takes $VARTYPEBASE$ $VARNAMEBASE$, $VARTYPE$ $VARNAME$ returns nothing
local thistype this = thistype.allocation
set this.$VARNAMEBASE$ = $VARNAMEBASE$
set this.$VARNAME$ = $VARNAME$
call thistype.sortThis(this)
endmethod
//! endtextmacro
endlibrary