Does JScript.NET have a "main()" function for global arguments?http://forums.asp.net/t/450448.aspx/1?Does+JScript+NET+have+a+main+function+for+global+arguments+Mon, 08 Mar 2004 00:32:44 -0500450448450448http://forums.asp.net/p/450448/450448.aspx/1?Does+JScript+NET+have+a+main+function+for+global+arguments+Does JScript.NET have a "main()" function for global arguments? I think I posted this question before, but anyway.. When coding JScript for the CLS, does JScript have a &quot;main()&quot; function like in C# or C&#43;&#43;? I haven't been able to find one or anything like it in the SDK documentation. 2004-01-22T00:44:22-05:00451150http://forums.asp.net/p/450448/451150.aspx/1?Re+Does+JScript+NET+have+a+main+function+for+global+arguments+Re: Does JScript.NET have a "main()" function for global arguments? <pre class="prettyprint">[System.STAThread()] public static void main(String[] args) { Application.Run(new Form1()); }</pre> All that you need to do is change that statement to the equive of JScript. There just has to be the System.STAThread() on top of a static method. I am not sure if it has to be called main but I don't think so. 2004-01-22T16:09:25-05:00463637http://forums.asp.net/p/450448/463637.aspx/1?What+does+this+do+What does this do? I have tried this, but I can't seem to get it to work. JScript attaches attributes to functions with the attribute name and the keyword &quot;Attribute&quot;. ie: STAThreadAttribute, not with the square braces [], and placing a function parameter argument block doesn't seem to work. THe compiler generates: Bad function calling. Can you explaing this? 2004-02-03T23:58:41-05:00463696http://forums.asp.net/p/450448/463696.aspx/1?Re+What+does+this+do+Re: What does this do? Can you post your code? 2004-02-04T01:26:00-05:00464925http://forums.asp.net/p/450448/464925.aspx/1?Re+What+does+this+do+Re: What does this do? I can only post the main function part of it only, the rest is probably to big to fit on screen: (and yes, the main part is inside a class declaration) STAThreadAttribute(); public function main() : int { Console.WriteLine(&quot;Hello: test&quot; &#43; var_IsOn); ask(); wcalcd(); } This without the STAThreadAttribute does not generate any errors, but the main function is not called unless a statement is place at the very top of the source code outside any class or function declarations. 2004-02-05T02:06:25-05:00465232http://forums.asp.net/p/450448/465232.aspx/1?Re+What+does+this+do+Re: What does this do? You need to make the main() function static, this is because the method is not accessable unless the object is created and since the main() method is suppose to create the object you sort of have a Catch22. 2004-02-05T11:45:28-05:00465343http://forums.asp.net/p/450448/465343.aspx/1?Re+What+does+this+do+Re: What does this do? A good reference is http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vxorilanguageequivalentskeywords.asp?frame=true and http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vxgrfLanguageEquivalents.asp?frame=true <pre class="prettyprint">STAThreadAttribute(); public <b>static</b> function main() : int { Console.WriteLine(&quot;Hello: test&quot; &#43; var_IsOn); ask(); wcalcd(); }</pre> 2004-02-05T13:31:39-05:00468112http://forums.asp.net/p/450448/468112.aspx/1?Re+What+does+this+do+Re: What does this do? Modifying the main function making it static doesn't seem to resolve all the issues, it resolves all but one, stating where I declared the STAThreadAttribute(); as a syntax error. JS1002: Syntax Error (line 230, 1) can you explain this too? 2004-02-09T00:27:48-05:00468451http://forums.asp.net/p/450448/468451.aspx/1?Re+What+does+this+do+Re: What does this do? Try this. I don't think you need the attribute at the end of the attribute but that wouldn't cause the problem. I think it was hte semi colon you put on it. <pre class="prettyprint">STAThread() public static function main() : int { Console.WriteLine(&quot;Hello: test&quot; &#43; var_IsOn); ask(); wcalcd(); }</pre> Hope this works. Can I ask you one question? Why are you using JScript, when you could just as easily use C#? You would have the use of a couple great IDE's #Develop (Free), VS.Net, or Borland. Also if you want you can take in an array of strings in the main method if you want arguments passed from the command line. Well good luck. 2004-02-09T11:39:40-05:00470617http://forums.asp.net/p/450448/470617.aspx/1?In+answer+to+your+questionIn answer to your question You raise many valid points Mr Nberardi about using C# as an alternative, as I have reviewed the language specifications for C# in documentation, and yes, I could just as easily use C#, but my first ever language I ever learnt was JScript, and when I found out Microsoft ported JScript as a compiled executable form, I was quite estatic about creating my own applications in exe form without learning another language. But I have written alot of, somewhat rudimentary applications, in JScript.NET (because I didn't know if JScript.NET had an application entry point), and although I probably could easily leverage the power of C#, I would prefer JScript.NET over the rest as thats the first language I was first acustomed to. <p>I haven't tried your solution yet Mr nberardi cause I'm not at home and these computers don't have the .NET Framework installed, but I do hope it does work.</p> 2004-02-11T00:24:09-05:00470639http://forums.asp.net/p/450448/470639.aspx/1?Re+In+answer+to+your+questionRe: In answer to your question Oh no I wasn't advocating you change if that is what you really like. But I don't think the shock value is going to be very high going from JScript to C#. Plus with a language like C# you get the Free IDE's that really kick butt like #Develop. But if that is what you like more power to you. 2004-02-11T00:41:26-05:00470689http://forums.asp.net/p/450448/470689.aspx/1?Re+In+answer+to+your+questionRe: In answer to your question yes nberardi, I know you weren't advocating it, it was just FYI. However I'm quite interested in this free IDE for C#, where can I find #Develop? 2004-02-11T01:58:15-05:00470996http://forums.asp.net/p/450448/470996.aspx/1?Re+In+answer+to+your+questionRe: In answer to your question http://www.icsharpcode.net/OpenSource/SD/Default.aspx 2004-02-11T11:39:29-05:00471769http://forums.asp.net/p/450448/471769.aspx/1?Re+In+answer+to+your+questionRe: In answer to your question I tried your solution and found the answer to my problem: I had made the main function static, you can't call non-static functions from a static scope: static function main() { ....so on.... ask(); ....so on.... } I needed to create a new instance of the Calculator class and use that to call further functions. This resolved all my problems. Including the STAThread(); bit. I don't know why the compiler said there was an error on that same line, but anyway. However, there is one problem at execution. Nothing appears to happen! It enters the application, shows one blank line and then exits? I don't suppose you can explain this, can you? 2004-02-12T00:33:34-05:00471844http://forums.asp.net/p/450448/471844.aspx/1?Re+In+answer+to+your+questionRe: In answer to your question normally what gets done in the Main() you run the following Application.Run(new MyForm()); 2004-02-12T03:10:53-05:00498557http://forums.asp.net/p/450448/498557.aspx/1?Excuse+me+Excuse me... ...but mr nberardi, I was just wondering where you got the information to attach the STAThread attribute to my original question? From a web site or something? It's just out of curiosity, but I'd really appreciate it if you told me. 2004-03-07T23:18:41-05:00498583http://forums.asp.net/p/450448/498583.aspx/1?Re+Excuse+me+Re: Excuse me... They always add it on in VS.Net. Also Main should always be static so it can be created. And all that should be in Main() is usally Application.Run(new MyForm()) 2004-03-08T00:32:44-05:00