mIRC Home    About    Download    Register    News    Help

Print Thread
Page 2 of 2 1 2
Re: How (In Theory) to use OTHER scripting languages #20576 28/04/03 12:45 PM
Joined: Dec 2002
Posts: 2,985
Watchdog Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 2,985
No probs hehe.

Re: How (In Theory) to use OTHER scripting languag #20577 29/04/03 04:22 AM
Joined: Feb 2003
Posts: 309
C
CloCkWeRX Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Feb 2003
Posts: 309
*ahem*

Well I seem to have started an verging on flamishness post.

Here's the abbreviated point of my original post, which many of you ignored and argued amongst yourselfs about.

COM object support in mIRC allows you to overcome some of the flaws in mIRC as a scripting language. Suppose you want to use and manipulate arrays, if you knwo the Jscript, VBscript or any script which can be supported by WSH and the XML to create your COM object, whammo! Instant code which is leaping high above mIRC script in some areas.

You don't need to run out and buy Visual Basic 6/.NET to do it. It can be done free, and with a microsoft product. I know. Wow. Did you say free and microsoft *IN THE SAME SENTENCE*

Another thing. AS far as I know it no one has written an AI bot for mIRC. It is possible to use LISP with WSH, and therefor create COM objects. All of a sudden you have an AI language working with mIRC and you don't have to mess around with sockets and A.L.I.C.E bot.

Debugging: WSH debugs scripts alot better than mIRC (which only checks for brackets and control structures being OK). You can find a syntax highlighting editor for javascript, xml, and mixed code etc. All of a sudden you can use somehting like editplus to code in mIRC. (Editplus is a programming orientated notepad clone... go frisk the net for it and try it... customisable sytnax highlighting, language models... too much to list)

COM objects are nice because they are objects. You can create countless _instances_ of the same object, and I know you can call COM objects from COM objects. So can you imagine creating a multithreaded COM object which does 5-10 things at once while mIRC thinks its only doing one thing...

And finally:
The point of my post was to get someone who knows WSH/Jscript/XML to see if they could actually create a mIRC implementable COM object. I've got too much stuff to do on the side. Its possibly in theory; I'm calling for people to prove me right or wrong.
The COM section needs an overhaul or at least some links to relevant MSDN articles. The mIRC community has failed to produce much in the way of tutorials, I've had to hunt all over efnet and trbz is never in. There are coders and mIRCers who can do it, they just hide.



Re: How (In Theory) to use OTHER scripting languag #20578 29/04/03 05:08 AM
Joined: Feb 2003
Posts: 309
C
CloCkWeRX Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Feb 2003
Posts: 309
Quote:
My gripe is the apparent attitude that a few people have in regards to mIRC that mIRC scripting is just a hurdle to be jumped over in order to get to 'the good languages' via DLLs and COM objects. If Khaled went to the trouble of making a language don't you think it's worth a little bit of the user's time to see if that can do the required job more easily before looking to other languages?


Perhaps.

Now; try to get a team of scripters synchronising your efforts and creating a managable, functional, clean script. We have no standards because mIRC isn't picky. It gets messy. COM objects and DLLs create a method of writing object orientated, modular code: it has a front end, and middle bit and the bit you can't see.
Its a lot neater and if you have documentation its a much neater and *better planned* outcome.

Aliases are meant to be reusable recyclable code. But they can't do anything in the way of multithreading. A DLL utilises memory far better than an interpreted script. A COM object (or Active X DLL, not the same) does the same. You have a neat package of functions and hopefully the documentation to go with.

mIRC is not a hurdle to get to the "good langauges". Would I use a COM object or DLL to write sickeningly pink colored popups? No. Would I use it to work with sockets? No. mIRC already has all of this.
BUT.
What if I want to sort lists by a "human" method. (1,2,11, not 1,11,2)
Or use fuzzy logic type "sounds like" type sorting criteria?
(Go look @ PHP documentation)A COM object/DLL allows this freedom. If your an animal more at home with javascript than mIRCscript, I'm pointing out here and now that hey, you CAN work with javascript in mIRC. COM objects alll the way.

Did any of you go and read the windows scripting host documentation?
Did any of you get curious to see if it could be done?
We all started bitching.
STOP IT! Children, please!

Nothing is usurping anything. There's a reason I suspect Khaled included DLL and COM support. He's fundamentally lazy (as all good coders should be) and has decided to let US as the mIRC community to carry on development of all of the pointless suggestions many of us come up with. I know I've thought of a few damn good n useless ones.
stop ranting about "i don't like your coding attitude too". Its what makes people fight holy wars over piddling little bits of land. Each to their own. Stop dragging each other down. I quite agree with starbucks_mafia on that one.

*pant, pant*

'nuff ranting. I'm off to do something useful with my life

Re: How (In Theory) to use OTHER scripting languag #20579 29/04/03 06:04 AM
Joined: Dec 2002
Posts: 2,985
Watchdog Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 2,985
Did any of you go and read the windows scripting host documentation?
Did any of you get curious to see if it could be done?
We all started bitching.
STOP IT! Children, please!


I don't see any flames, just people offering their opinion, I even got thanked for mine. grin

At the same time no-one is disputing that mIRC scripting has a few shortfalls. It all comes down to the necessity to include support for other things. The thread has already unearthed some interesting findings too, raw mIRC coding craps all over MDX for a start. I'm not flaming MDX here, it serves a purpose (makes dialogues look pretty and in some cases more functional), that is the point though, you support more languages, protocols, or whatever and the standard that is alleged to not exist becomes even less of a standard.

The other thing is the 'market' for what you want included. There is not a large number of people who would utilise the WSH or script in Perl if mIRC came to support it. How many people add DLL's to mIRC? How many people use MDX or even MTS? Hundreds, thousands but certainly not the millions who use mIRC.

I'd like to see resources put into things that most people will find a use for, and bugfixes.

Re: How (In Theory) to use OTHER scripting languag #20580 03/05/03 10:01 AM
Joined: Feb 2003
Posts: 309
C
CloCkWeRX Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Feb 2003
Posts: 309
again, you didn't read it did you watchdog

WSH already supports the creation COM object. mIRC implementable COM objects.

You make it in <whatever>Script and create a COM object and implement it in mIRC.

What I am asking is for someone who MAY know which end of a stick to poke at a COM object to create one in <whatever>script. I could do it myself but I am slack, and I dread creating and messing around with struff for ages.
Screw it. Sometime in the future I'll post something here.

Re: How (In Theory) to use OTHER scripting languag #20581 03/05/03 11:43 AM
Joined: Dec 2002
Posts: 2,985
Watchdog Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 2,985
Screw it. Sometime in the future I'll post something here.

lol - It does pay to finish what you start.

Re: How (In Theory) to use OTHER scripting languag #20582 05/05/03 05:55 AM
Joined: Feb 2003
Posts: 309
C
CloCkWeRX Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Feb 2003
Posts: 309
COM objects for Cheepskates
So you want to make com objects, but don't want to fork out cash for visual basic/other ide's?
Here's the simple, free and _EASY_ way to do it.

Requirements:
Javascript, Jscript, VBscript, Perlscript, REXXscript or any other script supported by windows scripting host.

Introduction
(previois posts)
That covers the background of this whole thing fairly well. So, here we are.

Part One: Working With My First Com Object
I read the help file entry and sat confused. I looked at the example and didn't get far either.
Here's my better commented version.
excel {
;Excel.Application is what the Excel com object is filed under the the WINDOWS REGISTRY. It has a clsid, which is a bunch of numbers in brackets, like:
;{00000-00000-00000-0000}
;That doesn't concern us yet.
;Action:
;Opens a new com object, and label it "excel" of type Excel.Application.
comopen excel Excel.Application

if ($comerr) {
;if it doesn't open, give up and yell at the user
echo comopen failed
halt
}

;Original: check if excel window is visible
;Extended: check if excel window is visible. Do this by
;accessing the public method VISIBLE in object EXCEL (opened earlier) with
;1 = DISPATCH_METHOD
;2 = DISPATCH_PROPERTYGET
;1 + 2 = 3, which explains that bit.
;That tells it to GET a return value from a METHOD
;Think of it like a custom $identifier - alias monkey { return fleas }
;$monkey returns the word "fleas", BUT its an alias rather than a varible.
;mIRC doesn't have return types, but other langauges do. More on that later.

if ($com(excel,Visible,3) == 0) {
echo $com failed
goto finish
}

echo Visible: $com(excel).result

;Original: make excel window visible
;Extended: make excel window visible. Do this by
;accessing the public method VISIBLE in object EXCEL (opened earlier) with
;1 = DISPATCH_METHOD
;4 = DISPATCH_PROPERTYPUT
;That tells it to PUT(pass) a value to a METHOD
;Again a custom $identifier - alias monkey { set %secret_var $1- }
;$monkey(fleas) sets a varible which the user can't see (PRIVATE some might say)
;this returns 0 for "we screwed up", or something else for "its all good"

if ($com(excel,Visible,5,i4,1) == 0) {
echo $com failed
goto finish
}

; check visibility again
;look above
if ($com(excel,Visible,3) == 0) {
echo $com failed
goto finish
}

echo Visible: $com(excel).result

:finish
;get rid of the stupid thing, we are sick of it.
comclose excel
}

mIRC isn't a real programming language. Its a scripting language. Its had bits cut out of it left right and center, for ease of use.
The differences between mIRC and a real programming language:
mIRC:
mIRC uses "aliases", which are "simulated functions".
mIRC uses varibles which automatically convert data.
mIRC isn't object oriented.
+more
Java:
Java uses real functions
Java uses primitive types for its varibles. For instance, if you have a varible named "x" of the type "int" (Integer), you can't put the String "Bob" into it and expect it to work. The reason for this is it is trying to use the least amount of memory possible - an Int takes up less memory than a string (how long is a piece of string, we don't know so we just take up a lot of space to start off with and hope!)
Java is Object Oriented.

What is the Object Orientated nonsense?
Well, think back to making a dialog.
What mIRC script does is create a basic dialog object and that in turn adds other objects (buttons, text boxes, etc). You can create your dialog by /dialog -m <table> <name>
What does that mean?
You can create 2 copies of one dialog table with different names
They are the same beast, just different INSTANCES of them. Sadly mIRC doesn't do this often with aliases and other language features, but in most cases it doesn't need to.

Whats the use of it all?
Lets look at this:
$com(excel,Visible,3)

Somewhere in Excel.Application's code is soemthing like this
private int Visible;
public int get_Visible() {
return Visible;
}
public int set_Visible(int Value) {
Visible = Value;
makeAppVisible;
return 1;
}
What that all is is as follows:
Line 1: a Varible named "Visible". It stores an int or Integer (whole number). It is PRIVATE, so only functions in the same program can "see" it. mIRC can't meddle with it, as that would be dangerous.
Line 2: a Method named get_Visible. It returns the value of Visible, which can't been seen by anything else externally. It is PUBLIC which means that everyone can see & use it. It takes no arguments (parameters, $1- etc).
Line 5: A method name set_Visible. It sets the value of Visible to Value (they are both integers so there is no need to convert from one type to another). It returns 1 if its successful. If its not successful, it won't return anything (NULL). It also does all of the code to show the app

This whole process is known as "Encapsulation", and is a key programming technique in many successful languages today.
So, here we are.
Reality:
Excel object
-Property Visible
-Method get_Visible
-Method set_Visible
What mIRC see's:
Excel
-Method Visible

get_ & set_Visible are combined into a "Visible" method for teh ease of use mIRCers. DISPATCH_METHOD + DISPATCH_PROPERTYGET simply calls the get_Visible method, DISPATCH_METHOD + DISPATCH_PROPERTYPUT does the same with set_Visible

I think we have covered enough theory about implementing for you to get a rough grasp of things to come.

Part 2: Creating my first COM object.
Run off to msdn.microsoft.com, downloads, windows script, and get Script Component Wizard.
It will make things easier, like assiging a CLSID.
Run it.
Follow the prompts and make a new com object, called "Monkey"
Scripting Langauge of your choice...
Scriptlet, not DHTML
Add property "Version", value "1.0.0", get only
Add property "Temp", value "Bob string!",put, get
Add method inputPrompt, arguments text
"Finish"

You should end up with something like this:
<scriptlet>

<Registration
Description="monkey"
ProgID="monkey.Scriptlet"
Version="1.00"
ClassID="{65378720-7da6-11d7-ab3c-525400edd75c}"
>
</Registration>

<implements id=Automation type=Automation>
<property name=version>
<get/>
</property>
<property name=temp>
<get/>
<put/>
</property>
</implements>

<script language=JScript>

var version = "1.0.0";
var temp = "Bob String";

function get_version()
{
return version;
}

function get_temp()
{
return temp;
}

function put_temp(newValue)
{
temp = newValue;
}
</script>
</scriptlet>

PHWOAR! Find whewre its been generated to (path\monkey.sct). right click and "register" it with windows, if it has problems it will tell you.
Problems appear in the form of "[line,col] Problem text". I'll let you debug it.
Once its registered, the rest is easy.
Go into mIRC and use the excel example alias as a guide.

;monkey.Scriptlet
alias monkey {
;open a new monkey.Scriptlet
comopen monkey monkey.Scriptlet
;if it won't open, yell out and stop doign stuff
if ($comerr) { echo comopen failed | halt }
;annoy it for stuff
var %test = $com(monkey,version,3)
echo -a version: $com(monkey).result

var %test = $com(monkey,temp,3)
echo -a temp1: $com(monkey).result

;change the value of temp to fish
if ($com(monkey,temp,4,string,fish) == 0) {
echo -a Didn't work
halt
}

var %test = $com(monkey,temp,3)
echo -a temp2: $com(monkey).result
comclose monkey
}


As you can see, $com.result holds the returned data.
Muddle through that, my fingers are tired and I want pie.

Part 4: Where's my part 3?
Well if your sharp enough you'll have noticed that its missing someting, not just a part 3. All I've shown you is how to get and set properties in your COM object, not how to call methods. Or have I? I've shown you how to get/set properties through their METHODS, so you can make your own method calls to custom methods (functions). Here's a tip, tho, don't try to return anything funky! Stick to your basic types, and you'll be fine.

Part 5:Real world applications
What can you do in Jscript you can't do in mIRC:
Better maths object (ie proper Psuedorandom numbers!)
An arguments object - better than using $1- for stuff that needs switches
Better Boolean object (for when $iif just doesn't cut it)
Enumerator - enables you to use a collection with an index (array styles)
Arrays! (not 2d tho, sigh)
Easier activeX com object implementation (well, maybe...)
Better error handling
Functions as objects! This is good enough to include an example methinks:

Example 1
function add(x, y)
{
return(x + y); //Perform addition and return results.
}
Example 2
var add = new Function("x", "y", "return(x+y)");

In either case, you call the function with a line of code similar to the following:

add(2, 3);

A Global object
A slightly better regexp object (yes, OBJECT is better in this case sometimes)
More organised string handling (its an OBJECT! gasp!)
VBarrays even



Of course its up to you to decide whats the _best_ option for the task, the script, and your ability. You should script for the end user rather than for what looks good for you.
If this is confusing, yes, look for a second edition (much cleaner, and neater. I'll probably even post it on my website.) Email me @ gekko_dev@hotmail.com if you have questions or queries.

Re: How (In Theory) to use OTHER scripting languag #20583 05/05/03 08:25 AM
Joined: Dec 2002
Posts: 1,237
T
The_Game Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Dec 2002
Posts: 1,237
*pauses to grab a beer and a bite to eat before continuing to read further*

Re: How (In Theory) to use OTHER scripting languag #20584 06/05/03 04:32 AM
Joined: Feb 2003
Posts: 309
C
CloCkWeRX Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Feb 2003
Posts: 309
well, i'm fed up here its shifting its rantyness to mIRCscripts.org 's POST YOUR TUTORIAL forum.

Page 2 of 2 1 2