Page 2 of 2

Re: Pointer arithmetic (expressions with integers)

Posted: Fri Jan 18, 2013 11:48 pm
by Psychophanta

Code: Select all

Structure Arraybyte
  b.b[0]  ; byte
EndStructure
Structure Arrayword
  w.w[0]  ; word
EndStructure
Structure Arraylong
  l.l[0]  ; long
EndStructure
Structure Arrayinteger
  i.i[0]  ; integer
EndStructure
Structure Arrayquad
  q.q[0]  ; quad
EndStructure
Structure Arrayfloat
  f.f[0]  ; float
EndStructure
Structure Arraydouble
  d.d[0]  ; double
EndStructure
Structure Arrayascii
  a.a[0]  ; ascii
EndStructure
Structure Arraycharacter
  c.c[0]  ; character
EndStructure
Structure Arrayunicode
  u.u[0]  ; unicode
EndStructure
Structure Arraystring
  s.s[0]  ; string
EndStructure
Macro MyDim(varname,type,items)
  varname#.Array#type#=AllocateMemory(items#*SizeOf(type#))
EndMacro

MyDim(*x,integer,23)
If *x
  *x\i[2] = 10
  *x\i[5] = 124
EndIf

Re: Pointer arithmetic (expressions with integers)

Posted: Thu Jun 20, 2013 12:36 pm
by luis
@Psycho

The [0] trick has been already discussed in the thread two years ago, with its shortcomings.

Re: Pointer arithmetic (expressions with integers)

Posted: Thu Jun 20, 2013 4:25 pm
by Psychophanta
luis wrote:@Psycho

The [0] trick has been already discussed in the thread two years ago, with its shortcomings.
Ok, but my nick prefix "Psycho" has nothing to do with the english or saxon meaning of "psycho", but with its greek etymology, which is: breath, soul.