Spsce() memCopy() Pointer

42 views
Skip to first unread message

Bert Mariani

unread,
Feb 26, 2026, 3:01:29 PMFeb 26
to The Ring Programming Language
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


AA-Space-Pointer-2.ring

Ilir Liburn

unread,
Feb 26, 2026, 4:42:23 PMFeb 26
to The Ring Programming Language
Hello Bert,

take a look at ring\samples\UsingOpenGL\cubeongpu2\cubeongpu.ring I wrote 6 years ago. Search for float2bytes function which fills space with numbers, used later for indices, vertices, etc. Here lies the answer to your question how to render at maximum speed: by loading data on GPU (there is also version which sends data to GPU).

Greetings,
Ilir

Bert Mariani

unread,
Feb 27, 2026, 12:24:43 PMFeb 27
to The Ring Programming Language
Hello Illir

Thanks for showing your sample -  cubeongpu.ring  -- Impressive !!
I see the float2Bytes()

=======================

memCopy()  should be able to handle numbers
Pointers should be able to be incremented by:    ptr++   depending if  char or float reference

=======================

Regards
Bert Mariani

Ilir Liburn

unread,
Feb 27, 2026, 1:01:20 PMFeb 27
to The Ring Programming Language
Hello Bert,

We must thank Mahmoud: because I could immediately recognize potential or the Ring language in low level area.

Regarding memcopy: problem is that list is not made of contiguous memory like arrays. However, you can copy from filled space to empty space
Regarding ptr++: doable, but not for every type because size is not known. You have setpointer() function to deal with that

Greetings,
Ilir

Mahmoud Fayed

unread,
Feb 27, 2026, 6:32:46 PMFeb 27
to The Ring Programming Language
Hello Ilir

>> "We must thank Mahmoud: because I could immediately recognize potential of the Ring language in low level area."

You are welcome :D

Greetings,
Mahmoud

Reply all
Reply to author
Forward
0 new messages