UberFoX Posted August 18, 2013 Author Share Posted August 18, 2013 Cripes! Looks rather impressive. EDIT: http://uberfox.no-ip.org/Sputnik/wiki/index.php/Class_Reference pbject-oriented lol yea forgive all spelling errors I'm sure the wiki is full of them. I add stuff to wiki as I go along sometimes at like 4 AM I will fix any issues you point out or if you want to grammar nazi I could give you edit rights. Link to comment Share on other sites More sharing options...
UberFoX Posted August 18, 2013 Author Share Posted August 18, 2013 (edited) Can scripts compile into executables? Yes they can. You run Compile.exe and select your script then enter an exe name to output. If you make a GUI program you use CompileW.exe (Compile.exe will produce a program with black console box) The exes dont need any files from Sputnik to run and any includes you added will be automatically added to the program. (However it is best to place the includes at the top of the program rather than hidden inside an If statement somewhere so the compiler sees a use in adding it). The compiler itself is acutally a Sputnik script (compiled by itself)...... It supports many types of things such as including images etc etc. Also @Compiled gets set to true if running from a compiled exe. It's worth noting when a scripy is turned into an exe (in the current state of Sputnik) all the text from your project is saved to the compiled exe (in compressed form). I have not got around to making it obfuscate the source code yet although if anybody wants to extend the compiler to do that youre more than welcome. Sputniks parser is very powerful and very very fast the time to load a compiled exe is same as running your script normally. Edited August 18, 2013 by UberFoX Link to comment Share on other sites More sharing options...
UberFoX Posted August 18, 2013 Author Share Posted August 18, 2013 UberFoX, Welcome to the AutoIt forum. I have lifted your "New Member" posting restriction - and with your current post count you should also have "Edit" permissions now (the button should appear at bottom right of the post). And could I remind people about this announcement. Here is a perfect example where we would be happy to help - if someone lets us know that we need to. Please forgive the aggressive tone taken by Edano - I hope that his intervention was a clumsy attempt to defend AutoIt against your mistaken interpretation of some of it's capabilities rather than a direct attack on your project. I am sure the majority of members will be very interested in seeing what is obviously the result of a great deal of work on your part. M23 Thanks! I remember reading the AutoIt help file about GUICreate, GUICreateButton etc and it never once mentioned you could make more than one window which is why I put that statement. Another reason is GUICreateButton does not accept a *GUI Window* as part of its parameters (like Sputnik does) which also fueled the idea that AutoIt doesn't do that. My bad. Link to comment Share on other sites More sharing options...
DatMCEyeBall Posted August 18, 2013 Share Posted August 18, 2013 Remember the GuiSwitch() command? Use it to "switch" to another window before creating the button. "Just be fred, all we gotta do, just be fred." -Vocaliod "That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha @tabhooked Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation Link to comment Share on other sites More sharing options...
UberFoX Posted August 18, 2013 Author Share Posted August 18, 2013 Remember the GuiSwitch() command? Use it to "switch" to another window before creating the button. Yea I know how to do it now thanks ot Edano. Link to comment Share on other sites More sharing options...
UberFoX Posted August 18, 2013 Author Share Posted August 18, 2013 (edited) One issue people have been getting is since Sputnik uses PHP/C style syntax the ; has become very important (where as in AutoIt its an optional comment). If you do a MsgBox its: MsgBox("Hello World"); Since the syntax is more flexible you can write things in many different ways for example: expandcollapse popup$a = 100; // ; ?: operator MsgBox($a == 100 ? "Hello World" : "error"); // ; ?! operator MsgBox($a == 100 !! "error" : "Hello World"); // ; The right way (to me) how to use cirly braces if($a == 100) { MsgBox("Hello World"); } // ; The wrong way (to me) how to use cirly braces if($a == 100) { MsgBox("Hello World"); } // ; The very wrong way (to me) how to use cirly braces if($a == 100) { MsgBox("Hello World");} // ; An interesting and sometimes needed way (one line it all) if($a == 100) { MsgBox("Hello World"); } // ; Making the if followed instantly by the statement to execute on true if($a == 100) MsgBox("Hello World"); // ; Making the statement to execute if the following if is true MsgBox("Hello World") if($a == 100); // ; same as above // ; Sputnik also supports Unless (same as Perl) example // ; Triggers UNLESS $a is 100 unless($a == 100) { MsgBox("Hello World"); } unless($a == 100) { MsgBox("Hello World"); } unless($a == 100) MsgBox("Hello World"); MsgBox("Hello World") unless($a == 100); // ; The same is true for everything It adopts the Perl idea of *There's more than one way to do it". That makes it possible to write very consistent code, very efficient code or just extremely unreadable gibberish that looks like a series of nonsense yet prints an entire christmas poem lol. I do have a GUI Builder I was working on its not finished yet but it can produce basic GUIs (with working tabs etc) (its made in Sputnik). It would be nice if somebody wants to help complete it and help out with other library/tools (obfuscator/winapi libraries etc). A Vector3 class in Sputnik to give an idea how to produce classes with operator overloading and cast overloading etc. Which will prove useful in helping with GUI builder and so on. expandcollapse popupClass Vec3 { my $x = 0; my $y = 0; my $z = 0; // ; The constructor can either clone a Vector3 or create a new one example // ; $v2 = new Vec3( $v1 ) // ; Will clone a vector $v1 but only if theres only 1 param // ; If theres more than 1 param it will simply create a new vector using whatever variables it can find or use defaults Function __construct($x = 0, $y = 0, $z = 0) { If( UBound(@args) == 1 && isVarClass($x, 'vec3' ) ) { $this->$x = $x->$x; $this->$y = $x->$y; $this->$z = $x->$z; } else { $this->$x = (double)$x; $this->$y = (double)$y; $this->$z = (double)$z; } } // ; Return a string of all the vectors variables to print or so Function toString() { return "($x, $y, $z)"; } // ; Return a 3 element array of this Vector3 Function GetArray() { return array($x, $y, $z); } // ; Magnitude (aka. length or absolute value) of the Vector3 Function Magnitude() { return Sqrt ( SumComponentSqrs() ); } // ; The length of this Vector Function Length() { return Sqrt($x * $x + $y * $y); } // ; The squared length of this Vector Function LengthSquared() { return ($x * $x + $y * $y); } // ; Find the distance between two Vectors // ; Pythagoras theorem on two Vectors Static Function Distance(Vec3 $v1, Vec3 $v2) { return Sqrt ( ($v1->$x - $v2->$x) * ($v1->$x - $v2->$x) + ($v1->$y - $v2->$y) * ($v1->$y - $v2->$y) + ($v1->$z - $v2->$z) * ($v1->$z - $v2->$z) ); } // ; Find the distance between this vector and another Function Distance(Vec3 $other) { return self::Distance($this, $other); } // ; Determine the cross product of two Vectors // ; Determine the vector product // ; Determine the normal vector (Vector3 90° to the plane) Static Function CrossProduct(Vec3 $v1, Vec3 $v2) { return new Vec3( $v1->$y * $v2->$z - $v1->$z * $v2->$y, $v1->$z * $v2->$x - $v1->$x * $v2->$z, $v1->$x * $v2->$y - $v1->$y * $v2->$x); } // ; Determine the cross product of this Vector3 and another Function CrossProduct(Vec3 $other) { return self::CrossProduct($this, $other); } // ; Determine the dot product of two Vectors Static Function DotProduct(Vec3 $v1, Vec3 $v2) { return ( $v1->$x * $v2->$x + $v1->$y * $v2->$y + $v1->$z * $v2->$z ); } // ; Determine the dot product of this Vector3 and another Function DotProduct(Vec3 $other) { return self::DotProduct($this, $other); } // ; Determine the mixed product of three Vectors Static Function MixedProduct(Vec3 $v1, Vec3 $v2, Vec3 $v3) { return DotProduct(CrossProduct($v1, $v2), $v3); } // ; Determine the mixed product of this and 2 other Vectors Function MixedProduct(Vec3 $other_v1, Vec3 $other_v2) { return self::DotProduct(self::CrossProduct($this, $other_v1), $other_v2); } // ; The individual multiplication to a power of a Vector3's components Static Function PowComponents(Vec3 $v1, $power) { return ( new Vec3 ( Pow($v1->$X, $power), Pow($v1->$Y, $power), Pow($v1->$Z, $power) ) ); } // ; The individual multiplication to a power of this Vector3's components Function PowComponents($power) { my $v1 = self::PowComponents($this, $power); $x = $v1->$x; $y = $v1->$y; $z = $v1->$z; unset($v1); } // ; Get the normalized vector of a vector // ; Get the unit vector // ; Scale a Vector3 so that the magnitude is 1 Static Function Normalize(Vec3 $v1) { // ; Check for divide by zero errors if ( $v1->Magnitude() == 0 ) { throw new exception("DivideByZeroException @ _Normalize"); } else { // ; find the inverse of the vectors magnitude $inverse = 1 / $v1->Magnitude(); return new Vec3($v1->$x * $inverse, $v1->$y * $inverse, $v1->$z * $inverse); } } // ; Get the normalized vector Function Normalize() { my $v1 = self::Normalize($this); $x = $v1->$x; $y = $v1->$y; $z = $v1->$z; unset($v1); } // ; Multiply - Returns the dot product: vector1.X*vector2.X + vector1.Y*vector2.Y Static Function Multiply(Vec3 $vector1, Vec3 $vector2) { return $vector1->$x * $vector2->$x + $vector1->$y * $vector2->$y; } // ; Determinant - Returns the determinant det(vector1, vector2) Static Function Determinant(Vec3 $vector1, Vec3 $vector2) { return $vector1->$x * $vector2->$y - $vector1->$y * $vector2->$x; } // ; The sum of a Vector3's squared components Static Function SumComponentSqrs(Vec3 $v1) { return self::SqrComponents($v1)->SumComponents(); } // ; The sum of this Vector3's squared components Function SumComponentSqrs() { return self::SumComponentSqrs($this); } // ; A Vector3's components squared Static Function SqrComponents(Vec3 $v1) { return new Vec3($v1->$x * $v1->$x, $v1->$y * $v1->$y, $v1->$z * $v1->$z); } // ; The individual square root of this Vector3's components Function SqrComponents() { my $v1 = self::SqrComponents($this); $x = $v1->$x; $y = $v1->$y; $z = $v1->$z; unset($v1); } // ; The sum of a Vector3's components Static Function SumComponents(Vec3 $v1) { return ($v1->$x + $v1->$y + $v1->$z); } // ; The sum of this Vector3's components Function SumComponents() { return self::SumComponents($this); } // ; The angle in degrees between 2 vectors Static Function AngleBetween(Vec3 $vector1, Vec3 $vector2) { my $sin = $vector1->$x * $vector2->$y - $vector2->$x * $vector1->$y; my $cos = $vector1->$x * $vector2->$x + $vector1->$y * $vector2->$y; return Atan($sin, $cos) * (180 / @PI); } // ; The angle in degrees between this and another vector Function AngleBetween(Vec3 $vector1) { my $sin = $x * $vector1->$y - $vector1->$x * $y; my $cos = $x * $vector1->$x + $y * $vector1->$y; return Atan($sin, $cos) * (180 / @PI); } // ; Find the angle between two Vectors Static Function Angle(Vec3 $v1, Vec3 $v2) { return Acos(self::Normalize($v1)->DotProduct(self::Normalize($v2))); } // ; Find the angle between this Vector3 and another Function Angle(Vec3 $other) { return self::Angle($this, $other); } // ; Rotates a Vector3 around the Y axis Static Function Yaw(Vec3 $v1, $degree) { return new Vec3 ( ($v1->$z * Sin($degree)) + ($v1->$x * Cos($degree)), $v1->$y, ($v1->$z * Cos($degree)) - ($v1->$x * Sin($degree)) ); } // ; Rotates this Vector3 around the Y axis Function Yaw($degree) { my $v1 = self::Yaw($this, $degree); $x = $v1->$x; $y = $v1->$y; $z = $v1->$z; unset($v1); } // ; Rotates a Vector3 around the X axis Static Function Pitch(Vec3 $v1, $degree) { return new Vec3 ( $v1->$x, ($v1->$y * Cos($degree)) - ($v1->$z * Sin($degree)), ($v1->$y * Sin($degree)) + ($v1->$z * Cos($degree)) ); } // ; Rotates this Vector3 around the X axis Function Pitch($degree) { my $v1 = self::Pitch($this, $degree); $x = $v1->$x; $y = $v1->$y; $z = $v1->$z; unset($v1); } // ; Rotates a Vector3 around the Z axis Static Function Roll(Vec3 $v1, $degree) { return new Vec3 ( ($v1->$x * Cos($degree)) - ($v1->$y * Sin($degree)), ($v1->$x * Sin($degree)) + ($v1->$y * Cos($degree)), $v1->$z ); } // ; Rotates this Vector3 around the Z axis Function Roll($degree) { my $v1 = self::Roll($this, $degree); $x = $v1->$x; $y = $v1->$y; $z = $v1->$z; unset($v1); } // ; Compares the magnitude of two Vectors and returns the greater Vector3 Static Function Max(Vec3 $v1, Vec3 $v2) { if ($v1 >= $v2){return $v1;} return $v2; } // ; Compares the magnitude of this and another and returns the greater Vector3 Function Max(Vec3 $other) { return self::Max($this, $other); } // ; Compares the magnitude of two Vectors and returns the lesser Vector3 Static Function Min(Vec3 $v1, Vec3 $v2) { if ($v1 <= $v2){return $v1;} return $v2; } // ; Compares the magnitude of this and another and returns the lesser Vector3 Function Min(Vec3 $other) { return self::Min($this, $other); } // ; Find the absolute value of a Vector3 Static Function Abs(Vec3 $v1) { return $v1->Magnitude(); } // ; Find the absolute value of this Vector3 Function Abs() { return $this->Magnitude(); } // ; / Checks if a vector is a unit vector Static Function IsUnitVector(Vec3 $v1) { return Abs($v1->Magnitude() -1) <= @Double_Epsilon; } // ; / Checks if this vector is a unit vector Function IsUnitVector() { return Abs($this->Magnitude() -1) <= @Double_Epsilon; } // ; / Checks if two Vectors are perpendicular // ; / Checks if two Vectors are orthogonal // ; / Checks if one Vector3 is the Normal of the other Static Function IsPerpendicular(Vec3 $v1, Vec3 $v2) { return $v1->DotProduct($v2) == 0; } // ; / Checks this Vector and another are perpendicular // ; / Checks this Vector and another are orthogonal // ; / Checks this Vector is the Normal of the other Function IsPerpendicular(Vec3 $other) { return self::IsPerpendicular($this, $other); } // ; / Checks if a face normal vector represents back face // ; / Checks if a face is visible, given the line of sight Static Function IsBackFace(Vec3 $normal, Vec3 $lineOfSight) { return $normal->DotProduct($lineOfSight) < 0; } // ; / Checks if a face normal vector represents back face // ; / Checks if a face is visible, given the line of sight Function IsBackFace(Vec3 $lineOfSight) { return self::IsBackFace($this, $lineOfSight); } // ; Creates a look vector (Heading) of a given Yaw and Pitch Static Function GetLookVector($Yaw, $Pitch) { return new Vec3(-Sin($Yaw) * Cos($Pitch), Sin($Pitch), -Cos($Yaw) * Cos($Pitch)); } // ; / Retuns the smallest vector possible (based on the double precision floating point structure) for you to use Static Function MinValue() { return new Vec3(@Double_Min, @Double_Min, @Double_Min); } // ; / Retuns the largest vector possible (based on the double precision floating point structure) for you to use Static Function MaxValue() { return new Vec3(@Double_Max, @Double_Max, @Double_Max); } // ; / Retuns an empty Vector3 object for you to use Static Function Zero() { return new Vec3(0.0, 0.0, 0.0); } Operator "+" ($vec) { If ( isVarClass($vec, "vec3") ) { $this->$x += $vec->$x; $this->$y += $vec->$y; $this->$z += $vec->$z; } else { $this->$x += $vec; $this->$y += $vec; $this->$z += $vec; } } Operator "+=" ($vec) { If ( isVarClass($vec, "vec3") ) { $this->$x += $vec->$x; $this->$y += $vec->$y; $this->$z += $vec->$z; } else { $this->$x += $vec; $this->$y += $vec; $this->$z += $vec; } } Operator "*" ($vec) { If ( isVarClass($vec, "vec3") ) { $this->$x *= $vec->$x; $this->$y *= $vec->$y; $this->$z *= $vec->$z; } else { $this->$x *= $vec; $this->$y *= $vec; $this->$z *= $vec; } } Operator "*=" ($vec) { If ( isVarClass($vec, "vec3") ) { $this->$x *= $vec->$x; $this->$y *= $vec->$y; $this->$z *= $vec->$z; } else { $this->$x *= $vec; $this->$y *= $vec; $this->$z *= $vec; } } Operator "/" (Vec3 $vec) { If ( isVarClass($vec, "vec3") ) { $this->$x /= $vec->$x; $this->$y /= $vec->$y; $this->$z /= $vec->$z; } else { $this->$x /= $vec; $this->$y /= $vec; $this->$z /= $vec; } } Operator "/=" (Vec3 $vec) { If ( isVarClass($vec, "vec3") ) { $this->$x /= $vec->$x; $this->$y /= $vec->$y; $this->$z /= $vec->$z; } else { $this->$x /= $vec; $this->$y /= $vec; $this->$z /= $vec; } } Operator "-" (Vec3 $vec) { If ( isVarClass($vec, "vec3") ) { $this->$x -= $vec->$x; $this->$y -= $vec->$y; $this->$z -= $vec->$z; } else { $this->$x -= $vec; $this->$y -= $vec; $this->$z -= $vec; } } Operator "-=" (Vec3 $vec) { If ( isVarClass($vec, "vec3") ) { $this->$x -= $vec->$x; $this->$y -= $vec->$y; $this->$z -= $vec->$z; } else { $this->$x -= $vec; $this->$y -= $vec; $this->$z -= $vec; } } Operator "**" (Vec3 $vec) { If ( isVarClass($vec, "vec3") ) { $this->$x **= $vec->$x; $this->$y **= $vec->$y; $this->$z **= $vec->$z; } else { $this->$x **= $vec; $this->$y **= $vec; $this->$z **= $vec; } } Operator "**=" (Vec3 $vec) { If ( isVarClass($vec, "vec3") ) { $this->$x **= $vec->$x; $this->$y **= $vec->$y; $this->$z **= $vec->$z; } else { $this->$x **= $vec; $this->$y **= $vec; $this->$z **= $vec; } } Operator "%" (Vec3 $vec) { If ( isVarClass($vec, "vec3") ) { $this->$x %= $vec->$x; $this->$y %= $vec->$y; $this->$z %= $vec->$z; } else { $this->$x %= $vec; $this->$y %= $vec; $this->$z %= $vec; } } Operator "%=" (Vec3 $vec) { If ( isVarClass($vec, "vec3") ) { $this->$x %= $vec->$x; $this->$y %= $vec->$y; $this->$z %= $vec->$z; } else { $this->$x %= $vec; $this->$y %= $vec; $this->$z %= $vec; } } // ; Compare two Vectors for equality. Operator "==" (Vec3 $vec) { return ( Abs($this->$x - $vec->$x) <= @Double_Epsilon && Abs($this->$y - $vec->$y) <= @Double_Epsilon && Abs($this->$z - $vec->$z) <= @Double_Epsilon ); } // ; Compare two Vectors for not equality. Operator "!=" (Vec3 $vec) { return !($this == $vec); } // ; Compare the magnitude of two Vectors (less than) Operator "<" (Vec3 $vec) { return $this->SumComponentSqrs() < $vec->SumComponentSqrs(); } // ; Compare the magnitude of two Vectors (greater than) Operator ">" (Vec3 $vec) { return $this->SumComponentSqrs() > $vec->SumComponentSqrs(); } // ; Compare the magnitude of two Vectors (less than or equal to) Operator "<=" (Vec3 $vec) { return $this->SumComponentSqrs() <= $vec->SumComponentSqrs(); } // ; Compare the magnitude of two Vectors (greater than or equal to) Operator ">=" (Vec3 $vec) { return $this->SumComponentSqrs() >= $vec->SumComponentSqrs(); } // ; Compare the magnitude of two Vectors (greater than or lower than) Operator "<>" (Vec3 $vec) { return $this < $vec || $this > $vec; } }; Edited August 18, 2013 by UberFoX Link to comment Share on other sites More sharing options...
FaridAgl Posted August 18, 2013 Share Posted August 18, 2013 I think a good editor with syntax highlight and intellisense is the most required thing for now. Also an installer is a good idea, with adding the compile option to right-click context menu. Keep it up. http://faridaghili.ir Link to comment Share on other sites More sharing options...
UberFoX Posted August 18, 2013 Author Share Posted August 18, 2013 (edited) I think a good editor with syntax highlight and intellisense is the most required thing for now. Also an installer is a good idea, with adding the compile option to right-click context menu. Keep it up. I'm too busy to make a text editor for it etc however I recommend using Notepad++ and setting the syntax to PHP since Sputnik syntax and function names are VERY similar to PHP so you get full syntax highlighting for MOST things. Just make sure you add <? at the top of your script and ?> at the bottom for PHP syntax highlight to work. Evenutally I or somebody will make a good editor but I'm too busy coding Sputnik to do that. (I do have an incomplete yet working GUI Builder that also needs finishing but I'm too busy coding Sputnik to do it... If somebody can either with any of the above that would be nice...) (I recommend copy and pasting code from the Wiki to avoid making mistakes for now since Notepad++ doesnt recognize intellisense) The compilation is not standardized yet and may change in the future so adding it to context might not be the best idea. Edited August 18, 2013 by UberFoX Link to comment Share on other sites More sharing options...
monoceres Posted August 18, 2013 Share Posted August 18, 2013 Developing languages is very fun! I'm currently doing that also. I'm mostly interested in implementation of Sputnik: What language is it written in? Are you using a parser generator or have you written a custom parser? What kind of garbage collecting are you doing, reference counting? And if so, have thought about cycles and how reference counting affects multi-threading? Have you optimized for speed, and what are currently the biggest bottlenecks in the language. Unicode support? What are your thoughts in platform dependence? Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
UberFoX Posted August 18, 2013 Author Share Posted August 18, 2013 (edited) Developing languages is very fun! I'm currently doing that also. I'm mostly interested in implementation of Sputnik: 1 What language is it written in? 2 Are you using a parser generator or have you written a custom parser? 3 What kind of garbage collecting are you doing, reference counting? And if so, have thought about cycles and how reference counting affects multi-threading? 4 Have you optimized for speed, and what are currently the biggest bottlenecks in the language. 5 Unicode support? 6 What are your thoughts in platform dependence? 1. It is written in C# fully (mostly because it was never intended to grow so big a bit like how minecraft is java) (yet this is a non issue and speed wise its similar to PHP). 2 It uses a customized/modified/improved version of the GoldParser engine (you can even make use of Sputniks own parser to parse anything you want (its like Regex on steroids) using see the example here: http://uberfox.no-ip.org/Sputnik/wiki/index.php/Core_Function_Parser_Engine this lets you create complex and highly detailed parsers VERY VERY easily using a bisson style easy to use series of classes) (Also you can create a series of parser classes in Sputnik to parse Sputnik code with Sputnik.... It doesn't hold back any power) the parser is VERY fast and can parse 10s of thousands of lines very snappy. (The example shown above is included with Sputnik in the Examples folder) 3. The language automatically handles garbage collection of all objects and variables and frees objects as needed however you can specifically demand something gets freed instantly using the unset($variable) alternatively you run gc(); command to force an immediate dispose of all objects floating in the garbage collector. 4. It was designed with speed in mind and it is very fast there is room for improvement but right now its similar to PHP in terms of speed I suppose you can do tests and benchmark to AutoIt and find any bottlenecks that I should fix. I'm not aware of any bottlenecks that will impact performance at this time but if you find them I will be happy to fix them. 5. The whole language is Unicode every string is Unicode this is default and unchangable however you can of course save to file, load from file and use DLLCall passing the strings as ASCII as you see fit. 6. Currently it is limited to Windows only but it could be made to run on Linux/Mac using the MONO framework (With a bit of effort involved). Edited August 18, 2013 by UberFoX Link to comment Share on other sites More sharing options...
monoceres Posted August 18, 2013 Share Posted August 18, 2013 I see. I think just C# answered several of my questions Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
FaridAgl Posted August 18, 2013 Share Posted August 18, 2013 Does that mean Sputnik needs .Net Framework? I have .Net Framework installed on my windows so I can't test! http://faridaghili.ir Link to comment Share on other sites More sharing options...
UberFoX Posted August 18, 2013 Author Share Posted August 18, 2013 Does that mean Sputnik needs .Net Framework? I have .Net Framework installed on my windows so I can't test! Yes it uses .NET 3.5 (minimal version). Link to comment Share on other sites More sharing options...
UberFoX Posted August 18, 2013 Author Share Posted August 18, 2013 (edited) I see. I think just C# answered several of my questions You can also inline C code into your Sputnik scripts Example: Include("TCC.spk", true); my $source = @" #include <stdio.h> int main(int a) { printf(""Value is '%d' Hello from C++\n"", a); //system(""pause""); return 3; } "; my $newC = new InlineC(); $newC->SetOutputType($TCC_OUTPUT_MEMORY); $newC->AddSource($source); $newC->SetExecute("Int32", "i"); my $ret = $newC->Execute(999); say "Return: $ret"; You can also create brand new C exes and dlls using the inline C functions (This makes use of TinyC) The C code is compiled to binary in memory and executed you can set what functions to call and what parameters to pass and what return value to expect and so on. Also you can use DLL files like in AutoIt with DLLCall however Sputnik has DLLImport that lets you import thousands of functions from hundreds of DLLs at once OR create a new DLL from all them imports so you load that DLL later and gain all them functions again instantly. This way you could load 50,000 APIs in a fraction of a second. DLLImport and DLLCall etc is on the wiki. DllImport( array ( '@AddBefore:w_', // Makes the APIs start with w_ so MessageBox = w_MessageBox 'API.dll:API_DLL_Source.cs', // Tells it to produce a DLL and the Source code to it //'API.dll', // Tells it to produce only the dll // User32.dll array('User32.dll', 'MessageBox', 'Int32', 'ippi', 'Unicode'), array('User32.dll', 'GetMessageExtraInfo', 'Int32', '', ''), array('User32.dll', 'MapVirtualKey', 'UInt32', 'II', ''), array('User32.dll', 'keybd_event', '', 'bbIi', ''), array('User32.dll', 'VkKeyScan', 'Int16', 's', ''), array('User32.dll', 'SendInput', 'UInt32', 'Iti', ''), array('User32.dll', 'GetAsyncKeyState', 'Int16', 'I', ''), array('User32.dll', 'GetKeyState', 'Int16', 'I', ''), // Kernel32.dll array('Kernel32.dll', 'GetTickCount', 'Int32', '', ''), array('Kernel32.dll', 'GetTickCount64', 'Int64', '', '') ) ); DllImport( array ( // User32.dll array('User32.dll', 'MessageBox', 'Int32', 'ippi', 'Unicode'), array('User32.dll', 'GetMessageExtraInfo', 'Int32', '', ''), array('User32.dll', 'MapVirtualKey', 'UInt32', 'II', ''), array('User32.dll', 'keybd_event', '', 'bbIi', ''), array('User32.dll', 'VkKeyScan', 'Int16', 's', ''), array('User32.dll', 'SendInput', 'UInt32', 'Iti', ''), array('User32.dll', 'GetAsyncKeyState', 'Int16', 'I', ''), array('User32.dll', 'GetKeyState', 'Int16', 'I', ''), // Kernel32.dll array('Kernel32.dll', 'GetTickCount', 'Int32', '', ''), array('Kernel32.dll', 'GetTickCount64', 'Int64', '', '') ) ); // Setup a few variables $MB_YESNO = 0x04; $MB_ICONINFORMATION = 0x40; $IDYES = 6; // Make the call $RetVal = w_MessageBox(0, "Hello There", "Title", $MB_YESNO | $MB_ICONINFORMATION); // ; An imported function from a DLL acts like a normal function and does not require DLLCall If ( $RetVal == $IDYES ) println("YES was pressed"); else println("NO was pressed"); Here is a Sputnik script that calls a C dll Its used as an example expandcollapse popup// ;Imports the DLL functions at runtime but making a DLL from DLLImport and using that instead would be alot faster DllImport( array ( // ;Objects array('test.dll', 'SendBool', 'void', 'b', 'Ansi:Cdecl'), array('test.dll', 'SendChar', 'void', 'c', 'Ansi:Cdecl'), array('test.dll', 'SendByte', 'void', 'B', 'Ansi:Cdecl'), array('test.dll', 'SendSByte', 'void', 'b', 'Ansi:Cdecl'), array('test.dll', 'SendInt16', 'void', 'L', 'Ansi:Cdecl'), array('test.dll', 'SendInt32', 'void', 'L', 'Ansi:Cdecl'), array('test.dll', 'SendInt64', 'void', 'L', 'Ansi:Cdecl'), array('test.dll', 'SendUInt16', 'void', 'L', 'Ansi:Cdecl'), array('test.dll', 'SendUInt32', 'void', 'L', 'Ansi:Cdecl'), array('test.dll', 'SendUInt64', 'void', 'L', 'Ansi:Cdecl'), array('test.dll', 'SendFloat', 'void', 'f', 'Ansi:Cdecl'), array('test.dll', 'SendDouble', 'void', 'd', 'Ansi:Cdecl'), array('test.dll', 'SendString', 'void', 'p', 'Ansi:Cdecl'), // ;Objects using return value array('test.dll', 'ReturnString', 'string', '', 'Ansi:Cdecl'), // ;Object using return value as pointer array('test.dll', 'ReturnStringPTR', '*string', '', 'Ansi:Cdecl'), // ;Objects as pointer (so the $variable is modifed in the DLL directly) array('test.dll', 'SendStringPTR', 'void', '*p', 'Ansi:Cdecl'), // ;Arrays array('test.dll', 'SendBoolArray', 'void', '%bi', 'Ansi:Cdecl'), array('test.dll', 'SendCharArray', 'void', '%ci', 'Ansi:Cdecl'), array('test.dll', 'SendByteArray', 'void', '%Bi', 'Ansi:Cdecl'), array('test.dll', 'SendSByteArray', 'void', '%bi', 'Ansi:Cdecl'), array('test.dll', 'SendInt16Array', 'void', '%si', 'Ansi:Cdecl'), array('test.dll', 'SendInt32Array', 'void', '%ii', 'Ansi:Cdecl'), array('test.dll', 'SendInt64Array', 'void', '%li', 'Ansi:Cdecl'), array('test.dll', 'SendUInt16Array', 'void', '%Si', 'Ansi:Cdecl'), array('test.dll', 'SendUInt32Array', 'void', '%Ii', 'Ansi:Cdecl'), array('test.dll', 'SendUInt64Array', 'void', '%Li', 'Ansi:Cdecl'), array('test.dll', 'SendFloatArray', 'void', '%fi', 'Ansi:Cdecl'), array('test.dll', 'SendDoubleArray', 'void', '%di', 'Ansi:Cdecl'), array('test.dll', 'SendStringArray', 'void', '%pi', 'Ansi:Cdecl') ) ); SendSingleObjects(); ReturningObjects(); ReturningObjectsAsPointers() ObjectsAsPointers(); SendingArrays(); Function SendSingleObjects() { inputc("Press any key to do singles objects"); cls(); // ;Single objects { // ;Send a Bool to the DLL say "Sending a Bool"; my $Value = true; SendBool( $Value ); say ""; } { // ;Send a Char to the DLL say "Sending a Char"; my $Value = 'S'; SendChar( $Value ); say ""; } { // ;Send a Byte to the DLL say "Sending a Byte"; my $Value = 77; SendByte( $Value ); say ""; } { // ;Send a SByte to the DLL say "Sending a SByte"; my $Value = 100; SendSByte( $Value ); say ""; } { // ;Send a Int16 to the DLL say "Sending a Int16"; my $Value = 300; SendInt16( $Value ); say ""; } { // ;Send a Int32 to the DLL say "Sending a Int32"; my $Value = 400; SendInt32( $Value ); say ""; } { // ;Send a Int64 to the DLL say "Sending a Int64"; my $Value = 500; SendInt64( $Value ); say ""; } { // ;Send a UInt16 to the DLL say "Sending a UInt16"; my $Value = 600; SendUInt16( $Value ); say ""; } { // ;Send a UInt32 to the DLL say "Sending a UInt32"; my $Value = 700; SendUInt32( $Value ); say ""; } { // ;Send a UInt64 to the DLL say "Sending a UInt64"; my $Value = 777; SendUInt64( $Value ); say ""; } { // ;Send a Float to the DLL say "Sending a Float"; my $Value = @PI / 2; SendFloat( $Value ); say ""; } { // ;Send a Double to the DLL say "Sending a Double"; my $Value = @PI; SendDouble( $Value ); say ""; } { // ;Send a String to the DLL say "Sending a String"; my $Value = "My String"; SendString( $Value ); say ""; } } Function ReturningObjects() { inputc("Press any key to do returning objects"); cls(); // ;Using return value { // ;Return a String from the DLL say "Returning a String"; my $value = ReturnString( ); say "Return value: $value"; say ""; } } Function ReturningObjectsAsPointers() { inputc("Press any key to do returning objects as pointers"); cls(); { // ;Return a String PTR from the DLL say "Returning a String PTR"; my $value = ReturnStringPTR( ); say "Return value: $value"; say ""; } } Function ObjectsAsPointers() { inputc("Press any key to do objects as pointer"); cls(); // ;Objects as pointer (so the $variable is modifed in the DLL directly) { // ;Send a String PTR to the DLL say "Sending a String pointer"; my $Value = "My String"; SendStringPTR( $Value ); say "String after modifed by DLL: $Value"; say ""; } } Function SendingArrays() { inputc("Press any key to do sending arrays to the DLL"); cls(); // ;Arrays { // ;Send an array of Bools to the DLL say "Sending Bool Array"; my $Value = array(true, false, true); SendBoolArray( $Value, uBound($Value) ); say ""; } { // ;Send an array of Chars to the DLL say "Sending Char Array"; my $Value = array('a', 'B', 'c'); SendCharArray( $Value, uBound($Value) ); say ""; } { // ;Send an array of Byte to the DLL say "Sending Byte Array"; my $Value = array(80, @Byte_Min, @Byte_Max); SendByteArray( $Value, uBound($Value) ); say ""; } { // ;Send an array of SByte to the DLL say "Sending SByte Array"; my $Value = array(70, @SByte_Min, @SByte_Max); SendSByteArray( $Value, uBound($Value) ); say ""; } { // ;Send an array of Int16 to the DLL say "Sending Int16 Array"; my $Value = array(90, @Int16_Min, @Int16_Max); SendInt16Array( $Value, uBound($Value) ); say ""; } { // ;Send an array of Int32 to the DLL say "Sending Int32 Array"; my $Value = array(90, @Int32_Min, @Int32_Max); SendInt32Array( $Value, uBound($Value) ); say ""; } { // ;Send an array of Int64 to the DLL say "Sending Int64 Array"; my $Value = array(100, @Int64_Min, @Int64_Max); SendInt64Array( $Value, uBound($Value) ); say ""; } { // ;Send an array of UInt16 to the DLL say "Sending UInt16 Array"; my $Value = array(101, @UInt16_Min, @UInt16_Max); SendUInt16Array( $Value, uBound($Value) ); say ""; } { // ;Send an array of UInt32 to the DLL say "Sending UInt32 Array"; my $Value = array(102, @UInt32_Min, @UInt32_Max); SendUInt32Array( $Value, uBound($Value) ); say ""; } { // ;Send an array of UInt64 to the DLL say "Sending UInt64 Array"; my $Value = array(103, @UInt64_Min, @UInt64_Max); SendUInt64Array( $Value, uBound($Value) ); say ""; } { // ;Send an array of Floats to the DLL say "Sending Float Array"; my $Value = array(1.2, @Float_Min, @Float_Max); SendFloatArray( $Value, uBound($Value) ); say ""; } { // ;Send an array of Doubles to the DLL say "Sending Double Array"; my $Value = array(@PI, @Double_Min, @Double_Max); SendDoubleArray( $Value, uBound($Value) ); say ""; } { // ;Send an array of Strings to the DLL say "Sending String Array"; my $Value = array("One", "Two", "Three"); SendStringArray( $Value, uBound($Value) ); say ""; } } Here is the C source code of the dll expandcollapse popup#include <stddef.h> #include <windows.h> #include <ctype.h> #include <memory.h> #include <stdlib.h> #define DLL_EXPORT __declspec(dllexport) DLL_EXPORT char* ReturnString () { return "Hello from DLL"; } DLL_EXPORT char* ReturnStringPTR () { char* newStr = (char*)malloc(200); memset(newStr, '\0', 200); strcpy (newStr,"New string"); strcat (newStr," - Hello"); return newStr; } DLL_EXPORT void SendBool (char x) { printf("Got: %s\n", x ? "true" : "false"); } DLL_EXPORT void SendChar (char x) { printf("Got: %c\n", x); } DLL_EXPORT void SendByte (char x) { printf("Got: %d\n", x); } DLL_EXPORT void SendSByte (unsigned char x) { printf("Got: %u\n", x); } DLL_EXPORT void SendInt16 (short x) { printf("Got: %d\n", x); } DLL_EXPORT void SendInt32 (int x) { printf("Got: %d\n", x); } DLL_EXPORT void SendInt64 (int64_t x) { printf("Got: %I64d\n", x); } DLL_EXPORT void SendUInt16 (uint16_t x) { printf("Got: %u\n", x); } DLL_EXPORT void SendUInt32 (uint32_t x) { printf("Got: %u\n", x); } DLL_EXPORT void SendUInt64 (uint64_t x) { printf("Got: %llu\n", x); } DLL_EXPORT void SendFloat (float x) { printf("Got: %g\n", x); } DLL_EXPORT void SendDouble (double x) { printf("Got: %g\n", x); } DLL_EXPORT void SendString (char* x) { printf("Got: %s\n", x); } DLL_EXPORT void SendStringPTR (char* x) { printf("Got as PTR: %s\n", x); for(int i = 0; i < strlen(x); i++) { x[i] = toupper(x[i]); } } DLL_EXPORT void SendStringArray (char* x[], int n) { for(int i = 0; i < n; i++) { printf("Array index [%d] : %s\n", i, x[i]); } } DLL_EXPORT void SendBoolArray (char x[], int n) { for(int i = 0; i < n; i++) { printf("Array index [%d] : %s\n", i, x[i] ? "true" : "false"); } } DLL_EXPORT void SendCharArray (char x[], int n) { for(int i = 0; i < n; i++) { printf("Array index [%d] : %c\n", i, x[i]); } } DLL_EXPORT void SendByteArray (char x[], int n) { for(int i = 0; i < n; i++) { printf("Array index [%d] : %d\n", i, x[i]); } } DLL_EXPORT void SendSByteArray (unsigned char x[], int n) { for(int i = 0; i < n; i++) { printf("Array index [%d] : %u\n", i, x[i]); } } DLL_EXPORT void SendInt16Array (short x[], int n) { for(int i = 0; i < n; i++) { printf("Array index [%d] : %d\n", i, x[i]); } } DLL_EXPORT void SendInt32Array (int x[], int n) { for(int i = 0; i < n; i++) { printf("Array index [%d] : %d\n", i, x[i]); } } DLL_EXPORT void SendInt64Array (int64_t x[], int n) { for(int i = 0; i < n; i++) { printf("Array index [%d] : %I64d\n", i, x[i]); } } DLL_EXPORT void SendUInt16Array (uint16_t x[], int n) { for(int i = 0; i < n; i++) { printf("Array index [%d] : %u\n", i, x[i]); } } DLL_EXPORT void SendUInt32Array (uint32_t x[], int n) { for(int i = 0; i < n; i++) { printf("Array index [%d] : %u\n", i, x[i]); } } DLL_EXPORT void SendUInt64Array (uint64_t x[], int n) { for(int i = 0; i < n; i++) { printf("Array index [%d] : %llu\n", i, x[i]); } } DLL_EXPORT void SendFloatArray (float x[], int n) { for(int i = 0; i < n; i++) { printf("Array index [%d] : %g\n", i, x[i]); } } DLL_EXPORT void SendDoubleArray (double x[], int n) { for(int i = 0; i < n; i++) { printf("Array index [%d] : %g\n", i, x[i]); } } Notice you can pass Arrays to DLLs and all kinds of stuff. So if you wanted maximal speed for a function you could use a C dll for it. Edited August 18, 2013 by UberFoX Link to comment Share on other sites More sharing options...
UberFoX Posted August 18, 2013 Author Share Posted August 18, 2013 (edited) As a side note Sputnik use mostly unsafe C# code so the char* etc is accessed directly for most of the functions and many other special ways to speed up the language as much as possible. References are passed around to speed things up too. Edited August 18, 2013 by UberFoX Link to comment Share on other sites More sharing options...
Digisoul Posted August 19, 2013 Share Posted August 19, 2013 1st of all your project is great and I really appreciate your effort, I will love to help you in any manners. You mentioned in one of your post that compiler is not yet 100% ready regarding security point of view, would you like to share your thoughts about future improvements in compiler ? this is a one thing in Autoit which irritate me sometimes. 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
UberFoX Posted August 19, 2013 Author Share Posted August 19, 2013 (edited) 1st of all your project is great and I really appreciate your effort, I will love to help you in any manners. You mentioned in one of your post that compiler is not yet 100% ready regarding security point of view, would you like to share your thoughts about future improvements in compiler ? this is a one thing in Autoit which irritate me sometimes. Well you can help out if you want... The script compiler itself is made using Sputnik its just a large Sputnik script.... I plan to have a bunch of secutiy features to protect peoples code (similar to Unity) the first obviously being an obfuscator that is pretty powerful and makes nice spaghetti with the ability to control how much spaghetti and randomness it produces. Secondly will be an encryption key which only really an expert coder can break anyway (not your typical average joe so you shouldn't have much to worry about there). Then finally I may make it compile to bytecode instead of adding the source to the assembly. Of course you can help make them if you want... Anybody can. Oh as far as helping goes well the the compiler could use the above additions^ I have a GUI Builder that is half complete that could use somebody willing to finish it (its made entirely in Sputnik and is similar to Koda). Library functions need making especially Win API functions and struct and consts etc. Bugs need finding. Code bottlenecks need finding. Suggestions for new functions. Suggestions for changes to existing functions. and so on... You can add me on MSN/Skype etc just PM if you want. Edited August 19, 2013 by UberFoX Link to comment Share on other sites More sharing options...
UberFoX Posted August 19, 2013 Author Share Posted August 19, 2013 (edited) I posted a newer version 0.15 It includes the following changes: * Count() function added this ALWAYS returns how many elements are in an array or binary array etc (includes hash keys as well) * UBound() has been modified to now return the index of the highest element in the array (instead of total count) * LBound() added and returns the lowest index in the array (Since arrays in Sputnik are dynamic like PHP you could have a LBound at 6 and UBound at 200 however running Order() function will move the indexes to start from 0 alternatively Unshift() will also do that and of course Count() will return the total amount of elements) * Improved speed of loops by up 2-3 fold (Which also improved speed of Math a bit) * HTTPDownload() now accepts a new param that lets you define a variable to store and will be used as $param in the Progress() and Completed() events (Useful for storing the class $this). * Fixed a major bug (introduced by accident) which caused a classes $this variable to become NULL when using unset($classvariable); * FileDownload.spk is now in the Lib folder this class can be used to easily download files here is what it contains: expandcollapse popup//; Example code //; include("FileDownloader.spk"); //; my $Downloader = new FileDownloader(); //; $Downloader->DownloadFile("http://uberfox.no-ip.org/usb.pkg", "./usb.pkg"); //; println("Downloading file please wait...."); //; until($Downloader->$Complete) //; { //; sleep(1); // To avoid cpu hoggage //; doEvents(); // required for COMPLETED AND PERCENT EVENTS!!!!!! //; if(($Downloader->$ProgressPercent % 10) == 0) //; println("Download percent: " . ($Downloader->$ProgressPercent)); //; } //; println("Download Complete!!!"); //; Asynchronous file downloader class //; Will download files in its own thread etc and report progress as it downloads it //; Still if you want to get progress updates you need to have doEvents() being ticked //; in a loop somewhere. Class FileDownloader { my List ($Complete, $Downloading, $URL, $LOC, $ProgressPercent, $BytesTotal, $BytesDone); Function __Construct($URL, $SaveTo) { $Complete = false; $Downloading = false; } Function DownloadFile($URL, $LOC) { if($Downloading) return false; $this->$URL = $URL; $this->$LOC = $LOC; if(HTTPDownload($URL, $LOC, '$param->Progress($arg);', '$param->Completed($arg);', $this)) { $Downloading = true; return true; } else { return false; } } Function Completed($arg) { $Complete = true; $Downloading = false; } Function Progress($arg) { List ($URL, $LOC, $ProgressPercent, $BytesTotal, $BytesDone) = $arg; $this->$ProgressPercent = $ProgressPercent; $this->$BytesTotal = $BytesTotal; $this->$BytesDone = $BytesDone; } }; Edited August 19, 2013 by UberFoX Link to comment Share on other sites More sharing options...
UberFoX Posted August 19, 2013 Author Share Posted August 19, 2013 (edited) For anybody who is interested the GUI Builder for Sputnik which is made in Sputnik the full source code it is available here: http://uberfox.no-ip.org/GUIBuild.zip Extract it to the Examples folder so the IDE.spk is located at Sputnik Folder/Examples/GUIBuild/IDE.spk This is NOT finished yet but it CAN be used to produce basic GUIs and output the source code that will run in Sputnik and create the GUI you desire. You will notice its very nicely made with extensive use of Classes its fully an object-oriented GUI builder. It also contains TRAINER MAKER on the banner lol since many years ago I made a program called: Game Trainer Studio So I thought I would put its banner on the GUI Builder for lulz... It will be changed later. It would be nice if somebody wants to help finish this take a look at it and see the classes and how it works its quite good i think. It uses an MDI interface to keep everything contained and neat. We use DropBox for shared projects. Edited August 19, 2013 by UberFoX Link to comment Share on other sites More sharing options...
Shaggi Posted August 21, 2013 Share Posted August 21, 2013 This looks like the language i always wanted. Amazing job, will look at it later Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG Link to comment Share on other sites More sharing options...
Recommended Posts