Debug Henry\ Friends("1")īool can be used to evaluate a boolean expression outside of regular conditional operator like Will print an empty string as the whole structure has been reseted. 'Structure' is the name of the structure which should be used to perform the clearing. ResetStructure clears a structured memory area Syntax ResetStructure(*Pointer, Structure) All other fields have been reset to zero. Will print empty strings as the whole structure has been cleared. This function is for advanced users and should be used with care. There is no internal check to ensures the structure Set to zero, even native type like long, integer etc. This is useful when the structure contains strings, array, list or map which have been allocated internally by PureBasic. Syntax ClearStructure(*Pointer, Structure)ĬlearStructure clears a structured memory area. There is no internal check to ensures that the structure match the two memory area. It could crash, as random values will be used by the clear routine. Should be a valid structure memory area, or a cleared memory area. Needed to call ClearStructure before CopyStructure. The destination structure will be automatically cleared before doing the copy, it's not This is useful when dealing with dynamic allocations, trough pointers. Syntax CopyStructure(*Source, *Destination, Structure)ĬopyStructure copy the memory of a structured memory area to another. Print out the list content ForEach *Student\ Friends() Now the list is ready to use AddElement(*Student\ Friends()) *Student.People = AllocateMemory( SizeOf(People)) Warning: multiple calls to InitializeStructure create a memory leakīecause the old members are not freed ( ClearStructure has to be called before calling InitializeStructure 'Structure' is the name of the structure which should be used to perform the initialization. It initializes structure members of type Array, List and Map, other members are not affected (.s. InitializeStructure initialize the specified structured memory area. Syntax InitializeStructure(*Pointer, Structure) #PB_Constant #PB_Variable #PB_Array #PB_List #PB_Map #PB_Structure #PB_Interface #PB_Procedure #PB_Function #PB_OSFunction #PB_Label #PB_Prototype #PB_Module #PB_EnumerationĬompilerIf Defined(PureConstant, #PB_Constant)ĭebug "Constant 'PureConstant' is declared" The 'Type' parameter can be one of the following values: (ie: without the '#' for a constant, without '()' for an The 'Name' parameter has to be specified without any extra decoration The name of the subsystem is case sensitive.ĭebug "Compiling with the OpenGL subsystem"ĭefined checks if a particular object of a code source like structure, Subsystem can be used to find out if a subsystem is in use for the If TypeOf(Surface) = #PB_Float Debug "Surface is a 'Float'" #PB_Byte #PB_Word #PB_Long #PB_String #PB_Structure #PB_Float #PB_Character #PB_Double #PB_Quad #PB_List #PB_Array #PB_Integer #PB_Map #PB_Ascii #PB_Unicode #PB_InterfaceĮndStructure If TypeOf(Person\Age) = #PB_Word Debug "Age is a 'Word'" TypeOf can be used to find out the type of a variable, Offset, so it will be IndexOfTheFunction*SizeOf(Integer).ĮndStructure Debug OffsetOf(Person\Age) will be 8 as a string is 4 byte in memory (16 with the 64-bit compiler, as a string is 8 bytes there) Interface ITestĮndInterface Debug OffsetOf(ITest\ Destroy()) will be 4 When used with an Interface, the function index is the memory OffsetOf can be used to find out the address offset of a Structure field or the address offset Note: if a variable and a structure have the same name, the structure will have the priority over the variable. An Ascii variable (.a) is AsciiĮxample: 1 char.c= '!' Debug SizeOf(char) display 2Īscii.a= '!' Debug SizeOf(ascii) display 1ĮndStructure Debug "The size of my friend is " Str( Sizeof(Person)) " bytes" will be 10 (4 4 2) Note: A Character (.c) variable is unicode and uses 2 bytes. ArraySize(), ListSize() or MapSize() can be used This can be useful in many areas such as calculating memory requirements for operations, using API commands.Īs SizeOf is a compile time function, it doesn't work with runtime Array, List or Map. Not work on the simple built-in types such as word, float etc.), Interface or even variables. SizeOf can be used to find out the size of any Structure (it does
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |