What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Request] In / Out Text Replacer

Pages: (2): « First [ 1 ] 2 » Last »
[Request] In / Out Text Replacer
Author: Message:
Yukai
New Member
*


Posts: 8
– / Male / –
Joined: Mar 2007
O.P. [Request] In / Out Text Replacer
Hi

I was playing around with the built in text replacer in Plus! and I got the funny idea of replacing Japanese Romaji with Kanji.

But to my suprise I could only edit the text that I write myself, which makes my idea a bit harder.

Here's the thing that I would like to do:

I write something in romaji   =  Becomes kanji
My friend writes something in kanji  = Becomes romaji


I do not request a dictionary, I will add the words myself if I could get my hands on a script like this.



Thank you..
06-24-2007 06:01 PM
Profile E-Mail PM Find Quote Report
toddy
Veteran Member
*****

Avatar
kcus uoy

Posts: 2573
Reputation: 49
– / Male / Flag
Joined: Jun 2004
RE: [Request] In / Out Text Replacer
http://www.msgpluslive.net/scripts/browse/
06-24-2007 06:07 PM
Profile PM Find Quote Report
Yukai
New Member
*


Posts: 8
– / Male / –
Joined: Mar 2007
O.P. RE: [Request] In / Out Text Replacer
There is no script in the database that fits my needs.
06-24-2007 06:12 PM
Profile E-Mail PM Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
29 / Male / Flag
Joined: Nov 2006
Status: Away
RE: [Request] In / Out Text Replacer
hmmm... (untested)

code:
var romaji = new Array(
"Just",
"Like",
"This",
"Separated by comma",
"unless if it's the last one."
);

var kanji = new Array(
"Same",
"Goes",
"Here"
);

function OnEvent_ChatWndSendMessage(Chatwnd, Message){
for(i=0;i<romaji.length;i++){
var Word = new RegExp(romaji[i], "gi");
Message = Message.replace(Word, kanji[i]);
}
return Message;
}

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
if(Origin != Messenger.MyName && MessageKind == 1){
for(i=0;i<kanji.length;i++){
var Word = new RegExp(kanji[i], "gi");
Message = Message.replace(Word, romaji[i]);
}
return Message;
}
}

Paste that in a new script and ther you go (Y)

it might fail in some cases though...

* roflmao456 calls Cookie to explain :P

This post was edited on 06-24-2007 at 07:33 PM by roflmao456.
[quote]
Ultimatess6
: What a noob mod
06-24-2007 07:32 PM
Profile PM Web Find Quote Report
Yukai
New Member
*


Posts: 8
– / Male / –
Joined: Mar 2007
O.P. RE: RE: [Request] In / Out Text Replacer
quote:
Originally posted by roflmao456
hmmm... (untested)

code:
var romaji = new Array(
"Just",
"Like",
"This",
"Separated by comma",
"unless if it's the last one."
);

var kanji = new Array(
"Same",
"Goes",
"Here"
);

function OnEvent_ChatWndSendMessage(Chatwnd, Message){
for(i=0;i<romaji.length;i++){
var Word = new RegExp(romaji[i], "gi");
Message = Message.replace(Word, kanji[i]);
}
return Message;
}

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
if(Origin != Messenger.MyName && MessageKind == 1){
for(i=0;i<kanji.length;i++){
var Word = new RegExp(kanji[i], "gi");
Message = Message.replace(Word, romaji[i]);
}
return Message;
}
}

Paste that in a new script and ther you go (Y)

it might fail in some cases though...

* roflmao456 calls Cookie to explain :P


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.

06-24-2007 07:47 PM
Profile E-Mail PM Find Quote Report
Deco
Full Member
***


Posts: 188
Reputation: 4
41 / Male / Flag
Joined: Aug 2006
RE: RE: RE: [Request] In / Out Text Replacer
quote:
Originally posted by Yukai
quote:
Originally posted by roflmao456
hmmm... (untested)

code:
var romaji = new Array(
"Just",
"Like",
"This",
"Separated by comma",
"unless if it's the last one."
);

var kanji = new Array(
"Same",
"Goes",
"Here"
);

function OnEvent_ChatWndSendMessage(Chatwnd, Message){
for(i=0;i<romaji.length;i++){
var Word = new RegExp(romaji[i], "gi");
Message = Message.replace(Word, kanji[i]);
}
return Message;
}

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
if(Origin != Messenger.MyName && MessageKind == 1){
for(i=0;i<kanji.length;i++){
var Word = new RegExp(kanji[i], "gi");
Message = Message.replace(Word, romaji[i]);
}
return Message;
}
}

Paste that in a new script and ther you go (Y)

it might fail in some cases though...

* roflmao456 calls Cookie to explain :P


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.




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:
var romaji = new Array(
"FirstWord",
"SecondWord",
"ThirdWord",
"FourthWord",
"FifthWord."
);

var kanji = new Array(
"KanjiWord",
"SecondKanjiWord",
"ThirdKanjiWord"
);

06-24-2007 09:46 PM
Profile E-Mail PM Web Find Quote Report
Yukai
New Member
*


Posts: 8
– / Male / –
Joined: Mar 2007
O.P. RE: [Request] In / Out Text Replacer
But why FirstWord and SecondWord? Are they linked with Kanjiword and SecondKanjiWord?

Let's say that:

FirstWord gets changed to A
KanjiWord gets changed to B

Will "A" then become "B" when i type and will an incoming "B" become "A"?


Again, sorry for being slow
06-24-2007 10:36 PM
Profile E-Mail PM Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
29 / Male / Flag
Joined: Nov 2006
Status: Away
RE: [Request] In / Out Text Replacer
quote:
Originally posted by Yukai
But why FirstWord and SecondWord? Are they linked with Kanjiword and SecondKanjiWord?

Let's say that:

FirstWord gets changed to A
KanjiWord gets changed to B

Will "A" then become "B" when i type and will an incoming "B" become "A"?


Again, sorry for being slow

no yes.. oops i just read it again

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:
var romaji = new Array(
"testing",
"test123",
"tester"
);

var kanji = new Array(
"testo",
"testthis",
"roflmao456"
);

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.

This post was edited on 06-25-2007 at 03:34 AM by roflmao456.
[quote]
Ultimatess6
: What a noob mod
06-25-2007 02:46 AM
Profile PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RE: [Request] In / Out Text Replacer
quote:
Originally posted by roflmao456
* roflmao456 calls Cookie to explain :P
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:
Originally posted by Yukai
But why FirstWord and SecondWord? Are they linked with Kanjiword and SecondKanjiWord?

Let's say that:

FirstWord gets changed to A
KanjiWord gets changed to B

Will "A" then become "B" when i type and will an incoming "B" become "A"?
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...

This post was edited on 06-25-2007 at 04:04 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
06-25-2007 03:24 AM
Profile PM Find Quote Report
Yukai
New Member
*


Posts: 8
– / Male / –
Joined: Mar 2007
O.P. RE: [Request] In / Out Text Replacer
I think it will be okay since romaji is Japanese spelled with letters

And Kanji is Japanese signs..

And are you saying that the word that will replace can't be longer than the original word?
Because the built in function can. It just doesn't have any support for incoming messages
06-25-2007 11:18 AM
Profile E-Mail PM Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On