Delete: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Heeheehee
Created page with '{{ #vardefine:name|delete}}{{ #vardefine:return_type|buffer}}{{ FunctionPage| name={{#var:name}}| function_category=String Handling Routines| function1={{Function| name={{#var:…'
 
imported>Heeheehee
Forgot that I'd need to write() the buffer in order for it to do anything.
Line 33: Line 33:
int st = results.index_of(del);
int st = results.index_of(del);
if ( st > -1 ) results.delete(st, st+length(del));
if ( st > -1 ) results.delete(st, st+length(del));
else print("string '"+del+ "' not found");
else print("string '"+del+ "' not found");  
results.write();
</syntaxhighlight>
</syntaxhighlight>
}}|
}}|

Revision as of 04:56, 20 April 2010

Function Syntax

buffer delete(buffer original ,int start ,int end )

  • original is the buffer to modify
  • start marks where to start deleting
  • end marks where to end deleting

Returns the buffer original with the substring from start to end removed.

Code Sample

Removes the border that KoL uses to frame some tables.

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

string del = " style=\"padding: 5px; border: 1px solid blue;\"";
int st = results.index_of(del);
if ( st > -1 ) results.delete(st, st+length(del));
else print("string '"+del+ "' not found"); 
results.write();

See Also

insert()