highrez2 Posted June 27, 2013 Posted June 27, 2013 working with some old code that I'm not to familiar with, the original writter used a different defun methood that I don't understand. Example (defun f:SC_GETINSPTS ( I can't run the lisp unless I change the "f" to a "c". Why is this? how can I run it without changing the code? Quote
Tharwat Posted June 27, 2013 Posted June 27, 2013 That considered as a function and not a command ( lisp ) Just an example of sub-functions by the Black Box . Quote
Tharwat Posted June 27, 2013 Posted June 27, 2013 can you exicute a function? Sure , some of functions need a number of arguments and some of them don't need and that's all related to the person who's programming it . Read THIS Quote
neophoible Posted June 27, 2013 Posted June 27, 2013 working with some old code that I'm not to familiar with, the original writter used a different defun methood that I don't understand. Example (defun f:SC_GETINSPTS ( I can't run the lisp unless I change the "f" to a "c". Why is this? how can I run it without changing the code? The confusion is probably due to the colon. When AutoLISP began using C: to indicate a command, this did not prevent folks from imitating that sort of naming for other functions. The "C:" does indeed indicate the routine can be used as a command on the command line. But other functions, even those with an embedded colon, are handled within parentheses, just as in a LISP routine. So, to run it from the command line as is, put it in parentheses; but note that you must provide whatever variables (arguments) are expected, just as you would in a standard LISP function. That is, any arguments before the forward slash have to have values passed to them. Quote
neophoible Posted June 27, 2013 Posted June 27, 2013 If this function does not have any variables or arguments before the backslash, then you can just call it by putting its name in parentheses, e.g., (f:SC_GETINSPTS) However, if it does require arguments, you will have to supply those at the same time, e.g., if you need to supply a prompt, it will expect a string... (f:SC_GETINSPTS "Pick some points: ") Quote
highrez2 Posted June 27, 2013 Author Posted June 27, 2013 Thanks, So "c" is for commands and "f" is for functions what is "g" Quote
Tharwat Posted June 27, 2013 Posted June 27, 2013 So "c" is for commands Correct . and "f" is for functions what is "g" Wrong , did you read the link that I brought in the first post ? Quote
highrez2 Posted June 27, 2013 Author Posted June 27, 2013 (defun sym ([arguments] [/ variables...]) expr...) sym A symbol naming the function. f and g or whatever is the function name? Quote
neophoible Posted June 27, 2013 Posted June 27, 2013 Thanks, So "c" is for commands and "f" is for functions what is "g" Yes, C: prefix is defined that way. But there is no other such : prefix that I'm aware of. There is at least one AutoLISP function that has :: in it. A programmer could use other such : prefixes for his own purposes, as someone did here, but it's strictly for his own purposes, not AutoCAD defined. Do you know or care anything about LISP, or are you just wanting to get this routine going? If the latter, then you've got more than enough info. If the former, then you've got some links to read. If you do need more help, you need to post the code in its entirety and ask questions specifically related. As it is, you gave minimal info. Quote
neophoible Posted June 27, 2013 Posted June 27, 2013 f and g or whatever is the function name?Yes, whatever the function's name is. It could be something straightforward like "GetSomePoints" (don't actually use quotes), or something more cryptic. It's just the name of the function. You could simply use F or G, but that's pretty lame for making sense of the code, and it's much more likely that someone else's code will interfere with your own if you use names that are too simple. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.