What is the difference between .l and .LONG?

Just starting out? Need help? Post your questions and find answers here.
Quin
Addict
Addict
Posts: 1135
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

What is the difference between .l and .LONG?

Post 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:
AZJIO
Addict
Addict
Posts: 2223
Joined: Sun May 14, 2017 1:48 am

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

Post by AZJIO »

Open structure view in tools
Tools -> Structure Viewer
Quin
Addict
Addict
Posts: 1135
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

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

Post 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:
User avatar
HeX0R
Addict
Addict
Posts: 1218
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

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

Post 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
AZJIO
Addict
Addict
Posts: 2223
Joined: Sun May 14, 2017 1:48 am

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

Post 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
User avatar
idle
Always Here
Always Here
Posts: 6026
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

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

Post 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
Quin
Addict
Addict
Posts: 1135
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

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

Post 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)
Post Reply