Hello Mahmoud
Question on Space() memCopy() and Pointer
Space allocates x number of Bytes
memCopy only copies String but Not number ?
Pointer can be defined as :char or :float but only seem to work as char
What I would like to do:
- Allocate space for 10 floating point numbers ( 10 x 8)
- Fill in the memory with the numbers using a Pointer type float
- Print out the float numbers using Pointer type float
- The Pointer type float should work with fPtr++ for the next number
memcpy(fPtr, 12345678 , 8) // no good
fPtr = fPtr + 8 // no good
fPtr++ // Preferred method -- by 8 bytes no good
==================================
CODE Example
nBytes = 6 * 8 // longFloat = 8 bytes
myString = space(nBytes)
for i = 1 to nBytes
myString[i] = '.'
next
See nl+"----- myString "+nl
See "|"+ myString +"|"
See nl+"-----"+nl
See "String Size : " + len(mystring) + nl
See "String Pointer : "+nl
See varptr("mystring",:char)
See "-----"+nl
//---------------------------------
fptr = varptr("mystring",:float)
See "fptrPointer : "+nl
See fptr
See "-----"+nl
memcpy(fPtr,"12345678", 8)
? myString
setPointer(fptr, getPointer(fPtr) + 16)
memcpy(fPtr,"98765432", 8)
? myString
setPointer(fPtr ,getPointer(fPtr) + 16)
memcpy(fPtr,"24681357", 8)
? myString
fPtr = fPtr + 8
memcpy(fPtr,"11114444", 8)
? myString
==================================
OUTPUT
----- myString
|................................................|
-----
String Size : 48
String Pointer :
00000209804002D0
char
0
-----
fptrPointer :
00000209804002D0
float
0
-----
12345678........................................
12345678........98765432........................
12345678........98765432........24681357........
Line 36 Bad parameter type!
In memcpy() in file C:/MyStuff/AA-Test/AA-Space-Pointer-2.ring