Difference between pages "Talk:Batch close" and "Get path"

From Kolmafia
(Difference between pages)
Jump to navigation Jump to search
imported>StDoodle
m
 
imported>Bale
(r8628)
 
Line 1: Line 1:
This is a really bad example of how to use batches:
+
{{
* The batchable commands are all executed conditionally, so the order in which the first instance of each one is unpredictable, and therefore the order in which the batched commands are executed is unpredictable.  If both autosellable and mallsellable items were processed prior to the first item that had a nonzero closet amount, the batch of take_closet()s will be executed LAST.  This really needs to be done in at least two separate batches - the autosell and mallsell can be safely done in the same batch, since at most one will be done for any given item.
+
#vardefine:name|get_path}}{{
* There are extraneous server-hitting commands inside the batch, for no reason whatsoever.  If cli_execute() became batchable (unlikely, but not entirely impossible), the script would malfunction because the inventory counts inside the main loop wouldn't reflect the outfit change.  visit_url() is safe in a batch only because it has an individually significant return value.
+
#vardefine:return_type|string}}{{
* In any case, an example that the user CAN'T SAFELY TRY FOR THEMSELVES does not strike me as being particularly educational.
 
--[[User:Jasonharper|Jasonharper]] 11:58, 5 March 2010 (UTC)
 
  
I won't comment on the first two parts, as JH surely knows what he's talking about far better than I could hope to. But for his last point, I wholeheartedly agree; ideally, a user could copy-paste any code found on a function page and try it out for themselves. But with this... bad idea.
+
FunctionPage|
--[[User:StDoodle|StDoodle]] 23:13, 8 March 2010 (UTC)
+
name={{#var:name}}|
 +
 
 +
function1={{Function|
 +
name={{#var:name}}|
 +
aggregate={{#var:aggregate}}|
 +
return_type=string|
 +
return_also={{#var:return_also}}|
 +
}}|
 +
 
 +
function_description=When called by a [[Relay Override Scripting|relay override script]], this returns the page name of the URL that was submitted in the relay browser. This does not include any variables which might follow a question mark in the URL.|
 +
code1={{CodeSample|
 +
title=Code Sample|
 +
description=Print path information about how the current override was called.|
 +
code=<syntaxhighlight>
 +
print( "This script was called by the URL: " + get_path_full() );
 +
if( get_path_variables() != "" ) {
 +
  print( "Which is composed of the page name: " + get_path() );
 +
  print( "followed by a question mark and the variables: "+ get_path_variables() );
 +
}
 +
</syntaxhighlight>}}|
 +
 
 +
see_also={{SeeAlso|form_fields|get_path_full|get_path_variables}}|
 +
special=When this function is called by any script that is not a relay override, it returns an empty string|
 +
}}
 +
 
 +
[[Category:Relay Browser Functions]]

Revision as of 06:27, 26 November 2014

Function Syntax

string get_path()

When called by a relay override script, this returns the page name of the URL that was submitted in the relay browser. This does not include any variables which might follow a question mark in the URL.

Code Sample

Print path information about how the current override was called.

print( "This script was called by the URL: " + get_path_full() );
if( get_path_variables() != "" ) {
   print( "Which is composed of the page name: " + get_path() );
   print( "followed by a question mark and the variables: "+ get_path_variables() );
}

See Also

form_fields() | get_path_full() | get_path_variables()

Special

When this function is called by any script that is not a relay override, it returns an empty string