my best effort

General discussion for topics related to the FreeBASIC project or its community.
Post Reply
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: my best effort

Post by fxm »

If you could post actual pieces of the affected code, it would be easier to help you.
hungnguyengia
Posts: 65
Joined: Jul 01, 2021 7:53

Re: my best effort

Post by hungnguyengia »

I can't find any information about FBCAD on Google. Could you give me a link to your project?
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: my best effort

Post by fxm »

speedfixer
Posts: 606
Joined: Nov 28, 2012 1:27
Location: CA, USA moving to WA, USA
Contact:

Re: my best effort

Post by speedfixer »

What I do:

declare a common shared pointer of the UDT type

use one sub or a set of subs to maintain the UDT array

the main sub for maintenance is a container; the UDT array is declareded as STATIC
- the array is redimmed as needed for the ubound; after any/each redim PRESERVE - reassign the UDT pointer to the (0) or (0,0,0,...) array item
- only grow the array in one (first?) dimension;

create a macro that properly calculates the index into the array - share that with any module needing access
use the pointer to get that UDT array item anywhere

works well in several locations of my libraries

david
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: my best effort

Post by fxm »

Now that the array descriptor is easily accessible to the user (for fbc version >= 1.08), it might be better to work with a descriptor pointer (value always constant when the array is resized) rather than with a pointer to array elements (variable value when array is resized).
In addition, all the array information is included in the descriptor data.

Example:

Code: Select all

#include "fbc-int/array.bi"

Redim As Integer array(0)
Dim As Any Ptr p0 = @array(0)
Dim As FBC.FBARRAY Ptr pdescript = FBC.ArrayDescriptorPtr(array())

Print p0, pdescript->base_ptr

Redim array(10000)
p0 = @array(0)
Print p0, pdescript->base_ptr

Sleep
speedfixer
Posts: 606
Joined: Nov 28, 2012 1:27
Location: CA, USA moving to WA, USA
Contact:

Re: my best effort

Post by speedfixer »

fxm: yes

Just beginning to work with 1.08.x - but that should be the way to go.
But can you have redimmable UDT arrays with that descriptor?
My way, you can, with 1/4 of the code in the example.

To be explored, then discussed on another topic thread.


david
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: my best effort

Post by fxm »

speedfixer wrote: But can you have redimmable UDT arrays with that descriptor?
Yes, you can resize an array from the address of its descriptor only.
See my code addition:

Code: Select all

#include "fbc-int/array.bi"

Redim As Integer array(0)
Dim As Any Ptr p0 = @array(0)
Dim As FBC.FBARRAY Ptr pdescript = FBC.ArrayDescriptorPtr(array())

Print p0, pdescript->base_ptr

Redim array(10000)
p0 = @array(0)
Print p0, pdescript->base_ptr
Print

'------- code addition

Type mydescriptor          '' not allowed at local level
    Dim As Integer a(Any)  '' because it has a default
End Type                   '' constructor / destructor

Sub resize(Byval p As Any Ptr, Byval ub As Integer)
    Dim As mydescriptor Ptr pmd = p
    Redim pmd->a(ub)
End Sub

Print Ubound(array)
resize(pdescript, 50000)
Print Ubound(array)

Sleep
  • 'pmd->a()' is a kind of reference to 'array()' (through only a pointer to its descriptor).
I wrote this example with the simple Integer type. But same capability can be gotten with any other type including an UDT.
paul doe
Moderator
Posts: 1730
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: my best effort

Post by paul doe »

It is with great sadness that I inform our members that Owen Paul Reese, author of FBCADCAM and the OP of this thread, passed away on 01/14/2022 at 1:35 AM due to heart issues. I had the privilege to know and work for him for a while, and he was a great person with a kind soul. My condolences go to his daughter and wife. I will surely miss you, old man :cry:
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: my best effort

Post by srvaldez »

sad to hear :(
TeeEmCee
Posts: 375
Joined: Jul 22, 2006 0:54
Location: Auckland

Re: my best effort

Post by TeeEmCee »

Seeing the sad news led me to read part of this thread and learn who Owen was, as I'd never interacted with him. I'm impressed and inspired by what he did there in the Philippines. The world needs more people like him, especially now that it's lost one. Peace.
jepalza
Posts: 149
Joined: Feb 24, 2010 10:08
Location: Spain (Bilbao)

Re: my best effort

Post by jepalza »

His WEB "FBCAD" ( https://fbcadcam.com/index.html ) is "off", no download, no forum ....

It's sad to think about it, but the years go by.
I registered 12 years ago when I was 43, I am now 55 and as much as it hurts to think about it, it could happen to me any day now. We get "old".
:(
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: my best effort

Post by D.J.Peters »

R.I.P "owen" :-(
jepalza wrote:... no download ...
fbcadcam with GTK: https://fbcadcam.org/beta/fbcadcam-2019-02-24.zip
source code: https://fbcadcam.org/beta/fbcadcam-2019 ... e-only.zip

you have to execute "fbcadcam-2019-02-24.exe" from the "gtk+-bundle_3.8.2-20130704_win32-RC1\bin" folder

Joshy
jepalza
Posts: 149
Joined: Feb 24, 2010 10:08
Location: Spain (Bilbao)

Re: my best effort

Post by jepalza »

Curiously, links Don't work --> https://fbcadcam.org/beta/ but direct access yes!!! :roll:

Lastest download forever :(
Andrew92
Posts: 8
Joined: Apr 28, 2022 23:19

Re: my best effort

Post by Andrew92 »

D.J.Peters wrote: May 06, 2022 9:11 R.I.P "owen" :-(
jepalza wrote:... no download ...
fbcadcam with GTK: https://fbcadcam.org/beta/fbcadcam-2019-02-24.zip
source code: https://fbcadcam.org/beta/fbcadcam-2019 ... e-only.zip

you have to execute "fbcadcam-2019-02-24.exe" from the "gtk+-bundle_3.8.2-20130704_win32-RC1\bin" folder

Joshy
These links don't seem to be working for me, just wondering if it's something on my side?
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: my best effort

Post by D.J.Peters »

Andrew92 wrote: May 27, 2022 21:15These links don't seem to be working for me, just wondering if it's something on my side?
both links works here right click, target save as ...

Joshy
Post Reply