Code: Select all
*buffer = AllocateMemory(1000)
byte=*buffer(10)
byte2=*buffer[50]
Code: Select all
*buffer = AllocateMemory(1000)
byte=*buffer(10)
byte2=*buffer[50]
Code: Select all
EnableExplicit
Structure BYTE_STRUCT
byte.b[0]
EndStructure
Procedure.i main()
Protected.BYTE_STRUCT *buffer
*buffer = AllocateMemory(1000)
If *buffer
*buffer\byte[10] = $FF
Debug *buffer\byte[10]
ShowMemoryViewer(*buffer,1000)
FreeMemory(*buffer)
EndIf
ProcedureReturn #Null
EndProcedure
End main()
The short answer is to do as Quin said and read the help manual instead of asking forum users to quote each page of it to you.rndrei wrote: Thu Apr 24, 2025 6:31 pm Tell me how to read the right byte from memory?Code: Select all
*buffer = AllocateMemory(1000) byte=*buffer(10) byte2=*buffer[50]
Code: Select all
*buffer = AllocateMemory(1000)
byte = PeekB(*buffer + 10)
byte2 = PeekB(*buffer + 50)
LifeUniverseNEverything = (Bool(PeekB(*buffer + '*') > '*' ) +
Bool(PeekB(*buffer + '*') < '*' ) +
Bool(PeekB(*buffer + '*') = '*' )) * '*'
Apropos: in my tests (but I tried on win 11 arm VM) the "array" method is always faster than peek/pokejacdelad wrote: Fri Apr 25, 2025 8:36 am Because he found AllocateMemory which includes an example which should lead you to the right way.![]()
The help file is available in German and French as well. In addition, the online html version can be translated into other languages with the Chrome web browser's 'translate' option for web pages.Piero wrote: Fri Apr 25, 2025 8:33 am Why are you gurus so angry @rndrei?
Sometimes (even if you know a bit of english!) it's not very easy to browse help………
I guess you think so because your native language is english, so the automatic "translations" are generally decent; if that's the case, I can assure you that if you were, e.g., italian, you would "think VERY different" (especially if it involves pineapple pizzas)
Languages and writing styles come in many flavors and are used in different and sometimes dicey levels of fluency. I mention automatic translations only as an additional option to having no translation. When I started with PureBasic the English version of the help file had many issues due to it being written by non native speakers. I survived and it has improved over the years. In addition to English I also communicate in German, French, and American Sign Language and have been a student of other languages including Spanish, Russian, Mandarin, and Japanese and would study many more if not for the lack of time. Some things do not translate well between different languages but a rough translation is often better than no translation.Piero wrote: Fri Apr 25, 2025 9:36 amI guess you think so because your native language is english, so the automatic "translations" are generally decent; if that's the case, I can assure you that if you were, e.g., italian, you would "think VERY different" (especially if it involves pineapple pizzas)
Code: Select all
EnableExplicit
Macro CharBuffer(_buffer_);<- defines cmem!
!char* cmem = (char*)p_#_buffer_;
EndMacro
Macro CharSet(_index_,_value_)
!cmem[_index_] = _value_;
EndMacro
Macro CharGet(_index_,_byte_)
!v_#_byte_ = cmem[_index_];
EndMacro
Procedure.i main()
Protected *buffer
Protected.b byte
*buffer = AllocateMemory(1000)
If *buffer
CharBuffer(buffer)
CharSet(10,255)
CharGet(10,byte)
Debug byte
ShowMemoryViewer(*buffer,1000)
FreeMemory(*buffer)
EndIf
ProcedureReturn #Null
EndProcedure
End main()