Gwbasic to lisp

Discussion in 'AutoCAD' started by bkvikas, May 31, 2004.

  1. bkvikas

    bkvikas Guest

    Iam doing some calculation part of my new project and I have old programs written in gwbasic can any one tell me how to create a double dimension list in autolisp. I will be thankful if anyone evaluate below code in lisp.
    thanks in advance.

    510 FOR I = 1 TO ICOILS
    520 IF I > 1 THEN 550
    530 D = AIMD:DE= CONDPSLA
    540 GOTO 560
    550 D = BIMD:DE=CONDPSLB
    560 IDE = DE
    570 B1 = PAI*D*PICH(I)/PITCH - CUWID
    580 B2 = PAI*OMD*PICH(I)/PITCH - CUWID
    590 STEIG(I) = ((B2 - B1)/(DE - 1))/2
    600 X1(I,1) = B1/2
    610 X2(I,1) = X1(I,1) + (STEIG(I)/F(I))
    620 FOR J = 2 TO IDE
    630 K = J - 1
    640 X1(I,J) = X1(I,K) + STEIG(I)
    650 X2(I,J) = X2(I,K) + STEIG(I)
    660 NEXT J
    670 NEXT I
     
    bkvikas, May 31, 2004
    #1
  2. bkvikas

    zeha Guest

    ; The problem is that i don't no how to use this in your situation
    ; In Lisp you can make a various of variable
    ; such as '("Hello world." (0.0 1.0 0.0) 12 (10 0.0 1.0 0.0)) and many other

    ;-------------------
    ; list of 2 dimensions look like this
    ; ((0 . 1)(0 . 2)(0 . 3))
    ; try (setq mylist '((0 . 1)(0 . 2)(0 . 3)))
    ; (nth 0 mylist) --> (0 . 1) equal (car mylist)
    ; (nth 1 mylist) --> (0 . 2) equal (cadr mylist)
    ; (nth 2 mylist) --> (0 . 3) equal (caddr mylist)

    ; First you must give the variable 1 to 11 the right value

    (defun basicDim ( / I ICOILS DE CONDPSLB BIMD:DE CONDPSLA BIMD:DE AIMD:DE STEIG X1 X2); every setq (variable) set to nil
    (setq I 0) ;1
    (setq ICOILS 2) ;2
    (setq CONDPSLB 3) ;3
    (setq CONDPSLA 4) ;4
    (setq DE 5) ;5
    (setq PICH '(1 2 3 4 5 6 7 8 9)) ;6
    (setq PITCH 6) ;7
    (setq PAI 7) ;8
    (setq OMD 8) ;9
    (setq CUWID 9) ;10
    (setq F '(0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9));11
    (repeat ICOILS
    (if (> I 1)
    (setq D CONDPSLB BIMD:DE CONDPSLB)
    (setq D CONDPSLA AIMD:DE CONDPSLA)
    )
    (setq IDE DE
    B1 (* PAI D (- (/ (nth I PICH) PITCH 1.0) CUWID))
    B2 (* PAI OMD (- (/ (nth I PICH) PITCH 1.0) CUWID))
    STG (/ (- B2 B1)(1- DE) 2.0)
    STEIG (cons STG STEIG)
    X1 (cons (list (/ B1 2.0) STG) X1)
    X2 (cons (list (+ (/ B1 2.0)(/ (- B2 B1)(1- DE) 2.0) (nth I F)) STG) X2)
    I (1+ I) ;increment I with 1
    )
    ); end repeat I (NEXT I)
    (list STEIG X1 X2)
    )

    ; load this and call the function
    (setq result (basicDim))
    (princ (car result))(princ "\n"); STEIG
    (princ (cadr result))(princ "\n"); X1
    (princ (caddr result))(princ "\n"); X2


    ; regards
     
    zeha, May 31, 2004
    #2
  3. bkvikas

    ECCAD Guest

    ;; Correction:
    (if (> I 1)
    (setq D BIMD DE CONDPSLB)
    (setq D AMID DE CONDPSLA)
    )

    Bob
     
    ECCAD, Jun 1, 2004
    #3
  4. bkvikas

    bkvikas Guest

    Thanks both of you, I will copy the code and try to understand, iam a beginner. and I have one more question in this regard, whether to proceed in VBA or lisp> can you guide me in this? iam familier in VBA. any more suggestions are appreciated. thanks once again.
     
    bkvikas, Jun 1, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.