AutoIt vs Euphoria
- Posted by Icy_Viking May 08, 2018
- 2519 views
So I recently came across AutoIt. It is a programming language that shares some similiarties with Euphoria. I even noticed that wrapping DLL functions in AutoIt is quite similar to how it is done in Euphoria. However one advantage AutoIt has over Euphoria when it comes to wrapping things such as DLL functions, it actually has struct support. I'll show below in code.
;Struct for SDL_RECT Func SDL_Rect($x,$y,$w,$h) $xSDL_Rect = DllStructCreate("int;int;int;int") DllStructSetData($SDL_Rect,1,$x) DllStructSetData($SDL_Rect,2,$y) DllStructSetData($SDL_Rect,3,$w) DllStructSetData($SDL_Rect,4,$h) Return $xSDL_Rect EndFunc Func SDL_GetDisplayBounds($display,$xSDL_Rect) Local $xSDL_GetDesktopDisplayMode = DllCall($SDL,"int:cdecl","SDL_GetDisplayBounds","int",$display,"ptr",DllStructGetPtr($xSDL_Rect)) Return $xSDL_GetDesktopDisplayMode[0] EndFunc
You basiclly make a variable for the struct, then you can access/use it via a pointer. Also, note the similarity in how similar it looks to as if you were wrapping it for Euphoria.
public constant xSDL_GetDisplayBounds = define_c_func(sdl2,"SDL_GetDisplayBounds",{C_INT,C_POINTER},C_INT) public function SDL_GetDisplayBounds(atom dis,atom rect) rect = allocate(16) poke4(rect + RECT_LEFT, 10) poke4(rect + RECT_TOP, 20) poke4(rect + RECT_RIGHT, 90) poke4(rect + RECT_BOTTOM, 100) return c_func(xSDL_GetDisplayBounds,{dis,rect}) end function
While Euphoria is still simple, having something to directly access structs or a struct for Euphoria would be excellent. Is it still true that the next version of Euphoria will have some sorta of primitive struct functionality? I'm sure it would probably be even more simple in Eu than it would be in AutoIt. Something like
Struct Eu_Struct {atom x,atom y,atom w, atom h} Eu_Struct.x = 15 Eu_Struct.y = 30 Eu_Struct.w = 25 Eu_Struct.h = 25 for i = 1 to length(Eu_Struct) printf(1,"Size: %d",{Eu_Struct[i]}) end for
At least that is how I think it would be like. Might be a little different in actual implentation. Thoughts?
P.S. Euphoria is still one of my favorite programming languages.