Multiple Repeated Functions

Started by Oak3s, March 25, 2010, 04:40:37 PM

Previous topic - Next topic

Oak3s

My first OpenDCL project :)
I was wondering if there is an easier way of going about this. I have 100's of blocks and slides that I want to be able to insert from this application. I can (with the help of others here) load a slide and insert upon double click. The functions are very repetitive and if it is possible I would like to condense them. I didnt attach the BlockInsert function. This is the only part I have been able to condense. Any ideas?

[image attached]

(defun c:SA-Block-Insertion-Image_Form1_OnInitialize (/)
(dcl_SlideView_Load SA-Block-Insertion-Image_Form1_SlideView1 "P:/SA-Drafting/Blocks/Slide_images/SA-Anchorbolt.sld") ;SlideView1
(dcl_SlideView_Load SA-Block-Insertion-Image_Form1_SlideView2 "P:/SA-Drafting/Blocks/Slide_images/SA-BoltNut.sld") ;SlideView2
(dcl_SlideView_Load SA-Block-Insertion-Image_Form1_SlideView3 "P:/SA-Drafting/Blocks/Slide_images/SA-Centerline.sld") ;SlideView3
(dcl_SlideView_Load SA-Block-Insertion-Image_Form1_SlideView4 "P:/SA-Drafting/Blocks/Slide_images/SA-DetailA.sld") ;SlideView4
(dcl_SlideView_Load SA-Block-Insertion-Image_Form1_SlideView5 "P:/SA-Drafting/Blocks/Slide_images/SA-DetailNotUsed.sld") ;SlideView5
(dcl_SlideView_Load SA-Block-Insertion-Image_Form1_SlideView6 "P:/SA-Drafting/Blocks/Slide_images/SA-DryPack.sld") ;SlideView6
(dcl_SlideView_Load SA-Block-Insertion-Image_Form1_SlideView7 "P:/SA-Drafting/Blocks/Slide_images/SA-Earth.sld") ;SlideView7
(dcl_SlideView_Load SA-Block-Insertion-Image_Form1_SlideView8 "P:/SA-Drafting/Blocks/Slide_images/SA-ExpansionBolt.sld") ;SlideView8
)
;*****************************************************************************************************************
;SlideView1
(defun c:SA-Block-Insertion-Image_Form1_SlideView1_OnMouseEntered (/)
(dcl_Control_SetFocus SA-Block-Insertion-Image_Form1_SlideView1)
(dcl_Control_SetCaption SA-Block-Insertion-Image_Form1_Label1 "Anchor Bolt")
)
(defun c:SA-Block-Insertion-Image_Form1_SlideView1_OnDblClicked (/)
(setq BName "SA-Anchorbolt" Xplod "1")
(BlockInsert)
)
;*****************************************************************************************************************
;SlideView2
(defun c:SA-Block-Insertion-Image_Form1_SlideView2_OnMouseEntered (/)
(dcl_Control_SetFocus SA-Block-Insertion-Image_Form1_SlideView2)
(dcl_Control_SetCaption SA-Block-Insertion-Image_Form1_Label1 "Bolt Nut")
)
(defun c:SA-Block-Insertion-Image_Form1_SlideView2_OnDblClicked (/)
(setq BName "SA-BoltNut" Xplod "1")
(BlockInsert)
)

BazzaCAD

You could do something like:

Code (autolisp) Select

(defun c:SA-Block-Insertion-Image_Form1_OnInitialize (/)
   (setq cnt 1)
   (while (< cnt (Length SlideList))
(dcl_SlideView_Load "SA-Block-Insertion-Image" "Form1" (strcat "SlideView" (itoa cnt)) (nth cnt SlideList))
        (setq cnt (1+ cnt))
   )
)


I did this off the top of my head without checking it in VLIDE, so I maybe missing something....
Also assuming you already you have SlideList built with all the slide files.


I don't think there's much you can do with the events...
a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

Oak3s

Thanks Barry. Im not knowledgeable enough to read that code though. :)
I kind of understand it. I am getting lost though with
dcl SlideView Load....
The confusing part is the lack of underscores...am I missing something here?
(dcl_SlideView_Load.....

Fred Tomke

Hello,

dcl SlideView Load won't work. It must be dcl SlideView_Load urgently.

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]