Re: A C to Euphoria Question: struct
- Posted by Jeffrey Fielding <JJProg at CYBERBURY.NET> Nov 11, 1998
- 430 views
Unfortunately, Euphoria doesn't support types or structs. You can implement the same thing using sequences, though: constant MainChar_x =3D 1, MainChar_y =3D 2, MainChar_Direction =3D 3, MainChar_MovePixels =3D 4, MainChar_CurrFrame =3D 5, MainChar_NumFrames =3D 6, MainChar_FrameRate =3D 7, MainChar_FrameCount =3D 8, MainChar_data =3D 9 I am working on a pre-processor for Euphoria that will allow for pointers and structures, but it isn't finished yet. You can get the current version at http://members.tripod.com/~JJProg/epp.html. Also, in C, * means pointer so data is an array of 20 pointers to characters. Euphoria doesn't support pointers either, though you can get pointer.e from the Euphoria web site (http://members.aol.com/fileseu/) which allows you to create "pointers" in Euphoria. Sometimes, pointers in C are used for dynamic arrays (which C, unlike Euphoria, doesn't support). In this case, you could do the same thing using sequences. If you need to check the sequences to make sure they are in the right format, you could use something like this: type OneD(object s) if not sequence(s) then return 0 end if for i =3D 1 to length(s) do if sequence(s[i]) then return 0 end if end for return 1 end type type MainChar(object s) if not sequence(s) then return 0 end if if length(s) !=3D 9 then return 0 end if for i =3D 1 to 8 do if not integer(s[i]) then return 0 end if end for if length(s[9]) !=3D 20 then return 0 end if for i =3D 1 to 20 do if not OneD(s[i]) then -- Replace OneD with Pointer if you are using pointers return 0 end if end for return 1 end type MainChar c c =3D ""}} -- Or (if you are using pointers) c =3D {0,0,0,0,0,0,0,0,{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}} Jeffrey Fielding JJProg at cyberbury.net