What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » how do i do this...

how do i do this...
Author: Message:
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
29 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. Huh?  how do i do this...
if i want to like say write something to an external file ( viewer.html )

its first preset text in the file is "Hello"

but in the script i want to open it and set that text to "Hi"

can anyone give out a code for this
[quote]
Ultimatess6
: What a noob mod
12-09-2006 10:50 PM
Profile PM Web Find Quote Report
Baggins
Full Member
***

Avatar
B000ALFAZO

Posts: 387
Reputation: 13
29 / Male / Flag
Joined: Oct 2006
RE: how do i do this...
You would need to read in the file, parse it, and replace the text.  I am not very good at parsing stuff though.

Or did you mean that the file just consists of the one word "hello" and nothing else?

EDIT: could you give an example of what exactly the file would look like?

I am assuming because you say html it would need parsing

This post was edited on 12-09-2006 at 11:13 PM by Baggins.
12-09-2006 11:09 PM
Profile E-Mail PM Web Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
29 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. RE: how do i do this...
this is my viewer.html file i need to replace the bold ones below..

code:
<HTML>
<TITLE>YouTube Viewer</TITLE>
<Script>
var v;

function viewVid(video){
v = video;
document.getElementById("vid").innerHTML = "<object width=\"425\" height=\"350\"><param name=\"movie\" value=\"http://www.youtube.com/v/12345678901\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"http://www.youtube.com/v/12345678901\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"425\" height=\"350\"></embed></object>";
}
</Script>
<BODY onload=''>
<div id='vid' align='center'>
</div>
</BODY>
</HTML>


the 12345678901 is what i am going to replace

This post was edited on 12-11-2006 at 12:04 AM by roflmao456.
[quote]
Ultimatess6
: What a noob mod
12-11-2006 12:03 AM
Profile PM Web Find Quote Report
Baggins
Full Member
***

Avatar
B000ALFAZO

Posts: 387
Reputation: 13
29 / Male / Flag
Joined: Oct 2006
RE: how do i do this...
ok, one solution popped into my head, first create three variables

in the first store:
code:
<HTML>
<TITLE>YouTube Viewer</TITLE>
<Script>
var v;

function viewVid(video){
v = video;
document.getElementById("vid").innerHTML = "<object width=\"425\" height=\"350\"><param name=\"movie\" value=\"http://www.youtube.com/v/

second:
code:
\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"http://www.youtube.com/v/

third:
code:
\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"425\" height=\"350\"></embed></object>";
}
</Script>
<BODY onload=''>
<div id='vid' align='center'>
</div>
</BODY>
</HTML>


now when you find out the id for whichever video you want to veiw, store it in a variable.

finally write the variables in this order to your file

var1, id, var2, id, var3

that is write NOT append

then you have a .html that you can open

that is the easiest way i can think of

This post was edited on 12-11-2006 at 12:14 AM by Baggins.
12-11-2006 12:12 AM
Profile E-Mail PM Web Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
35 / Male / Flag
Joined: Aug 2006
RE: how do i do this...
code:
var myVar = <variable with source code in it>.split("http://www.youtube.com/v/");
myVar = myVar[1].substr(0,11)//Change 11 to another number if needed
<variable with source code in it>.replace(/myVar/g);

Remember to write back to the file for changes to take affect
Not tested, but it should work

EDIT: Beaten :o

This post was edited on 12-11-2006 at 12:17 AM by Spunky.
<Eljay> "Problems encountered: shit blew up" :zippy:
12-11-2006 12:16 AM
Profile PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: how do i do this...
quote:
Originally posted by SpunkyLoveMuff
code:
var myVar = <variable with source code in it>.split("http://www.youtube.com/v/");
myVar = myVar[1].substr(0,11)//Change 11 to another number if needed
<variable with source code in it>.replace(/myVar/g);

Remember to write back to the file for changes to take affect
Not tested, but it should work

EDIT: Beaten :o

that will not work...

The split function is not needed and will actually make that this wont work. Delimeters ("http://www.youtube.com/v/" in your case) will obviously be deleted from the final array the split function has created.

-------

The proper way to do this:

1) read the entire file into a variable

now you have the entire contents of the file in 1 string. All it takes now is just replacing parts of the string like you replace text in strings...

2) replace the number with your own number in that variable (use the string.replace() function for this with a regular expression so you replace all occurances and not simply the first one).

3) overwrite the file with the new text in that variable

But as stated several times by now, look things up yourself roflmao456. You clearly don't learn a thing by asking copy/paste solutions as you keep comming asking for basic programming stuff. Study the JScript 5.6 documentation (available from the official Plus! scripting database, category "others").

Hence I'm not going to give the code, you need to look this up and find out by yourself using the documentation. Start by reading about files and how to open, read and write them. It is clearly explained with examples in the documentation.

This post was edited on 12-11-2006 at 02:55 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
12-11-2006 02:49 AM
Profile PM Find Quote Report
« 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