Table: Resize all variables in ReDim (New, New,10,New) like.

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
GeBonet
Enthusiast
Enthusiast
Posts: 135
Joined: Fri Apr 04, 2008 6:20 pm
Location: Belgium

Table: Resize all variables in ReDim (New, New,10,New) like.

Post by GeBonet »

Table: Resize all variables such as ReDim (New, New, New) and not only ReDim (10, New) the last ...
Like, in Old QB, and PowerBasic, and many other languages.
Its necessary when you work and use with various file open simultaneously in conjunction with the tables... And you work with 3, 4 or 5 dimension...
I have many SGBD created from me, with possibility to work with ISAM file but its necessary have, a possibility ReDim with various parametter...
Tanks for attention ! (Sorry for the English, I am French Belgian).
User avatar
GeBonet
Enthusiast
Enthusiast
Posts: 135
Joined: Fri Apr 04, 2008 6:20 pm
Location: Belgium

Post by GeBonet »

Wy Using ReDim with all Items... ? Exemple :

If i have one or more table like : TableFile$(NumberLine, NumberCol)
Table where the columns would be = (Idend., Name, adress, zipcode, city,..., etc...)

In such a table, If I do not know in advance the number of lines, I need return the table Like this : TableFile$ (NumberCol, NumberLine).

1- It is not very compatible with the presentation of conventional tables.
2- Now If in addition I should manage these tables with Files
3- But I would also like more FILES in connection with these tables....

My Table will be see like this : TableFile$(NumberOfFile, NumberLine_Of_EatchFile, NumberCol_Of_EatchFile)

But if you do not know in advance the number of file to open, the number of articles that contain all the files, then it must be possible to dynamically resize the tables ...

This demonstrates the usefulness of power resize any table parameter
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

you can use Dim on an existing array with arbitrary size in all dimensions,
even with other dimensions, but the content will be erased.

ReDim is for keeping existing content, and so only the outermost Dimension can be changed because there is no complicated element copying involved.
implementing a ReDim with arbitrary dimension change would mean to implement most complicated moving of single elements.


about your example: TableFile$(NumberOfFile, NumberLine_Of_EatchFile, NumberCol_Of_EatchFile)
imho it is just the way how-not-to-be-done.
putting several files into one single array of strings, sounds like an idea of Edgar Allen Poe... most creepy.
oh... and have a nice day.
User avatar
GeBonet
Enthusiast
Enthusiast
Posts: 135
Joined: Fri Apr 04, 2008 6:20 pm
Location: Belgium

Post by GeBonet »

Thank you very much,
I know the ReDim function for a very long time ...
And that is precisely what I would do it but in other dimensions, and not just the latest ...

And this is an example of Table I shows as it should be resized ...

Thing, which was easily in the versions of Qb to QBX ... But long ago and in other languages ...

They served me a gerer tables dynamically configurable multiple dimensions.
Thank you anyway! :lol: :lol:
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

GeBonet wrote:Wy Using ReDim with all Items... ? Exemple :

If i have one or more table like : TableFile$(NumberLine, NumberCol)
Table where the columns would be = (Idend., Name, adress, zipcode, city,..., etc...)

In such a table, If I do not know in advance the number of lines, I need return the table Like this : TableFile$ (NumberCol, NumberLine).

1- It is not very compatible with the presentation of conventional tables.
2- Now If in addition I should manage these tables with Files
3- But I would also like more FILES in connection with these tables....

My Table will be see like this : TableFile$(NumberOfFile, NumberLine_Of_EatchFile, NumberCol_Of_EatchFile)

But if you do not know in advance the number of file to open, the number of articles that contain all the files, then it must be possible to dynamically resize the tables ...

This demonstrates the usefulness of power resize any table parameter
Would something like this work for you?

Code: Select all

  Structure element
    Idend.s
    name.s
    Address.s
    zipcode.s
    city.s
  EndStructure
  
  NumberLine = 300
  Dim TableFile.element(NumberLine)
  
  ;change size
  NumberLine = 500
  Redim TableFile(NumberLine)
It doesn't handle different file numbers though. I think that would be possible with just a little more effort.

I second Kaeru's comment that you may be trying to force something into a multi-dimensional array that shouldn't be there in the first place.

If all the elements of your table are the same (i.e. strings) then you can copy them all to a single dimension array, recreate the multi-dimensional array with the new dimensions, then copy the elements back in. That is what the suggested feature request would be doing anyway.

I'll post an example if this would be useful.
Last edited by Demivec on Sun Apr 19, 2009 11:55 pm, edited 1 time in total.
User avatar
GeBonet
Enthusiast
Enthusiast
Posts: 135
Joined: Fri Apr 04, 2008 6:20 pm
Location: Belgium

Post by GeBonet »

Thank you for your help,

I understand your explanation its very is clear. :lol:

My intent was simply to suggest an expansion in opportunities for ReDim ...
Because I think that would give a little more freedom and that's it!

Again thank you. :lol:
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

Your welcome. :D

I agree the feature requested would expand freedom, although it would be at the expense of speed (according to Fred).

It is fortunately something that can usually be accomplished via other means.
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

Kaeru Gaman wrote:you can use Dim on an existing array with arbitrary size in all dimensions,
even with other dimensions, but the content will be erased.
:shock: I didn't know this, thanks for the tip.

Infact I was looking for a workaround to this just last night and thinking of changing data structure so that I didn't have a 2d array in there.

Cheers :D
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
Post Reply