Mirar @ Pike developers forum wrote:
Hm, wait. You have it in THIS... that might be enough. D'oh...
Hmm.. doesn't seem like my variables show up (with correct values), unless added to a pike class... ?
why doesn't this work (as expected == what am I doing wrong):
// Module variables PIKEVAR array(int) acs_map; PIKEVAR int LINES; PIKEVAR int COLS; PIKEVAR int TABSIZE;
PIKEFUN int initscr() { DPRINTF( "nc: initscr()\n" );
initscr();
// init acs_map int i; check_stack(120); BEGIN_AGGREGATE_ARRAY(120) { push_int(0); for( i = 1; acs_map[i]; i++ ) { if( i >= 512 ) Pike_error( "Unexpected large acs_map!" );
DPRINTF( " acs_map[%d]: %d\r\n" COMMA i COMMA acs_map[i] );
push_int(acs_map[ i ]); DO_AGGREGATE_ARRAY(120); } } END_AGGREGATE_ARRAY;
THIS->acs_map = Pike_sp[-1].u.array;
DPRINTF( "nc: acs_map: %x\r\n" COMMA THIS->acs_map ); DPRINTF( "nc: acs_map: size %d\r\n" COMMA THIS->acs_map->size ); DPRINTF( "nc: acs_map: item 0 %d\r\n" COMMA THIS->acs_map->item[0].u.integer ); DPRINTF( "nc: acs_map: item 10 %d\r\n" COMMA THIS->acs_map->item[10].u.integer );
// init vars THIS->LINES = LINES; THIS->COLS = COLS; THIS->TABSIZE = TABSIZE;
DPRINTF( "nc: LINES: %d\r\n" COMMA THIS->LINES ); // tells me lines = 60, but the value from the pike script says = 0.
not sure if I should pop_stack() or anything after assigning the value to THIS->acs_map (or it that's the way to do it at all?). when I run pike, the variables is present in the module, but all with the int value 0.
I have a PIKEFUN int foo; inside a PIKECLASS which i set to THIS->foo = 123; in it's INIT{}, and that comes out alright..