Call function c:Beta from within function c:Alpha

Call function c:Beta from within function c:Alpha

saitoib
Advocate Advocate
714 Views
5 Replies
Message 1 of 6

Call function c:Beta from within function c:Alpha

saitoib
Advocate
Advocate

Hi all.

It's a little late for this, but...
Is it possible to call function c:Beta from within AutoLisp's my function c:Alpha?

 

Thank you.

Saitoib
0 Likes
Accepted solutions (1)
715 Views
5 Replies
Replies (5)
Message 2 of 6

diagodose2009
Collaborator
Collaborator
Accepted solution

You try this code (C:Beta) or (command "C:Beta")

 

0 Likes
Message 3 of 6

hak_vz
Advisor
Advisor

You can have in your code

 

(defun alfa (.... / .....) )
(defun beta (.... / .....) )
(defun c:alfa nil (alfa))
(defun c:beta nil (beta))

And in alfa you call function beta

(c:beta) or (beta ... ...) 

 

C functions don't have arguments

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 4 of 6

pbejse
Mentor
Mentor

@saitoib wrote:

Hi all.

It's a little late for this, but...
Is it possible to call function c:Beta from within AutoLisp's my function c:Alpha?

 

Thank you.


Sure it is possible,

 

Real question is, what is the intention? are you planning to continue where Alpa command left off or right after what the main program finished with its task?  It can be a sub rather than a main function, especially if the program requires input from the user or a variable as an argument [ selecion set, string ...]

 

As an example

 

(Defun c:Alpha ()
  ; some functions ;
  (setq string (_Alpha&Beta (getstring "\nTell me something")))
  ;  more here ;
   )

 (Defun c:Beta ()
  ; some functions ;
  (setq string (_Alpha&Beta (getstring "\nTell me something")))
  ;  more here ;
   )

(defun _Alpha&Beta (str)
  (princ (strcat "\nDo a lot of formating with this ---> " str))
  (princ)
  )

 

HTH

 

 

 

 

 

0 Likes
Message 5 of 6

saitoib
Advocate
Advocate

I needed to use c:.
I was able to solve the problem with (command (c:Beta)).


Thank you very much.

 

Saitoib
0 Likes
Message 6 of 6

CodeDing
Advisor
Advisor

@saitoib wrote:

I was able to solve the problem with (command (c:Beta)).


@saitoib , you do not need the (command ...) call. The propper way to call it is without. Like so:

(defun c:ALPHA ( / )
  (alert "This is Alpha.")
)
(defun c:BETA ( / )
  (c:ALPHA)
  (alert "This is Beta.")
)

 

Just better practice to do it that way.

Best,

~DD

0 Likes