Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
illyism
Wanderer


Joined: 09 Dec 2007
Posts: 58

PostPosted: Thu Jul 03, 2008 3:59 pm   

%mss lags me up!
 
what happened to the colourizer? -http://www.silverbridge.org/~varmel/zmud/syntax/

Quote:
#CLASS {translator}
#ALIAS showtran {
#script {strHTML = ~"~"}
#script {Sub getHTML:Set objHTTP = CreateObject~(~"MSXML2.ServerXMLHTTP~"):objHTTP.Open ~"GET~", ~"@translink~", ~"FALSE~":objHTTP.Send:strHTML = objHTTP.ResponseText:Set objHTTP = Nothing:End Sub}
#mss {getHTML}
#echo %ansi( black)%mss( strHTML)
}
#ALIAS trans {
#var wordtrans %1
#var translink http://www.majstro.com/Web/Majstro/mobile_translator.php?bron=@thesourcelans~&doel=@thetarglans~&wrd=@wordtrans
showtran
}
#ALIAS TransHelp {
#show %ansi( green)Translator
#show %ansi( red)--Made by Illyism
#say
#show %ansi( yellow)Commands:
#show %ansi( green)Chooselans %ansi( white)Pick languages, 1. source, 2.target
#show %ansi( green)trans %ansi( yellow)<word> %ansi( white) translates the word
#say
#show !!!Lags a lot!!!
}
#ALIAS chooselans {
#pick {@placesorlans}
#pick {@placetarglans}
}
#ALIAS setarglans {#echo Target Language is : %1}
#ALIAS setsorlans {#echo Source Language is : %1}
#VAR targlans {'afr'Afrikaans|'alb'Albanees|'cat'Catalaans|'dan'Deens|'deu'Duits|'eng'Engels|'ang'Old Engels |'epo'Esperanto|'fao'Faeröers|'fin'Fins|'fra'Frans|'fry'Fries|'ell'Grieks|'hun'Hongaars|'ice'IJslands|'ita'Italiaans|'jpn'Japans|'lat'Latijn|'may'Maleis|'dut' Nederlands|'nor'Noors|'pap'Papiaments|'pol'Pools|'por'Portugees|'rom'Roemeens|'rus'Russisch|'gae'Schots-Gaelisch|'spa'Spaans|'sra'Sranan|'swa'Swahili|'tgl'Tagalog|'tai'Thais|'ces'Tsjechisch|'tur'Turks|'yuc'Yucatec|'zul'Zoeloe|'sve'Zweeds}
#VAR translink {http://www.majstro.com/Web/Majstro/mobile_translator.php?bron=eng&doel=lat&wrd=reds}
#VAR sourcelans {'afr'Afrikaans|'alb'Albanees|'cat'Catalaans|'dan'Deens|'deu'Duits|'eng'Engels|'ang'Old Engels |'epo'Esperanto|'fao'Faeröers|'fin'Fins|'fra'Frans|'fry'Fries|'ell'Grieks|'hun'Hongaars|'ice'IJslands|'ita'Italiaans|'jpn'Japans|'lat'Latijn|'may'Maleis|'dut' Nederlands|'nor'Noors|'pap'Papiaments|'pol'Pools|'por'Portugees|'rom'Roemeens|'rus'Russisch|'gae'Schots-Gaelisch|'spa'Spaans|'sra'Sranan|'swa'Swahili|'tgl'Tagalog|'tai'Thais|'ces'Tsjechisch|'tur'Turks|'yuc'Yucatec|'zul'Zoeloe|'sve'Zweeds}
#VAR trans {}
#VAR thetarglans {lat}
#VAR thesourcelans {eng}
#VAR placetarglans {p:Select the second language|o:1|setarglans 'afr'Afrikaans|setarglans 'alb'Albanees|setarglans 'cat'Catalaans|setarglans 'dan'Deens|setarglans 'deu'Duits|setarglans 'eng'Engels|setarglans 'ang'Old Engels |setarglans 'epo'Esperanto|setarglans 'fao'Faeröers|setarglans 'fin'Fins|setarglans 'fra'Frans|setarglans 'fry'Fries|setarglans 'ell'Grieks|setarglans 'hun'Hongaars|setarglans 'ice'IJslands|setarglans 'ita'Italiaans|setarglans 'jpn'Japans|setarglans 'lat'Latijn|setarglans 'may'Maleis|setarglans 'dut' Nederlands|setarglans 'nor'Noors|setarglans 'pap'Papiaments|setarglans 'pol'Pools|setarglans 'por'Portugees|setarglans 'rus'Russisch|setarglans 'rom'Roemeens|setarglans 'gae'Schots-Gaelisch|setarglans spa'Spaans|setarglans 'sra'Sranan|setarglans 'swa'Swahili|setarglans 'tgl'Tagalog|setarglans 'tai'Thais|setarglans 'ces'Tsjechisch|setarglans 'tur'Turks|setarglans 'yuc'Yucatec|setarglans 'zul'Zoeloe|setarglans 'sve'Zweeds}
#VAR placesorlans {p:Select the second language|o:1|setsorlans 'afr'Afrikaans|setsorlans 'alb'Albanees|setsorlans 'cat'Catalaans|setsorlans 'dan'Deens|setsorlans 'deu'Duits|setsorlans 'eng'Engels|setsorlans 'ang'Old Engels |setsorlans 'epo'Esperanto|setsorlans 'fao'Faeröers|setsorlans 'fin'Fins|setsorlans 'fra'Frans|setsorlans 'fry'Fries|setsorlans 'ell'Grieks|setsorlans 'hun'Hongaars|setsorlans 'ice'IJslands|setsorlans 'ita'Italiaans|setsorlans 'jpn'Japans|setsorlans 'lat'Latijn|setsorlans 'may'Maleis|setsorlans 'dut' Nederlands|setsorlans 'nor'Noors|setsorlans 'pap'Papiaments|setsorlans 'pol'Pools|setsorlans 'por'Portugees|setsorlans 'rus'Russisch|setsorlans 'rom'Roemeens|setsorlans 'gae'Schots-Gaelisch|setsorlans spa'Spaans|setsorlans 'sra'Sranan|setsorlans 'swa'Swahili|setsorlans 'tgl'Tagalog|setsorlans 'tai'Thais|setsorlans 'ces'Tsjechisch|setsorlans 'tur'Turks|setsorlans 'yuc'Yucatec|setsorlans 'zul'Zoeloe|setsorlans 'sve'Zweeds}
#VAR wordtrans {reds}
#VAR transed {?}
#TRIGGER {Target Language is : ~'(*)~'*} {#var thetarglans %1}
#TRIGGER {Source Language is : ~'(*)~'*} {#var thesourcelans %1}
#TRIGGER {<div>(*)</div> } {
#var transed {%1}
#var transed %replace( @transed, "{", "")
#var transed %replace( @transed, "}", "")
#var transed %replace( @transed, "</b>", "")
#var transed %replace( @transed, "br/", "")
#var transed %replace( @transed, ";", ",")
#echo @transed
}
#CLASS 0


so, when I try to use this script, it takes a long while to get the stuff I need from the website (Majestro.com), does anyone know how to shorten that time, I can't type anything in the 4-6 seconds download time.
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Thu Jul 03, 2008 5:33 pm   
 
The problem is that your call to the XMLHTTP component is synchronous and blocks the thread that calls it until it returns.
I would rewrite this thing as an external Windows Script Component and make the call asynchronous then you could just poll the component
until you get the response back from the webserver
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Thu Jul 03, 2008 7:52 pm   Re: %mss lags me up!
 
illyism wrote:
what happened to the colourizer? -http://www.silverbridge.org/~varmel/zmud/syntax/

I'm sorry but the server lost access to the Internet Crying or Very sad. It's frustrating and I am unfortunately not sure when it will be back online.
Reply with quote
illyism
Wanderer


Joined: 09 Dec 2007
Posts: 58

PostPosted: Fri Jul 04, 2008 5:46 pm   
 
Dharkael wrote:
The problem is that your call to the XMLHTTP component is synchronous and blocks the thread that calls it until it returns.
I would rewrite this thing as an external Windows Script Component and make the call asynchronous then you could just poll the component
until you get the response back from the webserver


can you please explain me how you would do that?
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Mon Jul 07, 2008 3:24 pm   
 
Below is an example of how it might be done, I did mine in JScript because I prefer it to VBScript.
The functions are really simple no checks or anything.
You copy this code to a file save it with the file Extension WSC
I called mine Illyism.translator.WSC
then right click and register the file, it's now a COM component.
Code:

<?xml version="1.0" ?>
<package>
   <comment>
        illyism's translator component
   </comment>
   <component >
      <?component error="true" debug="true" ?>
      <registration progid="illyism.translator.WSC" classid="{91F4A4A5-F8E1-47c4-86E2-AE784FEDA37C}" description="Illyism's translator component" version="1.0">
      </registration>
      <object id="conn" progid="MSXML2.XMLHTTP" events="true"/>   
      <public>
         <property name="Target">
            <get internalName="get_Target"/>
            <put internalName="put_Target"/>
         </property>
         <property name="Source">
            <get internalName="get_Source"/>
            <put internalName="put_Source"/>
         </property>
         <property name="Word">
            <get internalName="get_Word"/>
            <put internalName="put_Word"/>
         </property>
         <property name="Completed">
            <get internalName="is_Completed"/>           
         </property>
         <property name="Result">
            <get internalName="get_Result"/>           
         </property>                   
         <method name="Translate">       
        </method>
      </public>     
      <script language="JScript">
<![CDATA[
var Source = "eng";
var Target = "fra";
var Word ="";
var Complete = false;
var Result =""

function get_Target()
{
   return Target;
}
function put_Target(tar)
{
 Target = ""+tar;
}


function get_Source()
{
   return Source;
}
function put_Source(so)
{
 Source = ""+so;
}

function get_Word()
{
   return Word;
}
function put_Word(wo)
{
 Word = ""+wo;
}

function is_Completed()
{
   return Complete;
}

function get_Result()
{
   return Result;
}




function HandleStateChange()

{
  if (conn.readyState == 4)
  {
     Result = conn.responseText;     
     Complete=true;
  }
}


function Translate()
{
   Complete = false;
   Result="";
   if(conn.readyState!=0)
      conn.abort();
   conn.open("GET","http://www.majstro.com/Web/Majstro/mobile_translator.php?bron="+Source+"&doel="+Target+"&wrd="+Word,true)
   conn.onreadystatechange = HandleStateChange;
   conn.send();



]]>
      </script>
   </component>
</package>



Using this from ZMUD would go something like this

Code:
#var transObj %comcreate("illyism.translator.WSC")
transObj.Source = "eng"
transObj.Target = "fra"
transObj.Word = "fish"
#call @treansObj.Translate()

Okay that started an asynchronous call now you just test for Completed and if it evuluates to true (not zero) then Results will contain what you're looking for
Code:
#IF (@transObj.Completed) {#ECHO @transObj.Result} {#ECHO Not yet Completed}


I didn't build in any error handling of any sort, I'm just showing how you MIGHT get this done.
A good idea might be after calling Translate use a repeating #alarm to test for completed and then do something with the result.
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Mon Jul 07, 2008 3:30 pm   
 
It would of course be a lot easier if you were using CMUD you could obviate the need for any of this component stuff by just using threads.
But in ZMUD since there's only One thread available you can't make a synchronous call that will block for a long time.
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
illyism
Wanderer


Joined: 09 Dec 2007
Posts: 58

PostPosted: Tue Jul 08, 2008 1:15 am   
 
that is amazing, I think I'll be posting this in the finished scripts section, of course, if you agree.
This helped me a lot, and the example is perfect for future work.
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Tue Jul 08, 2008 1:01 pm   
 
Go ahead post away Smile
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net