Why won't this work?

Vestras

Retired
Reaction score
249
Okay, I'm trying to create new methods for storing struct data, but my current won't work! It only displays the "lol".
JASS:
library DAS initializer Init
    
    //! textmacro DAS_make takes TYPE,NAME,SCOPE
    private keyword $NAME$DATA
    globals
        $SCOPE$ string array $NAME$STR[400000]
        $SCOPE$ string array $NAME$DUMMYSTR[400000]
        $SCOPE$ integer $NAME$N=-1
        $SCOPE$ $NAME$DATA $NAME$store
    endglobals
    
    private struct $NAME$DATA
    $TYPE$ dat
        
        method operator[] takes string s returns $TYPE$
            return .dat
        endmethod
        
        method operator[]= takes string s, $TYPE$ data returns nothing
            set .dat=data
        endmethod
    endstruct
    
    $SCOPE$ function Get$NAME$ takes handle h returns integer
        local integer r
        local integer j=-1
        local boolean b=false
        loop
            set j=j+1
            if $NAME$DUMMYSTR[j]=="stored" then
                set r=$NAME$store[$NAME$STR[$NAME$N]]
                set $NAME$STR[$NAME$N]=""
                set $NAME$DUMMYSTR[$NAME$N]="available"
                set $NAME$N=$NAME$N-1
                set b=true
            endif
            if j>$NAME$N then
                debug call BJDebugMsg("DAS: please store data before getting it!")
            endif
            exitwhen b==true or j>$NAME$N
        endloop
        return r
    endfunction
    
    $SCOPE$ function Store$NAME$ takes handle h, integer xxx returns nothing
        if $NAME$DUMMYSTR[$NAME$N]=="available" then
            set $NAME$N=$NAME$N+1
            set $NAME$STR[$NAME$N]=I2S(xxx)
            set $NAME$DUMMYSTR[$NAME$N]="stored"
            set $NAME$store[$NAME$STR[$NAME$N]]=xxx
            
            call BJDebugMsg($NAME$STR[$NAME$N])
            call BJDebugMsg("lolh")
        endif
    endfunction
    
    $SCOPE$ function InitStrings_DASGENERATED$NAME$ takes nothing returns nothing
        local integer j=-1
        loop
            set j=j+1
            exitwhen j>399999
                set $NAME$DUMMYSTR[j]="available"
                set $NAME$STR[j]=""
        endloop
        call BJDebugMsg("lolz")
    endfunction
    //! endtextmacro
    
    //! runtextmacro DAS_make("integer","Struct"," ")
    
    private function Init takes nothing returns nothing
        call BJDebugMsg("lol")
        call InitStrings_DASGENERATEDStruct()
    endfunction
endlibrary


JASS:
library tst

struct d
    timer t
    string str
endstruct

function Lulz takes nothing returns nothing
    local d y=GetStruct(GetExpiredTimer())
    call BJDebugMsg(y.str)
endfunction

function Trig_TEST_Actions takes nothing returns nothing
    local d y=d.create()
    set y.str="hi"
    set y.t=CreateTimer()
    call StoreStruct(y.t,y)
    call TimerStart(y.t,0.25,false,function Lulz)
endfunction

//===========================================================================
function InitTrig_TEST takes nothing returns nothing
    set gg_trg_TEST = CreateTrigger(  )
    call TimerStart(CreateTimer(),0.03,false,function Trig_TEST_Actions)
    //call TriggerAddAction( gg_trg_TEST, function Trig_TEST_Actions )
endfunction

endlibrary


Grr?
 
Without checking if your method is sensible or not, I found this:

JASS:
        loop
            set j=j+1
            exitwhen j>399999
                set $NAME$DUMMYSTR[j]="available"
                set $NAME$STR[j]=""
        endloop

That'll will hit op limit somewhere around j = 15000 or earlier.
 
Without checking if your method is sensible or not, I found this:

JASS:
        loop
            set j=j+1
            exitwhen j>399999
                set $NAME$DUMMYSTR[j]="available"
                set $NAME$STR[j]=""
        endloop

That'll will hit op limit somewhere around j = 15000 or earlier.

Why? What can I do to prevent that?
 
build in waits every 10000 executions?
split up the loop to run in different threads?
 
Wouldn't it be somehow logical to use booleans for checking if it's available or not..? Use false as the available value, so you don't need to set them (they default to false). And I can't see a reason to give "" as the value for $NAME$STR. Isn't null good enough?
 
JASS:
library DAS
    
    //! textmacro DAS_make takes TYPE,NAME,SCOPE
    private keyword $NAME$DATA
    globals
        $SCOPE$ string array $NAME$STR[400000]
        $SCOPE$ boolean array $NAME$DUMMY[400000]
        $SCOPE$ $NAME$DATA $NAME$store
    endglobals
    
    $SCOPE$ function H2I takes handle h returns integer
        return h
        return 0
    endfunction
    
    private struct $NAME$DATA
    $TYPE$ dat
        
        method operator[] takes string s returns $TYPE$
            return .dat
        endmethod
        
        method operator[]= takes string s, $TYPE$ data returns nothing
            set .dat=data
        endmethod
    endstruct
    
    $SCOPE$ function Get$NAME$ takes handle h returns integer
        local integer r
        local integer j=-1
        local boolean b=false
        loop
            set j=j+1
            if $NAME$DUMMY[j]==true then
                set r=$NAME$store[$NAME$STR[H2I(h)-0x100000]]
                set $NAME$STR[H2I(h)-0x100000]=""
                set $NAME$DUMMY[H2I(h)-0x100000]=false
                set b=true
            endif
            exitwhen b==true
        endloop
        return r
    endfunction
    
    $SCOPE$ function Store$NAME$ takes handle h, integer xxx returns nothing
        call BJDebugMsg("lolha")
        if $NAME$DUMMY[H2I(h)-0x100000]==false then
            set $NAME$STR[H2I(h)-0x100000]=I2S(H2I(h)-0x100000)
            set $NAME$DUMMY[H2I(h)-0x100000]=true
            set $NAME$store[$NAME$STR[H2I(h)-0x100000]]=xxx
            
            call BJDebugMsg($NAME$STR[H2I(h)-0x100000])
            call BJDebugMsg("lolh")
        endif
    endfunction
    //! endtextmacro
    
    //! runtextmacro DAS_make("integer","Struct"," ")
endlibrary

Still doesn't show. :( Only shows the "lolha".
 
JASS:
$SCOPE$ $NAME$DATA $NAME$store

You never give that a value. And why do you even have that? o_O
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    It is weird seeing a way more realistic users online number
  • The Helper The Helper:
    Happy Tuesday Night!
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top