User Tools

Site Tools


4rpl:commands:list

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
4rpl:commands:list [2021/03/02 18:05] Karsten754rpl:commands:list [2025/09/02 21:05] (current) – [Examples] kalli
Line 15: Line 15:
 trace(GetListCount(<-list) trace(GetListCount(<-list)
 </code> </code>
 +
 +When building a list, there is a risk that there are items left on the stack before you start building your list. If you know your list length, then you can use listN. If you don't, then you need to clear the stack before starting to build your new list. __To prevent this:__ ClearStack will throw away the old stack, but if you want to save the old stack instead, then you can use the functions below.
 +<code 4rpl>
 +"various" "things" "left" "on" "the stack"
 +@saveOldStack
 +List(1 2 3) ->list
 +@loadOldStack
 +traceallsp
 +
 +:saveOldStack
 +stacksize if list ->oldStack 0 else 1 endif ->noOldStack
 +
 +:loadOldStack
 +<-noOldStack if return endif
 +stacksize if list ->newStack 1 else 0 endif ->newStackSaved
 +<-oldStack ListToStack
 +<-newStackSaved if <-newStack ListToStack endif
 +
 +
 +</code>
 +
 <=[[4rpl:start| Index]] <=[[4rpl:start| Index]]
  
4rpl/commands/list.1614708302.txt.gz · Last modified: 2025/02/14 14:56 (external edit)