Page 1 of 1

What is the difference between .l and .LONG?

Posted: Tue Jan 07, 2025 9:12 pm
by Quin
In a lot of PB codes, I see stuff like:

Code: Select all

*Len.LONG
or

Code: Select all

*input.ASCII
My question is, where are all these possible types listed, and more importantly what do they do? Since I typically see them used with pointers I assume this is a way of storing pointers to native types, but I can't find any mention of it in the documentation.
The pointers chapter shows the .String type, but no others.
Thanks, and sorry if it's obvious... :lol:

Re: What is the difference between .l and .LONG?

Posted: Tue Jan 07, 2025 10:27 pm
by AZJIO
Open structure view in tools
Tools -> Structure Viewer

Re: What is the difference between .l and .LONG?

Posted: Tue Jan 07, 2025 11:23 pm
by Quin
AZJIO wrote: Tue Jan 07, 2025 10:27 pm Open structure view in tools
Tools -> Structure Viewer
Cool, but I asked what it does, not what fields it contains :mrgreen:

Re: What is the difference between .l and .LONG?

Posted: Tue Jan 07, 2025 11:35 pm
by HeX0R
.LONG is a structure, whereas .l is a variable type.
It is typically used, when you are sending variables ByRef to a procedure to make your life easier.
Quick example:

Code: Select all

Procedure ChangeByRef(*Value)
	Protected Value = PeekI(*Value)
	
	Value = Value + 2
	PokeI(*Value, Value)
EndProcedure

Procedure ChangeByRef2(*Value.INTEGER)
	*Value\i + 2
EndProcedure


A = 100
ChangeByRef(@A)
Debug A
A = 100
ChangeByRef2(@A)
Debug A

Re: What is the difference between .l and .LONG?

Posted: Tue Jan 07, 2025 11:46 pm
by AZJIO
What does the structure do? She doesn't do anything. This is simply a place where data is placed. With a struct, instead of passing a number to a function, you pass a pointer to that number. The number is not copied. If you use pointer access, it is as if you were accessing a global variable.
LONG is simply the name of a structure that creates a field of the same type. You can create the same structure with a different name.

example

Re: What is the difference between .l and .LONG?

Posted: Wed Jan 08, 2025 1:20 am
by idle
also see pointers and memory access
https://www.purebasic.com/documentation ... emory.html

The defined PB structures, look at the basic types table
https://www.purebasic.com/documentation ... ables.html
those are the structure names

there are of course loads of OS specific structures. under tools ALT+S

Re: What is the difference between .l and .LONG?

Posted: Wed Jan 08, 2025 3:41 pm
by Quin
HeX0R wrote: Tue Jan 07, 2025 11:35 pm .LONG is a structure, whereas .l is a variable type.
It is typically used, when you are sending variables ByRef to a procedure to make your life easier.
Ah, I see! Thanks! 8)