HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

ClearTable(certainvar) ?

04-25-2006, 10:51 AM#1
vile
Since I started using tables instead of handle vars, I have a bit of a problem. I only have a ClearTable(string) which does this:
Collapse JASS:
function ClearTable takes string table returns nothing
     call FlushStoredMission(Cache(),table)
endfunction

Thing is, what if I want to clear a certain variable inside a table? which function I should make?
I remember I made this for the handle vars but it acts kind of differently for tables.

I want to be able to clear a certain var from a table. For example:

Collapse JASS:
local string s = GetAttachmentTable(s, unit)
call SetTableBoolean(s, "b", true)

Then I want only to clear the "b" value, and not the entire table.
Can anyone help me with this? Thanks.
04-25-2006, 11:33 AM#2
PitzerMike
I've never looked at this implementation of tables but what you want to accomplish translates to

Collapse JASS:
FlushStoredBoolean(Cache(), s, "b")

Vexorian might also have implemented an auto-flush on default value behavior,
in which case you'd simply use
Collapse JASS:
SetTableBoolean(s, "b", false)
to remove the value from the table.

But that's pure speculation, as already mentioned I've never checked the implementation.
04-25-2006, 11:58 AM#3
vile
hmm now that i'm looking at it;
Collapse JASS:
function SetTableObject takes string table, string field, handle val returns nothing
    local gamecache g=Cache()
    if (val==null) then
        call FlushStoredInteger(g,table,field)
    else
        call StoreInteger(g,table,field,H2I(val))
    endif
    set g=null
endfunction

It seems that if the value is null than it flushes the certain var

so if I use
Collapse JASS:
call SetTableObject(s, "u", null)
"u" will be flushed. Is this correct?
04-25-2006, 12:05 PM#4
PitzerMike
Yes, correct. That's what I meant with "auto-flush on default value".
For booleans it would be false, for strings either null or "" and for numeric types 0.
04-25-2006, 12:34 PM#5
vile
Thanks mate.