Post Reply 
emu48 append to list issue
03-21-2022, 11:03 PM (This post was last modified: 03-22-2022 09:44 PM by rickster.)
Post: #1
emu48 append to list issue
I'm working on a program to generate characters for a role-playing game. I am having trouble with '+' used to append an item to a list:
Code:

@ HP 48GX simulator
@ XGEN2 -- do the crunch for A/H Chaosium Runequest 3e characters

@ relevant parts of the program
« 
INI$LOG    @ initialize the logger function
" →X XGEN2" LOGGIT
   @ append to LOG$S
LOAD$$    @ initialize data structures
CLFX
   @ clear flags #1-#7
DO 
  SP$PICK
   @ choose species from list, execute corresponding XX$$ routine setting species name, average characteristic values, mov stat,  base age, and gender, and set flag #i if average characteristic #i is e.g. 10.5
UNTIL 1 ==
END 
DUP 'CHRXCX' STO
   @ save a copy of this vector, and pass a copy to next routines
BUMPX    @ if flag #i set, add 1 to characteristic #i half the time
ADJX    @ randomize each charax +2D4-4 -- definitely not canon!
EDITX    @ edit the randomized set to taste
OBJ→ DROP   @ put  vector elements in stack, drop count from level 1 of strack

   @ start a local variable block with values taken from stack
←str ←con ←siz ←int ←pow

←dex ←app ←mov ←age ←gnr

  « ATTRS 'CHRXAT' STO    @ calc attributes (hit points, strike rank,...), and save a vector thereof
     SCMS 'CHRXSC' STO
   @ calc Skills  Category Modifiers and save a vector thereof
     DO$PREXP 'CHRXPE' STO
   @ handle previous experience for this character (not implemented)
  »    @ end local block
"X→ XGEN2" LOGGIT

LOG$S
   @ show the log
»
'XGEN2' STO


@ $$EDITX -- set parameters for INFORM in EDITX
« 

  "EDIT CHARAX"    @ title 
  { { "STR:" "" 0 } { "CON:" "" 0 } { "SIZ:" "" 0 } 
    { "INT:" "" 0 } { "POW:" "" 0 } { "DEX:" "" 0 } 
    { "APP:" "" 0 } { "MOV:" "ms" 13 } { } 
    { "age:" "" 0 } { } 
    { "gnr:" "m,f,..." 2 } }     @ field specs
  { 3 4 }
   @ layout
  { }    @ reset values

CHRXCX 1 →LIST +
   @ append initial values as a list, as 5th item in the list
»
'$$EDITX' STO

@ EDITX --- run the input form, return a vector on the stack
«
"  ->X EDITX" LOGGIT
DO 
  $$EDITX OBJ→ DROP
  @ set the 5 values from $$EDITX on the stack for the input form
  INFORM
UNTIL 1 ==
   @ consume Boolean from stack
END    @ return the edited values as a vector
"  X-> EDITX" LOGGIT
»
'EDITX' STO

When I run XGEN2, it stalls at INFORM in EDITX: the "$$EDITX" routine apparently fails to add CHRXCX as
the 5th element of the parameter-list. (CHRXCX has a value.) When I run "$$EDITX" on its own, however, it does add the list. And when I run EDITX on its own, it displays the input form correctly!
I am completely puzzled by this behaviour. Any ideas? Thanks in advance...

Charles? He was my grandfather. --Oh, *that* Charles. We share a common ancestor.
Find all posts by this user
Quote this message in a reply
03-22-2022, 01:05 PM
Post: #2
RE: emu48 append to list issue
Interesting that your variable name that begins with two dollar signs and ends with EDITX is causing posting problems in the forum. There's probably a way to "escape" that name, but I'm not familiar enough with the MyBB features to know for sure.

Speculation:

Is it possible that the variable CHRXCX is not defined at some point in the code when your append is being attempted? If it isn't defined, it will simply show up on the stack as 'CHRXCX' instead of showing any possible contents, which would undoubtedly cause problems. Try placing the commands 41 MENU HALT right before the "+" in your code to see exactly what's on the stack, and that might provide a clue as to what is happening. If everything looks good, simply SST through the code to see where things start to break down.

Another suggestion: try putting the list elements on the stack first and then combining them all with 5 \->LIST instead of appending an encapsulated sublist. Not a huge difference here, but it might save some space in the long run.

Hope this helps!
Find all posts by this user
Quote this message in a reply
03-22-2022, 02:44 PM
Post: #3
RE: emu48 append to list issue
Thanks, I'll try that 41 MENU HALT tip.

Charles? He was my grandfather. --Oh, *that* Charles. We share a common ancestor.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)