Guest Jim Posted December 8, 2009 Report Share Posted December 8, 2009 uLib Stringslatest version: 2009.12.8 Download: ulib_strings.ubot This library includes commonly used string functions. Currently implemented:- replace - simple string replace- length - gets the length of a string- find - finds the position of a string within another string- find from - same as 'find' but with a parameter for an index to start from- substring - gets part of a string from a position for a certain length- substring (alt) - gets part of a string from one position to another position- trim - removes leading and trailing spaces from a string Let me know any other string functions you guys might find useful that I can implement for this library. If you have any problems or questions, let me know.  Enjoy. Quote Link to post Share on other sites
Aaron Nimocks 19 Posted December 8, 2009 Report Share Posted December 8, 2009 Strip would be useful. Quote Link to post Share on other sites
Guest Jim Posted December 8, 2009 Report Share Posted December 8, 2009 Strip would be useful. Done. Implemented it as 'trim'. Quote Link to post Share on other sites
some_guy 11 Posted December 8, 2009 Report Share Posted December 8, 2009 Cheers for this Just a quick question if I may. The substring sub, it's return node is "{1}".substr({2},{3}) #str #start #length My question is to do with the 'return' node. I think it is a new feature as it isn't in the 'commando' guide or the wiki (that I can see). Anyway, the 'substr' is Javascript I believe? Am I correct in thinking we can put any valid javascript in a return node? Quote Link to post Share on other sites
some_guy 11 Posted December 8, 2009 Report Share Posted December 8, 2009 Answer to my question. Yes the return field can take any Javascript Attached is the test, substring that takes a string and startpos and will return the substring from start position to end. Saves you having to work out the length. Note the #str variable should be passed in as "this is my string", as the " are not added in the sub. Again thanks for adding this library, you have increased the usefulnes of Ubot a million times to me and making it easier and quicker to do things. Quote Link to post Share on other sites
Guest Jim Posted December 9, 2009 Report Share Posted December 9, 2009 You can use $eval to run javascript - it's useful for a lot of things. My libraries are mostly just wrappers for javascript so far : I'm going to add a 'left' and 'right' substring functions to the library to easily substring the left or right side of a string. Trying to think of any other functions I can write. Quote Link to post Share on other sites
Guest turbolapp Posted December 9, 2009 Report Share Posted December 9, 2009 I have visited this thread a few times now hoping a light would go off as to what the hell you guys are talking about. I'm sad to say I am still in the dark. Anyone care to enlighten the non programmer here? Quote Link to post Share on other sites
some_guy 11 Posted December 9, 2009 Report Share Posted December 9, 2009 ^ I felt like that too. Download the encoding library as it includes an example which should help. Basically, if you have ever wanted to do something in Ubot but found there isn't a straight forward way to do things, you can know add the functionality yourself. Just create a library, add the functionality you require using Javascript. Now in any bot you write you can this added functionality just as you would a normal ubot command. I will upload an example tonight that uses this string library as it really is a useful library to use (once you have got your head round it). Quote Link to post Share on other sites
some_guy 11 Posted December 9, 2009 Report Share Posted December 9, 2009 Attached example of using two subs in the string lib. Takes a file name and at the end displays the filename without the extension. Also included an annotaed screen grab to explain things further Quote Link to post Share on other sites
bluegoat 24 Posted December 10, 2009 Report Share Posted December 10, 2009 Trying to think of any other functions I can write. Convert text to "UPPER CASE", "lower case", "Title Case", "Sentence case" Quote Link to post Share on other sites
random random 0 Posted December 10, 2009 Report Share Posted December 10, 2009 Can't add this into new scripts after the most recent ubot update. The current ones inside a script work and I can still include it, but when I try to click on ulib_strings through run sub I get a huge error every single time. Doesn't matter if its an older script or a brand new one, same thing. I've attached an image of the error if you want to take a look. Let me know if I should post this in the bug report section instead. Quote Link to post Share on other sites
random random 0 Posted December 11, 2009 Report Share Posted December 11, 2009 Figured I'd mention that one of the recent updates to ubot fixed this in case it wasn't already known. Thanks for the library, btw. Good stuff. Quote Link to post Share on other sites
webautomationlab 21 Posted January 5, 2010 Report Share Posted January 5, 2010 This should be stickied. Or maybe we need a resource forum that is strictly threads with key info like this. Quote Link to post Share on other sites
G-Man 0 Posted January 14, 2010 Report Share Posted January 14, 2010 urlencode (or escape as it's called in javascript) would be handy and appropriate I think. G-Man Quote Link to post Share on other sites
Guest Jim Posted January 14, 2010 Report Share Posted January 14, 2010 urlencode (or escape as it's called in javascript) would be handy and appropriate I think. G-Manhttp://ubotstudio.com/forum/index.php?/topic/2204-library-encoding ^ already implemented in my encoding library Quote Link to post Share on other sites
G-Man 0 Posted January 17, 2010 Report Share Posted January 17, 2010 http://ubotstudio.com/forum/index.php?/topic/2204-library-encoding ^ already implemented in my encoding library Yeah, I saw that after I made my post G-Man Quote Link to post Share on other sites
G-Man 0 Posted January 20, 2010 Report Share Posted January 20, 2010 Split would be nice. That is, being able to split a string up into multiple pieces based on a char and then putting it all into a list. Not sure that's technically possible right now tho G-Man Quote Link to post Share on other sites
some_guy 11 Posted February 3, 2010 Report Share Posted February 3, 2010 Have discovered an issue using javascript in an eval function. I was having an issue passing in a string that contained " and '. Found out I have to escape these manually using the Text Constant > $replace feature (i.e. replace " with \") However, I found out after much swearing and infuration, that if you pass this escaped string into a sub in the string lib that returned a string, then the returned string lost it's encoding. So I had to re-escape it all. Quote Link to post Share on other sites
bluegoat 24 Posted February 6, 2010 Report Share Posted February 6, 2010 Split would be nice. That is, being able to split a string up into multiple pieces based on a char and then putting it all into a list. Not sure that's technically possible right now tho G-ManHave you tried "add to list >> list from text"? Quote Link to post Share on other sites
Xspringe 6 Posted February 21, 2010 Report Share Posted February 21, 2010 I must be doing something wrong, because I can only get the subs in the strings library to return "undefined" as the return value. I've attached a screenshot of a test script that browses to google, tries to find the position of the letter "e" within the string "abcdefgh" and then enters the return value into the google search field. I must be making some stupid mistake but I can't figure out what it is. Quote Link to post Share on other sites
some_guy 11 Posted February 22, 2010 Report Share Posted February 22, 2010 Don't know why, but the issue is todo with the fact you are passing in straight text and not variables. At a guess I would say it is how uBot stores strings as variables and how it deals with text. Anyway, set 'abcdef' as a variable and set 'e' as a variable and it will work. For testing, right clicking a and selecting run node, you can then right click any variable and select insert string, to see what that variable currently has been set to. Make sure you cancel out the window, otherwise you will replace the variable with a string. Quote Link to post Share on other sites
Xspringe 6 Posted February 24, 2010 Report Share Posted February 24, 2010 Thanks again for all your help some_guy. It appears that the troubles I am having are due to a bug in Ubot. Quote Link to post Share on other sites
some_guy 11 Posted February 24, 2010 Report Share Posted February 24, 2010 Thanks again for all your help some_guy. It appears that the troubles I am having are due to a bug in Ubot. No worries, any additional information on what was causing your issue? Quote Link to post Share on other sites
Xspringe 6 Posted February 24, 2010 Report Share Posted February 24, 2010 No worries, any additional information on what was causing your issue? Not sure yet, but I think it has something to do with how Ubot and javascript interact. The interesting thing is that the Ubot tech support has the exact same problem, so it appears to be a common and reproducible issue. This should hopefully help with debugging. PS - Please check your mail Quote Link to post Share on other sites
iglow 8 Posted February 25, 2010 Report Share Posted February 25, 2010 IF based on part of URL For exampel i have a list of urls that i want to do some tasks on.ANd i want to LOOP it like this:nav-> next list item IF in url aaa.html then RUN SUB1IF in url bbb.html then RUN SUB2etc i tried messing with stings library a bit but didnt accomplish it. Anybody could help maybe? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.