Forum Replies Created
- 
		AuthorPosts
 - 
		
			
				
August 20, 2017 at 8:56 am in reply to: [REQUEST] Add 'With…End With' Statement in Monkey2 language #9943
The “With … End” statement is considered as a “helper” to have a clearer and less verbose source code, neither more nor less, it does not modify the control structures. A bit like the use of “Alias” which allows to “simplify” a type of variable or function. For example, you can write “Rect <Float>” to “Rectf” in your “Rect <Float>” and with “Alias”, and nothing prevents you from writing “Rect <Float>” elsewhere of your application. There are two different ways to use it but quite compatible.
- You define an “ObjectClass” with “With” keyword as the current “Object” to use in the block
 - Inside the “With” block, you use (dot) “.MyMethod or .MyProperty” directly without rewriting your declared “With”
 - “End”
 
August 18, 2017 at 10:02 pm in reply to: [REQUEST] Add 'With…End With' Statement in Monkey2 language #9905The right subject is to request to integrate “With” statement in Monkey2 language, no how to use an equivalent.
Do you think this is possible to add this in Monkey2 simply?
August 18, 2017 at 8:54 am in reply to: [REQUEST] Add 'With…End With' Statement in Monkey2 language #9901Obviously this has a real interest if there are many members called for the same object, or calling the members of these nested objects. In use it will always be much less verbose.
August 18, 2017 at 8:13 am in reply to: [REQUEST] Add 'With…End With' Statement in Monkey2 language #9899“With statement” work with ObjectClass expression only (class if you want use static function/variable or instance of class) and use “.” (dot) or “->”, if object’s pointer, in the block to avoid rewrite ObjectClass.
Syntax :
Monkey123With ObjectExpression[Statements]End[ObjectExpression] : Required. An expression that evaluates to an object or class/struct
[Statements] : Optional. One or more statements between ‘With’ and ‘End’ that may refer to members of an objects that’s produced by the evaluation of [ObjectExpression]
[End] : Required. Terminates the definition of the “With” blockMonkey2 example :
Monkey123456789101112131415161718192021222324252627282930313233343536Class CustomerField Name:StringField City:StringField URL:StringField Comments:=New List<String>EndFunction AddCustomer() '// without 'With statement'Local theCustomer:= New CustomertheCustomer.Name = "John Doe"theCustomer.City = "Unknown"theCustomer.URL = "http://www.john.doe"theCustomer.Comments.Add( "First comment." )theCustomer.Comments.Add( "Second comment." )If theCustomer.City = "" Then theCustomer.City = "Earth"EndFunction AddCustomer() '// with 'With statement'Local theCustomer:= New CustomerWith theCustomer '// Each 'With' block executes a series of statement one a single object.Name = "John Doe".City = "Unknown".URL = "http://www.john.doe"With .Comments '// Within the nested 'With' statement, the syntax refer to the inner object.Add( "First comment." ).Add( "Second comment." )EndIf .City = "" Then .City = "Earth" '// If statementEndEndDirectly with SDL function : SDL_WarpMouseGlobal:Void( x:Int, y:Int )
Remarks : This function generates a mouse motion event. A failure of this function usually means that it is unsupported by a platform.Do you look at the side of bgfx – Cross platform rendering library ? I think it would solve the rendering backend problems for all target platforms.
To quote the github page:
What is it?
Cross-platform, graphics API agnostic, “Bring Your Own Engine/Framework” style rendering library.
Supported rendering backends:- Direct3D 9
 - Direct3D 11
 - Direct3D 12 (WIP)
 - Metal (WIP)
 - OpenGL 2.1
 - OpenGL 3.1+
 - OpenGL ES 2
 - OpenGL ES 3.1
 - WebGL 1.0
 - WebGL 2.0
 
Supported HMD:
- OculusVR (1.3.0)
 
Supported platforms:
- Android (14+, ARM, x86, MIPS)
 - asm.js/Emscripten (1.25.0)
 - FreeBSD
 - iOS (iPhone, iPad, AppleTV)
 - Linux
 - MIPS Creator CI20
 - Native Client (PPAPI 37+, ARM, x86, x64, PNaCl)
 - OSX (10.9+)
 - RaspberryPi
 - SteamLink
 - Windows (XP, Vista, 7, 8, 10)
 - WinRT (WinPhone 8.0+)
 
Supported compilers:
- Clang 3.3 and above
 - GCC 4.6 and above
 - VS2012 and above
 
Look some screenshots of samples.
Improve – types parsing (:=True, ‘Ptr’ and some other)
Thanks it’s work perfectly
Wow! it’s really nice feature. Congrats!
I just find an little bug on AutoCompletion, if an parameters of function contains “xxx Ptr”, that’s don’t parse correctly. (eg: screenshots for example).
December 17, 2016 at 7:33 am in reply to: Shortening file extension *.monkey2 to *.mx2 or other #5863Ok Mark, it’s just a simple suggestion. Maybe for next Monkey…
Hi,
I need to extend Vec2<T> struct with additionnal features but i have an errors with ‘Property’. Can you tell me if my code is correct and why he doesn’t work?
Monkey1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374#Import "<std>"Using std..Struct Vec2<T> Extension'// By PropertyProperty Angle:Float()Return ATan2(Self.Y, Self.X)Setter:Void(value:Float)Self.X = Cos(value) * Self.LengthSelf.Y = Sin(value) * Self.LengthEndProperty Len:Double() 'Length extensionReturn LengthSetter(value:Double)Local a:Double = ATan2(Self.Y, Self.X)Self.X = Cos(a) * valueSelf.Y = Sin(a) * valueEnd'// By MethodMethod Angle2:Float() 'TestReturn ATan2(Self.Y, Self.X)EndMethod Angle2:Vec2<T>(value:Float) 'TestSelf.X = Cos(value) * Self.LengthSelf.Y = Sin(value) * Self.LengthReturn SelfEndMethod Clone:Vec2<T>()Return New Vec2<T>(Self.X, Self.Y)EndMethod One:Vec2<T>()Self.X = 1.0Self.Y = 1.0Return SelfEndMethod Zero:Vec2<T>()Self.X = 0.0Self.Y = 0.0Return SelfEndMethod Limit:Vec2<T>(value:Double)Local i:T = value / ((Self.Length <> 0.0) ? Self.Length Else 1.0)i = (i < 1.0) ? i Else 1.0Self.X = Self.X * iSelf.Y = Self.Y * iReturn SelfEndEndFunction Main()Local v:=New Vec2f(1,2)Print v.One()Print v.Zero()Print v.Angle2()Print v.Angle2(10.0)Print v.Angle '<--- Error : Property 'Angle' cannot be accessed from an instance of a different classv.Angle = 2.0Print vPrint v.Len '<--- Error : Property 'Len' cannot be accessed from an instance of a different classv.Len = 30.0Print vEnd - 
		AuthorPosts
 





