Another solution:
EnableExplicit
Structure Type
x.f
y.f
z.f
EndStructure
Procedure init(_x.f,_y.f,_z.f, *a.Type)
*a\x=_x.f
*a\y=_y.f
*a\z=_z.f
EndProcedure
Define other_var.Type
init(1,2,3,@other_var)
Debug other_var\x ;1.0
Debug other_var\y ;2.0
Debug other_var\z ;3.0
Search found 5 matches
- Mon Oct 14, 2024 12:39 pm
- Forum: Feature Requests and Wishlists
- Topic: Wishlist for Structure like in C?
- Replies: 9
- Views: 2430
- Wed Jul 03, 2024 12:38 pm
- Forum: Tricks 'n' Tips
- Topic: PureBasic Modules: A Quick Tutorial
- Replies: 21
- Views: 84869
Re: PureBasic Modules: A Quick Tutorial
In addition to the examples given before, here an example of a very common use case, namely, a structure defined in a module and called in other modules.
DeclareModule module1
Structure Writer
name.s
surname.s
EndStructure
;.....
EndDeclareModule
Module module1
;here can be empty, but it ...
DeclareModule module1
Structure Writer
name.s
surname.s
EndStructure
;.....
EndDeclareModule
Module module1
;here can be empty, but it ...
- Mon Jul 01, 2024 11:12 am
- Forum: Coding Questions
- Topic: Protected NewList
- Replies: 3
- Views: 486
Protected NewList
There are cases where a variable of type List is used only within a procedure (and declared as Protected).
In order to avoid “ memory leak ”, is it necessary to use the FreeList() command before procedure exit?
The same question in the case of a variable of type Map or Array .
A simple example ...
In order to avoid “ memory leak ”, is it necessary to use the FreeList() command before procedure exit?
The same question in the case of a variable of type Map or Array .
A simple example ...
- Fri Jun 21, 2024 11:40 am
- Forum: Coding Questions
- Topic: File closed unexpected during read loop when #PB_Any is used
- Replies: 27
- Views: 3277
Re: File closed unexpected during read loop when #PB_Any is used
I remembered.
For example:
#file=200
If CreateFile(#file,"test.txt")
CloseFile(#file)
Else
Debug ("Error")
EndIf
For #file =200 it works.
For #file =2000 it does not compile, the following error message is displayed:
" File object number is very high (over 1000), are You sure of that ?"
It ...
For example:
#file=200
If CreateFile(#file,"test.txt")
CloseFile(#file)
Else
Debug ("Error")
EndIf
For #file =200 it works.
For #file =2000 it does not compile, the following error message is displayed:
" File object number is very high (over 1000), are You sure of that ?"
It ...
- Fri Jun 21, 2024 10:16 am
- Forum: Coding Questions
- Topic: File closed unexpected during read loop when #PB_Any is used
- Replies: 27
- Views: 3277
Re: File closed unexpected during read loop when #PB_Any is used
I met a similar issue.
To open/read/close a file I used for number to identify the file a number #file (instead #PB_Any) obtained from Enumeration
E. g.:
Enumeration
#window
...
a lot of gadgets, menu, etc
...
#file
EndEnumeration
Error message was: #file is to large or some like that, i do not ...
To open/read/close a file I used for number to identify the file a number #file (instead #PB_Any) obtained from Enumeration
E. g.:
Enumeration
#window
...
a lot of gadgets, menu, etc
...
#file
EndEnumeration
Error message was: #file is to large or some like that, i do not ...