Append: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
Created page with '{{#vardefine:name|append}} {{#vardefine:return_type|buffer}} {{FunctionPage| name={{#var:name}}| function_category=String Handling Routines| function1={{Function| name={{#var:n…'
 
m Changed "slot" to "slott", because "slot" is reserved in KoLMafia and cannot be used as a key variable name
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{#vardefine:name|append}}
{{
{{#vardefine:return_type|buffer}}
#vardefine:name|append}}{{
#vardefine:return_type|buffer}}{{


{{FunctionPage|
FunctionPage|
name={{#var:name}}|
name={{#var:name}}|
function_category=String Handling Routines|


function1={{Function|
function1={{Function|
Line 19: Line 19:
function_description=Returns a buffer containing {{pspan|original}} with {{pspan|add}} tacked on to the end.|
function_description=Returns a buffer containing {{pspan|original}} with {{pspan|add}} tacked on to the end.|


needscode=yes|
code1={{CodeSample|
title=Code Sample|
description=Print a list of all items currently equipped.|
code=
<syntaxhighlight>
buffer gear;


see_also={{SeeAlso|append_tail}}|
foreach slott in $slots[]
  if(equipped_item(slott) != $item[none]) {
      if(length(gear) != 0)
        gear = append(gear, ", ");
      gear = append(gear, to_string(equipped_item(slott)));
  }
 
print("I am wearing: "+ gear);
</syntaxhighlight>
}}|
 
see_also={{SeeAlso|append_tail|set_length|delete|insert}}|
}}
}}
[[Category:String Handling Routines]]

Latest revision as of 14:21, 8 December 2021

Function Syntax

buffer append(buffer original ,string add )

  • original is the buffer to add to
  • add is a string to add on

Returns a buffer containing original with add tacked on to the end.

Code Sample

Print a list of all items currently equipped.

buffer gear;

foreach slott in $slots[]
   if(equipped_item(slott) != $item[none]) {
      if(length(gear) != 0)
         gear = append(gear, ", ");
      gear = append(gear, to_string(equipped_item(slott)));
   }

print("I am wearing: "+ gear);

See Also

append_tail() | set_length() | delete() | insert()