Author Topic: array 3+ dimensions  (Read 3102 times)

0 Members and 1 Guest are viewing this topic.

vladimirzm

  • Guest
array 3+ dimensions
« on: November 30, 2005, 02:31:20 PM »

WHY?...

Code: [Select]
(setq
  array   (vlax-make-safearray vlax-vbString '(0 . 99))
  array1  (vlax-make-safearray vlax-vbString '(0 . 99) '(0 . 99))
  array2  (vlax-make-safearray vlax-vbString '(0 . 99) '(0 . 99) '(0 . 99))
  array3  (vlax-make-safearray vlax-vbString '(0 . 99) '(0 . 99) '(0 . 99) '(0 . 99))
  array4  (vlax-make-safearray vlax-vbString '(0 . 99) '(0 . 99) '(0 . 99) '(0 . 99) '(0 . 99))
  ; ...
  array15 (vlax-make-safearray vlax-vbString
    '(0 . 99) '(0 . 99) '(0 . 99) '(0 . 99)
    '(0 . 99) '(0 . 99) '(0 . 99) '(0 . 99)
    '(0 . 99) '(0 . 99) '(0 . 99) '(0 . 99)
    '(0 . 99) '(0 . 99) '(0 . 99) '(0 . 99)
   )
)


;...
;...
(vlax-safearray-get-dim array) = 1 -------> Works
(vlax-safearray-get-dim array1) = 2 -------> Works
(vlax-safearray-get-dim array2) = 3 -------> Works
(vlax-safearray-get-dim array3) = 0 -------> ERROR!!!!!
;...
(vlax-safearray-get-dim array15) = 0 -------> ERROR!!!!!!


AND

Code: [Select]
(setq
  array   (vlax-make-safearray vlax-vbString '(0 . 1))
  array1  (vlax-make-safearray vlax-vbString '(0 . 1) '(0 . 1))
  array2  (vlax-make-safearray vlax-vbString '(0 . 1) '(0 . 1) '(0 . 1))
  array3  (vlax-make-safearray vlax-vbString '(0 . 1) '(0 . 1) '(0 . 1) '(0 . 1))
  array4  (vlax-make-safearray vlax-vbString '(0 . 1) '(0 . 1) '(0 . 1) '(0 . 1) '(0 . 1))
; ...
  array15 (vlax-make-safearray vlax-vbString
    '(0 . 1) '(0 . 1) '(0 . 1) '(0 . 1)
    '(0 . 1) '(0 . 1) '(0 . 1) '(0 . 1)
    '(0 . 1) '(0 . 1) '(0 . 1) '(0 . 1)
    '(0 . 1) '(0 . 1) '(0 . 1) '(0 . 1)
  )
)

;...
;...
(vlax-safearray-get-dim array) = 1 -------> Works
(vlax-safearray-get-dim array1) = 2 -------> Works
(vlax-safearray-get-dim array2) = 3 -------> Works
(vlax-safearray-get-dim array3) = 4 -------> WORKS!!!!!!
(vlax-safearray-get-dim array4) = 5 -------> WORKS!!!!!
(vlax-safearray-get-dim array5) = ERROR -------> ERROR!!!!!!!
;...
(vlax-safearray-get-dim array15) = ERROR -------> ERROR!!!!!!!


The Developer's Guide says: "A maximum of 16 dimensions can be defined for an array." I think isn't true, and What about the limits for every dimension?


LE

  • Guest
Re: array 3+ dimensions
« Reply #1 on: November 30, 2005, 04:24:49 PM »
Test the following lines of code, please:

Code: [Select]
;;;
(setq array (vlax-make-safearray vlax-vbString '(0 . 0)))

(vlax-safearray-fill array '("a"))


;;;
(setq array (vlax-make-safearray vlax-vbString '(0 . 0) '(0 . 0)))

(vlax-safearray-fill array '(("a")))


;;;
(setq array (vlax-make-safearray vlax-vbString '(0 . 1) '(0 . 1)))

(vlax-safearray-fill array '(("a" "b") ("d" "e")))


(setq array (vlax-make-safearray vlax-vbString '(1 . 2) '(1 . 2)))

(vlax-safearray-fill array '(("a" "b") ("d" "e")))
;;;

(setq array (vlax-make-safearray vlax-vbString '(1 . 3) '(1 . 3)))

(vlax-safearray-fill array '(("a" "b" "c") ("d" "e" "c")("d" "e" "c")))

HTH

vladimirzm

  • Guest
Re: array 3+ dimensions
« Reply #2 on: November 30, 2005, 05:25:14 PM »
hola.

Yes but i forget to make the question... i think.
my problem isn't to fill an array, i'm trying to make an array with the greater possible amount of dimensions (i need to store lots of text meaning diferent thins and numbers) then i wrote
Code: [Select]
(setq
  array   (vlax-make-safearray vlax-vbString '(0 . 99))
  array1  (vlax-make-safearray vlax-vbString '(0 . 99) '(0 . 99))
  array2  (vlax-make-safearray vlax-vbString '(0 . 99) '(0 . 99) '(0 . 99))
  array3  (vlax-make-safearray vlax-vbString '(0 . 99) '(0 . 99) '(0 . 99) '(0 . 99))
  array4  (vlax-make-safearray vlax-vbString '(0 . 99) '(0 . 99) '(0 . 99) '(0 . 99) '(0 . 99))
  ; ...
  array15 (vlax-make-safearray vlax-vbString
    '(0 . 99) '(0 . 99) '(0 . 99) '(0 . 99)
    '(0 . 99) '(0 . 99) '(0 . 99) '(0 . 99)
    '(0 . 99) '(0 . 99) '(0 . 99) '(0 . 99)
    '(0 . 99) '(0 . 99) '(0 . 99) '(0 . 99)
   )
)

this it not works

now i'm working with
Code: [Select]
(setq array (vlax-make-safearray vlax-vbString '(0 . 9999)))
but this isn't functional for my intensions

LE

  • Guest
Re: array 3+ dimensions
« Reply #3 on: November 30, 2005, 05:41:46 PM »
Sorry,

But I do not understand what are you trying to do...

Why you want to use safearrays?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: array 3+ dimensions
« Reply #4 on: November 30, 2005, 06:03:52 PM »
Yes, Why safearrays?
List are much easer to deal with, for me at least.
And you are not limited in the size.
A list of list is an array.

If you could, give an example of the data you want to store &
how you are wanting to use it.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: array 3+ dimensions
« Reply #5 on: November 30, 2005, 06:37:42 PM »
To echo my friends, is this an academic pursuit or the genesis of a solution to a problem?

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: array 3+ dimensions
« Reply #6 on: November 30, 2005, 11:22:29 PM »
OK, now I'm confused and I'm pretty sure I've found why I don't use safearrays unless I HAVE to. Following vladimir's sample I just stopped at array4 (and it tried like crazy to bring my computer to it's knees)
Code: [Select]
(setq
  array0  (vlax-make-safearray vlax-vbString '(0 . 99))
  array1  (vlax-make-safearray vlax-vbString '(0 . 2) '(0 . 2))
  array2  (vlax-make-safearray vlax-vbString '(0 . 9) '(0 . 9) '(0 . 9))
)
I then tested these like so:

Well CRUDDDDDDDDDDDDDDDDDDDDDDD In trying to reproduce my testing I just got a Fatal Error Out of Memory ......and Acad closed without warning!   

To make a long story short since I'm not going to redo all that, just creating a 3 dimensional array with each one having and Upper bounds of 99 creates/reserves space for 1,000,000 items! It seems to me that either I don't understand arrays or the safearray does have issues.........even the array1 doesn't return what I'd think with (vlax-safearray->list)......just try it and tell me if it's right....

Jeff

JohnK

  • Administrator
  • Seagull
  • Posts: 10646
Re: array 3+ dimensions
« Reply #7 on: December 01, 2005, 01:19:28 PM »
*Se7en Scratches head*

Now im not the greatest when it comes to safearrays to begin with; Im not quite sure I understand how they are assembled. -i.e. if an array with 16 dims is actualy and truly an array of arrays...etc. but after reading your thread and title over and over I think you know more then me. (So any help I can offer is moot.)

However, I tried to achieve more then 3 storage slots in an dim and I couldnt get anything further then 3 slots.


;;; setup some defaults ;;;

;; give me 2 slots
;; index of one...
(setq my-sa
      (vlax-make-safearray
        vlax-vbString
        '(1 . 2) '(1 . 2) '(1 . 2) '(1 . 2)
        '(1 . 2) '(1 . 2) '(1 . 2) '(1 . 2)
        '(1 . 2) '(1 . 2) '(1 . 2) '(1 . 2)
        '(1 . 2) '(1 . 2) '(1 . 2) '(1 . 2) ))

Command: (vlax-safearray-get-dim my-sa)
16

;; give me 3 slots
(setq my-sa
      (vlax-make-safearray
        vlax-vbString
        '(1 . 3) '(1 . 3) '(1 . 3) '(1 . 3)
        '(1 . 3) '(1 . 3) '(1 . 3) '(1 . 3)
        '(1 . 3) '(1 . 3) '(1 . 3) '(1 . 3)
        '(1 . 3) '(1 . 3) '(1 . 3) '(1 . 3) ))

Command: (vlax-safearray-get-dim my-sa)
16

;; lets try to get 3 slots anotherway.
;; index zero...
(setq my-sa
      (vlax-make-safearray
        vlax-vbString
        '(0 . 2) '(0 . 2) '(0 . 2) '(0 . 2)
        '(0 . 2) '(0 . 2) '(0 . 2) '(0 . 2)
        '(0 . 2) '(0 . 2) '(0 . 2) '(0 . 2)
        '(0 . 2) '(0 . 2) '(0 . 2) '(0 . 2) ))

Command: (vlax-safearray-get-dim my-sa)
16

;;; lets try to force 4 slots in each dim.                      ;;;

;; lets try to force 4 slots --method one.--
;; index zero...
(setq my-sa
      (vlax-make-safearray
        vlax-vbString
        '(0 . 3) '(0 . 3) '(0 . 3) '(0 . 3)
        '(0 . 3) '(0 . 3) '(0 . 3) '(0 . 3)
        '(0 . 3) '(0 . 3) '(0 . 3) '(0 . 3)
        '(0 . 3) '(0 . 3) '(0 . 3) '(0 . 3) ))

Command: (vlax-safearray-get-dim my-sa)
0

;; lets try to force 4 slots --method 2--
;; index one...
(setq my-sa
      (vlax-make-safearray
        vlax-vbString
        '(1 . 4) '(1 . 4) '(1 . 4) '(1 . 4)
        '(1 . 4) '(1 . 4) '(1 . 4) '(1 . 4)
        '(1 . 4) '(1 . 4) '(1 . 4) '(1 . 4)
        '(1 . 4) '(1 . 4) '(1 . 4) '(1 . 4) ))

Command: (vlax-safearray-get-dim my-sa)
0
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10646
Re: array 3+ dimensions
« Reply #8 on: December 01, 2005, 03:29:47 PM »
When I went out for lunch I was driving along and somthing kinda hit me; At first I kinda dismissed it, but the number 99 kinda made me think a bit. I said to myself: "Why 99?"

You do know that with the statment of: (vlax-make-safearray vlax-vbString '(0 . 2) '(0 . 2) '(0 . 2) '(0 . 2)) you are building a Tree right?

((0 . 2) (0 . 2) (0 . 2) (0 . 2))
is = to
(1 . 81)
is = to
81^1
is = to
3^4

Sooo.. what that means is: With 3^16 you have 43046721 possible slots to fill. (In the form of a Tree.)

In otherwords this:
(vlax-make-safearray
  vlax-vbString
  '(0 . 2) '(0 . 2) '(0 . 2) '(0 . 2)
  '(0 . 2) '(0 . 2) '(0 . 2) '(0 . 2)
  '(0 . 2) '(0 . 2) '(0 . 2) '(0 . 2)
  '(0 . 2) '(0 . 2) '(0 . 2) '(0 . 2) )
is 43046721 slots!?

Thats A LOT OF DATA! (Thats what hit me while I was driving.)

Oh and by the way, the fact that 'this' is a true ``Tree'' is what im unsure of. I havent tried to test it yet so keep in mind that im speaking in theory.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

vladimirzm

  • Guest
Re: array 3+ dimensions
« Reply #9 on: December 02, 2005, 12:47:15 AM »
Ok, first thxs for your answers

I am very sad to disappoint you by the use that I give to arrays.  :oops:

Second...
I work in a office with very competent people making them work, in all sense... and games are not out of this. Some day I found a very nice place to get some code for game at http://www.jefferypsanders.com/autolisp_games.html. At the beginning it was very nice, playing Tic Tac Toe, mines, mummy and the principal: HangMan, we played one game at time and so on. But days pass... and that become into addiction, now they play (of course I’m not  :evil: ) with several games at the same time (i.e. several Tic Tac Toe or mines in one game), and of course there's bets like "if you lose, tomorrow you'll take my work"  ^-^  :evil: or "you pay lunch" (i need to say that we are 13 people  :evil: :evil: :evil:), or physical punishes (this are the best!  :pissed:) you can imagine bets like that... :lol: ... In this context I had to change the routines to our requirements, those routines needed adaptation it to Spanish (we're from South America) i.e. add Ñ and Á É Í Ó Ú to the available characters for HangMand (is not the same PAPÁ that PAPA) and add a lot of words... and some others changes to rest of the games... yes! the games become too hard.

But what's the relation between arrays and our new addictions? ...

Well... I said "add a lot of words " and in addition that I said, I’m developing my version of Scrubble (something like http://okgames.altervista.org/html/modules/mydownloads/singlefile.php?lid=155) and try to add the greater possible amount of words of the Spanish vocabulary. I want to control all variables of the games by a unique objec, and the arrays are the best solution, i think the lists are not the best solution.

ok. i hope you understand my reasons  :roll:

...
...

In future days I'm thinking to develop my version of NAVAL FLEET (something like http://pdagamesoft.com/PocketPC/Naval-Ship-Warfare )

Again, thank you... and excuse my English.

JohnK

  • Administrator
  • Seagull
  • Posts: 10646
Re: array 3+ dimensions
« Reply #10 on: December 02, 2005, 09:24:47 AM »
Hey, you can use arrays all you want. I have no problem with that. (Nor should anyone else!! --Why should they care if you use arrays to code your programs.)

Now vladimirzm, did you happen to read my last post? An array of 16 dims three slots big is a huge amount of data!

Tell ya what: Run this line of code in your command line. hit Ctrl-C when you get tired of waiting.
(vlax-safearray->list (vlax-make-safearray vlax-vbString '(1 . 43046721)))

Now run this one. This one is offered just to solidify my point that your stuck with a char string with the lenght of 43,046,721 chars.
(vlax-safearray-get-dim (vlax-make-safearray vlax-vbString '(1 . 43046722)))

TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org