Form of...HTML!

heeheehee

Developer
Staff member
buffer results;
results.append(visit_url());
string str = "border: 1px solid blue;"
int start = results.index_of(str);
// This string is 23 chars long, but you can use length() to find this if you don't know it.
results.delete(start, start+23);
 

slyz

Developer
You have to make sure that string exists in the page before trying to remove it:
PHP:
buffer results;
results.append(visit_url());
string str = "border: 1px solid blue;"
int start = results.index_of(str);
if ( start > -1 ) results.delete(start, start+length(str));
 

icon315

Member
Thanks, but it doesn't seem to do what i wanted it to do, i was trying to remove the frame from the page.


I want this:



To be this:
 

slyz

Developer
PHP:
buffer results;
results.append(visit_url());
string str = "border: 1px solid blue;"
int start = results.index_of(str);
if ( start > -1 ) results.delete(start, start+length(str));
else print("string '"+str+ "' not found);
This will tell you if the string str is found in results or not.
 

icon315

Member
I guess it works, it would be much more helpful if actually knew the code for the border, and if you can even remove it, but thank you very much for the help
 

heeheehee

Developer
Staff member
Okay, here we go:
PHP:
   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");
 

icon315

Member
string ' style="padding: 5px; border: 1px solid blue;"' not found

Maybe it would help if i link my script here, (Iron Man). It is called Icon's clan_slimetube.ash v2.52.


EDIT: I Just Uploaded the version with the code you gave me on it
 
Last edited:

StDoodle

Minion
Icon, do you change your relay browser colors to non-standard ones? That looks like a slightly different blue, but it could be me.

If so (and to be safe, always, in a relay override - and only in a relay override) you should replace references to the color blue with get_property("defaultBorderColor")
 

icon315

Member
like this?:

PHP:
	get_property("defaultBorderColor");
   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");
 

heeheehee

Developer
Staff member
Yeah, that looks like it might be the case. And to stop threadjacking, might I suggest moving this discussion to icon315's thread for his relay override scripts?
Edit: And you'd want to do it more like this:
PHP:
   ;
   string del = " style=\"padding: 5px; border: 1px solid "+get_property("defaultBorderColor")+";\"";
   int st = results.index_of(del);
   if ( st > -1 ) results.delete(st, st+length(del));
   else print("string '"+del+ "' not found");
 

icon315

Member
sorry....../me moves


EDIT: OK to end this, i looked at the source code and i changed this:
PHP:
	get_property("defaultBorderColor");
   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");

to this:

PHP:
	get_property("defaultBorderColor");
   string del = " style=\"padding: 5px; border: 1px solid #0000ff;\"";
   int st = results.index_of(del);
   if ( st > -1 ) results.delete(st, st+length(del));
   else print("string '"+del+ "' not found");
 
Last edited:

StDoodle

Minion
I'm having a bit of a problem that I was wondering if anyone could help with.

The script I'm working on is an update to my daily deeds script, which allows the user to perform actions related to each listing (as appropriate). I really don't want to hard-code a bunch of test_button() calls, as that would make the script more difficult to update / maintain. However, the buttons get written after their relevant settings are listed. For example, the script lists # of 3 tome summons, and allows casting of a tome skill from the form. If the button is used, its action is performed after the script writes the current number of tome summons, so the # isn't updated until another refresh is done. Is there any simple way to deal with this, or am I going to need to move the button column over to before the X of Y column in order to get what I'm looking for?
 

xKiv

Active member
I don't think so. You would probably have to do something wild, like do another pass over all listed deeds *after* all button-actions are processed, and set new values using javascript.
And that would be .. ugghly.
 

slyz

Developer
Have a look at FamiliarFeeder (linked in my sig). I look in fields to see if a button has been used in the previous instance of the relay script, and execute the actions before generating the page, so the inventory stays up to date.

Here is an example:
PHP:
fields = form_fields();
if ( fields contains "fam_equip_ghost" ) {
	fam = $familiar[Gluttonous Green Ghost] ;
	if ( !debug ) use_familiar(fam) ;
} else remove fields["fam_equip_ghost"] ;

...

if ( !my_familiar() == $familiar[Gluttonous Green Ghost] ) {
	write  ("              ");
	attr("class='button'");
	write_button("fam_equip_ghost", "Take GGG out");
	writeln("");
}

A little note about the remove fields["fam_equip_ghost"] ; - if you test to see if a key exists and if it didn't exist, you have to remove the key, or it will stay in the map (with the default value, in this case the default string "").
If you want to test for the presence of that key only once, it's not really important though.
 
Last edited:

jasonharper

Developer
You need to test the buttons earlier, before anything is written that would be affected by the button's action. It doesn't have to be very much earlier: for each summoning skill, you could test the button and cast the skill if true, then determine and write the number of casts remaining, then write a button if that's non-zero. That would keep everything related to one skill close together in the code.

Another possibility would be to structure your code so that everything is done by individual functions, with a boolean parameter: false to test the button and possibly take an action, true to actually write the button if one is needed. You'd then have a master function that calls all of the individual functions with the same parameter. Your main then becomes master(false); master(true);. This would let you write results from an action that appear at the top of the page, while still keeping all the code related to an action in a single place.
 

StDoodle

Minion
The problem is that it isn't just for "each summoning skill" that my script will perform actions; it will also do so for user-defined settings, which are rather difficult to hardcode.

I'm not sure I'm 100% sure on what you're outlining for your second solution, jasonharper. (No offense meant; I'm just dense sometimes.) I'm thinking the best solution will probably just be to loop through all form_fields() when the script starts, and make sure to use naming conventions such that buttons are easily recognizable (probably names starting with "button_"), and test each of those; performing its action as needed. Of course, since buttons have different types of actions, I'll probably need to write a hidden field for each button, with a name that can be parsed into a function call.... hmm...

Again, it wouldn't be an issue if I was willing to hardcode everything, but that would defeat the purpose of this re-write. ;)
 
Top