[Request] In / Out Text Replacer - Printable Version -Shoutbox (https://shoutbox.menthix.net) +-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58) +--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4) +---- Forum: Scripting (/forumdisplay.php?fid=39) +----- Thread: [Request] In / Out Text Replacer (/showthread.php?tid=75592) [Request] In / Out Text Replacer by Yukai on 06-24-2007 at 06:01 PM
Hi RE: [Request] In / Out Text Replacer by toddy on 06-24-2007 at 06:07 PM http://www.msgpluslive.net/scripts/browse/ RE: [Request] In / Out Text Replacer by Yukai on 06-24-2007 at 06:12 PM There is no script in the database that fits my needs. RE: [Request] In / Out Text Replacer by roflmao456 on 06-24-2007 at 07:32 PM
hmmm... (untested) code: Paste that in a new script and ther you go it might fail in some cases though... * roflmao456 calls Cookie to explain RE: RE: [Request] In / Out Text Replacer by Yukai on 06-24-2007 at 07:47 PM
quote: Thank you so much for taking time to write that. But I feel kind of dumb since I don't understand what to replace and where. RE: RE: RE: [Request] In / Out Text Replacer by Deco on 06-24-2007 at 09:46 PM
quote: In this part. Change "FirstWord" to the word in romaji you want. Then Change "SecondWord" to another word you want in romaji. and so on. In the second part change "KanjiWord" to any kanji word you want.. like "feioso" or something (sorry I don't know kanji). Hope you get it this time! code: RE: [Request] In / Out Text Replacer by Yukai on 06-24-2007 at 10:36 PM
But why FirstWord and SecondWord? Are they linked with Kanjiword and SecondKanjiWord? RE: [Request] In / Out Text Replacer by roflmao456 on 06-25-2007 at 02:46 AM
quote: as you said in your previous post, you want to just replace romaji words with kanji. so in the first list you put the romaji words (look after var) and in the second, you put the kanji words Let's see it like this: code: if you send 'testing' it will replace with 'testo'. if your contact sends you 'testthis' it will replace to you with 'test123' (but it will fail if test123 is longer than testthis's length. RE: RE: [Request] In / Out Text Replacer by CookieRevised on 06-25-2007 at 03:24 AM
quote:Whooosh.. For things like this many people use the Replace function. But the replace function will search for the stuff to replace from the beginning of the text you paste to it. So, in a list if you have the letters A B C D E F G H and you're going to replace each letter respectivly with C D E F G H A B... Then you can (and will) come in the situation like this: The next pseudo code is almost always used in scripts like this (you can verify this in the scripting database). But it will, in most cases, render wrong results: var myword = "ABC" myword = myword.replace("A", "C") myword = myword.replace("B", "D") myword = myword.replace("C", "E") myword = myword.replace("D", "F") myword = myword.replace("E", "G") myword = myword.replace("F", "H") myword = myword.replace("G", "A") myword = myword.replace("H", "B") myword is now "EBC"(1) or "ABA"(2) not "CDE" as it was intended! This because: (1) if Replace replaced the first letter it finds (like it does by default): var myword = "ABC" myword = myword.replace("A", "C") => myword is now "CBC" myword = myword.replace("B", "D") => myword is now "CDC" myword = myword.replace("C", "E") => myword is now "EDC" (here the first error occurs) myword = myword.replace("D", "F") => myword is now "EFC" myword = myword.replace("E", "G") => myword is now "EFC" myword = myword.replace("F", "H") => myword is now "EHC" myword = myword.replace("G", "A") => myword is still "EHC" myword = myword.replace("H", "B") => myword is now "EBC" or, (2) if Replace replaced all the letters it finds: var myword = "ABC" myword = myword.replace("A", "C") => myword is now "CBC" myword = myword.replace("B", "D") => myword is now "CDC" myword = myword.replace("C", "E") => myword is now "EDE" (here the first error occurs) myword = myword.replace("D", "F") => myword is now "EFE" myword = myword.replace("E", "G") => myword is now "GFG" myword = myword.replace("F", "H") => myword is now "GHG" myword = myword.replace("G", "A") => myword is now "AHA" myword = myword.replace("H", "B") => myword is now "ABA" Conclussion: never ever use: var myword = "something" myword = myword.replace("A", "B") myword = myword.replace("B", "C") myword = myword.replace("C", "A") or the likes (like looping using a list, as this is just the same, only shorter in code) to replace text when the text to search for contains the same characters as the text to replace with! ------------------------- quote:yep But only if Kanji and Romaji don't have any words in common (or even parts of words!!). Otherwise you will have the situation as described above. Which means you will not be able to use that script for this. Though, there are other situations in which this script will not work properly and this has got something to do with the RecievedMessage event and detecting if the recieved message is/isn't a message you wrote. But that's explained in another thread And then there is also the fact that you can not return a longer message than the one you've recieved in the RecievedMessage event. Which can and will also lead to this script not working properly in those cases. ------------------------- This said, it could be possible that there is a Windows API which already does this convertion, I can't remember anymore, I'll need to look this up (unless someone else can confirm this or not). > EDIT: after an extremely quick plain search I can't find any api for this though... RE: [Request] In / Out Text Replacer by Yukai on 06-25-2007 at 11:18 AM
I think it will be okay since romaji is Japanese spelled with letters RE: [Request] In / Out Text Replacer by CookieRevised on 06-25-2007 at 11:32 AM
quote: PS: seeing http://en.wikipedia.org/wiki/Romaji and other resources, it seems not so easy to convert romaji back though, as there are several systems possible. So you'd need something which automatically reconizes the used system, etc. All in all, not an easy script to make I think. The Javascript used on this page might be a great help... also check out the links that page points to. RE: [Request] In / Out Text Replacer by Yukai on 06-25-2007 at 12:31 PM
ow, this might be a little more difficult than i thought. RE: [Request] In / Out Text Replacer by markee on 06-26-2007 at 02:10 PM
You also have to remember that changing to kanji is probably not the best to change it into as there are at least 2 ways that every kanji can be pronounced and there are many kanji that make the same sound and hence same romaji. The only way to do a script that you were after by any means is a romaji to hiragana or a romaji to katakana script that could translate either way. [off-topic] quote:This is easily fixed by using a function in your replace method instead code:This will return "bcda". [/off-topic] |