Insert: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Heeheehee
Renamed start to strStart since it might confuse readers (start happens to be another ASH function dealing with buffers)
imported>Fredg1
mNo edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 5: Line 5:
FunctionPage|
FunctionPage|
name={{#var:name}}|
name={{#var:name}}|
function_category=String Handling Routines|


function1={{Function|
function1={{Function|
Line 20: Line 19:
}}|
}}|


function_description=Returns the buffer {{pspan|original}} with the string {{pspan|stuff}} inserted at {{pspan|start}} removed.|
function_description=Returns the buffer {{pspan|original}} with the string {{pspan|stuff}} inserted at {{pspan|strStart}}.|


code1={{CodeSample|
code1={{CodeSample|
Line 38: Line 37:
}}|
}}|


see_also={{SeeAlso|delete}}|
see_also={{SeeAlso|delete|append|set_length}}|
}}
}}
[[Category:String Handling Routines]]

Latest revision as of 06:37, 19 August 2020

Function Syntax

buffer insert(buffer original ,int strStart ,string stuff )

  • original is the buffer to modify
  • strStart marks where to insert the string
  • stuff is the string to insert

Returns the buffer original with the string stuff inserted at strStart.

Code Sample

Inserts a "Refresh page" link to the Pyramid inside KoL's default border.

buffer results;
results.append(visit_url());

int strEnd = results.index_of("height=137 border=0>");
if(strEnd > 0) {
   results.insert(strEnd + 20,"<br /><div align='center' class='tiny'><a href='pyramid.php'>Refresh page</a></div>");
}
results.write();

See Also

delete() | append() | set_length()