So, I am using this code to generate a list of clan members by id (code later adds more info, but that works fine). I am expecting a map to be generated (called player_id) which has the first id on the detailed roster page (obtained from the showplayer.php?who= part of the frame source code) as the entry for 0 in my map. After producing the map, it uses map_to_file to place a text file (called backup.txt) into my data folder. However, when I run the code, the file at the end has nothing at 0, and is filled with the correct ids from 1. Is there any way to make it start from 0?
Sorry if this is unclear. I have tried to be as thorough as possible as to what I am expecting and what is actually happening, but I realise my wording isn't ideal.
EDIT:
Looking back through the code, I had a thought. Would I be right in thinking that:
Produces a map whose first line is everything before the first appearance of "nounder", then each subsequent line being the lines after each appearance of the term? If so, is there any way to avoid this, or otherwise remove that line from the map?
Sorry if this is unclear. I have tried to be as thorough as possible as to what I am expecting and what is actually happening, but I realise my wording isn't ideal.
Code:
record clan_info
{
string backup_id;
};
string excise( string source , string start , string end )
{
if( !source.contains_text( start ) ) return "";
string result = substring( source , index_of( source , start ) + length( start ) );
if( !result.contains_text( end ) ) return "";
return substring( result , 0 , index_of( result , end ) );
}
clan_info [int] parse_ids()
{
clan_info [int] parsed_id;
string call_clan_page = visit_url( "clan_detailedroster.php" );
call_clan_page = substring( call_clan_page , index_of( call_clan_page , "nounder" ) );
string [int] km = split_string( call_clan_page , "nounder");
int p = 0;
for i from 0 upto count( km ) - 1
{
if( contains_text( km[i] , "" ) )
{
parsed_id [p].backup_id = excise( km[i] , "href=\"showplayer.php?who=" , "\">" );
p = p + 1;
}
}
return parsed_id;
}
void main()
{
clan_info [int] player_id = parse_ids();
map_to_file( player_id , "backup.txt" );
}
EDIT:
Looking back through the code, I had a thought. Would I be right in thinking that:
Code:
string [int] km = split_string( call_clan_page , "nounder");
Produces a map whose first line is everything before the first appearance of "nounder", then each subsequent line being the lines after each appearance of the term? If so, is there any way to avoid this, or otherwise remove that line from the map?
Last edited: