Jump to content
UBot Underground

Anyone got a good understanding of subtext?


Recommended Posts

Hi all,

 

Makes a change for me to be stumped lol. Can anyone who has figured out subtext take a look at the example dummy bot...

 

subtextbot.ubot

 

The bot asks for a url and should the user put a forward slash on the end of the url it should strip it off before adding "/?a=1". the ?a=1 is just an example and not what I would actually append to the url. The issue I have is that if the user of the bot puts a / on the end the url becomes www.url.com//?a=1

 

So I have written a sub which should take a url, check the last character of it and if its a / then it should return the url without it, else return the url as it was passed in with no changes.

 

The logic here is to get a subtext of the url which contains the last character of the url, if its a / then set the return variable to be a subtext of the original url from position 1 to the length of the original url minus 1. Otherwise just return the original url unchanged.

 

So to test you can use my site if you like. Run the bot with the url set to:

 

http://www.66th.net

 

...and it works fine. Now run it with it set to:

 

http://www.66th.net/

 

And notice how it ends up with a double // in it.

 

Andy

 

P.S. I can't just use replace to get rid of /'s as the url could just as easily be http://www.url.com/subfolder/anothersubfolder/pagename.php

Link to post
Share on other sites

I use subtext regularly. Your bot will not run for me. I get an error.

 

Are you just trying to avoid a // situation?

 

Yes.

 

What error do you get?

 

Am I right in assuming the first character in a string of text is position 1?

 

Andy

Link to post
Share on other sites

I've left this for now, when I have more time I'll play about with the subtext thing some more and try to figure out why this isn't working. In the mean time I'll just make it clearer to the end user they must not put the trailing slash on.

 

Andy

 

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning." - Rick Cook.

Link to post
Share on other sites
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning." - Rick Cook.

Good Quote.

 

I changed the sample a little bit.

 

It will remove the tailing "/" from the url.

 

Kevin

subtextbot-test.ubot

  • Like 1
Link to post
Share on other sites

Andy,

 

You could use the $Text Length constant to get you to the end in one shot and then just read 1 character for testing to see if it is a /. In essence, you are using text length as the pointer to the spot you want to read.

 

Buddy

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...