|
||
|
|||||||
| Script Support Get support for modifying RunUO Scripts, or writing your own! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Newbie
|
Hi all. I've recently scripted a component to a custom profile system I've been testing on my shard. Everything works quite well, however I have problem when it comes to saving information to a string, and then parsing that string into a URL.
Example is below: Code:
this.AddHtml(15,51,270,20,"<A HREF=\"http://www.(edited for advertisement)+ temp + "\">Click for " + temp + "'s Webpage",false,false); Code:
string temp=((Account)((Mobile)who).Account).GetTag("PROFILELINK" + who.Name);
As I said, this works wonderfully as is. For example, this code would automatically check the string stored as the PROFILELINK account tag, parse that string into the URL, and then open. However, with browsers other than Internet Explorer, when a space is used to seperate two words, the gump simply fails to open the browser (obviously due to the browser recognizing bad syntax in the URL created by above code. Mozilla/FireFox does not like white spaces!). I've tested using an underscore ( _ ) between two words as opposed to a simple space, and voila, it works fine for just about every browser (save for Chrome). Thus, my issue inherent is as follows: How can I have the line of code in the gump recognize white space as an underscore? I think this approach would be more practical than saving the string's white space as underscores, or even my last resort, posting a disclaimer that instructs players to use an underscore instead of a space. And for the inquiring minds wondering why on earth I'd want a space between two words that are used to create a viable web-link, the website I created to use this system recognizes spaces between words automatically as underscores. If it wasn't for the FireFox issue, the script would be fine as is. Any help would be duly appreciated. Again, I'm essenitally just looking for a way to either replace spaces in a string with underscores automatically, or have an AddHtml gump line of code that automatically recognizes and replaces spaces with underscores. Oh, and Merry Christmas to those Christian folk out there! |
|
|
|
|
|
#2 (permalink) |
|
Forum Master
|
you can do a check on the string entered, checking for bad characters and speaces, etc
and if in there tell them they have to remake it looke at NameVerification.cs in the misc directory and how they do it
__________________
http://www.AoAUO.com
:) ..... Come for the Customs, Play for the Fun. Return to see your new Friends ..... :) |
|
|
|
|
|
#3 (permalink) |
|
Forum Novice
|
Strings are also like "arrays" of "char" type data.
So consider string temp = "blah"; temp[0] (this value is b) temp[1] (this value is l) etc. So what you could do is... Code:
foreach(char c in temp)
{
if(c == ' ') //if char is whitespace
c = '_'; //replace with underscore;
}
But there also should be many Methods in the String class that could help with this as well. Google C# string manipulation tutorial and you should find dozens of links....I wish I knew the methods, but I've not done much string manipulation in a long time. Hope that helps and merry xmas if you celebrate.
__________________
Check out my MMO Design Blog:@http://mmodesigntheory.blogspot.com/
|
|
|
|
|
|
#4 (permalink) | |
|
ConnectUO Creator
Join Date: Jan 2004
Age: 28
Posts: 5,440
|
Quote:
you should just use string.Replace Code:
temp = temp.Replace(' ', '_');
__________________
Jeff Boulanger ConnectUO - Creator/Core Developer Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|