Difference between revisions of "Set length"

From Kolmafia
Jump to navigation Jump to search
imported>Bale
(Created page with '{{ #vardefine:name|set_length}}{{ #vardefine:return_type|void}}{{ FunctionPage| name={{#var:name}}| function_category=String Handling Routines| function1={{Function| name={{#va…')
 
imported>Bale
m
 
(One intermediate revision by the same user not shown)
Line 5: Line 5:
 
FunctionPage|
 
FunctionPage|
 
name={{#var:name}}|
 
name={{#var:name}}|
function_category=String Handling Routines|
 
  
 
function1={{Function|
 
function1={{Function|
Line 18: Line 17:
 
}}|
 
}}|
  
function_description=Changes the size of the buffer. If the new length is less than the current length, then the buffer is truncated, losing all characters past that length.|
+
function_description=Changes the size of the buffer. Primarily this is used to truncate the buffer by setting a new length shorter than the current length, deleting all the characters past that length. If the new length is longer than the old length, the buffer will be padded with null characters: \u0000. Those character can cause trouble, so only use set_length to truncate.|
  
 
needscode=yes|
 
needscode=yes|
Line 24: Line 23:
 
see_also={{SeeAlso|delete|insert|length}}|
 
see_also={{SeeAlso|delete|insert|length}}|
 
}}
 
}}
 +
 +
[[Category:String Handling Routines]]

Latest revision as of 05:13, 22 May 2010

needs(code_samples);

Function Syntax

void set_length(buffer original ,int length )

  • original is the buffer to modify
  • length is the new length of the buffer

Changes the size of the buffer. Primarily this is used to truncate the buffer by setting a new length shorter than the current length, deleting all the characters past that length. If the new length is longer than the old length, the buffer will be padded with null characters: \u0000. Those character can cause trouble, so only use set_length to truncate.

See Also

delete() | insert() | length()