STRINGP function error

STRINGP function error

namlt33
Advocate Advocate
412 Views
7 Replies
Message 1 of 8

STRINGP function error

namlt33
Advocate
Advocate

I strange that when i run the command such as" (stringp "text") the software return "; error: no function definition: STRINGP". What seem to be problem here, pls help

0 Likes
Accepted solutions (1)
413 Views
7 Replies
Replies (7)
Message 2 of 8

CodeDing
Advisor
Advisor
Accepted solution

@namlt33 ,

 

There is no (stringp ...) function in AutoLISP by default. You can make one though:

(defun stringp (var / )
  (eq 'STR (type var))
)

 

Best,

~DD

Message 3 of 8

paullimapa
Mentor
Mentor

Sounds like one of those AI generated functions that don’t exist on AutoLisp


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 4 of 8

Kent1Cooper
Consultant
Consultant

.... bur it's understandable that one might think there is such a function, paralleling the (numberp) function [which does exist], and also from the fact that when you give a function that is looking for a string something different, the message you get is:

Command: (strcat "what" 1.234)
; error: bad argument type: stringp 1.234

which likewise parallels the number variety of the same thing:

Command: (+ 1.234 "what")
; error: bad argument type: numberp: "what"

So AutoLisp has a function of the same name as the error test for the latter, but not for the former.  But it must have an internal stringp test, even if that doesn't rise to the level of a function that Users can employ.

I wonder whether there's any significance to the fact that in those error messages, stringp does not have the colon after it that numberp has.

Kent Cooper, AIA
0 Likes
Message 5 of 8

diagodose2009
Collaborator
Collaborator

Please you customize my IF_Str with string-p?

(defun if_str(s386 elseuser / $rr tip) ;;_ASSERT_OK
(setq;|a000|;
tip (quote STR)
$rr (if (= (type s386) (quote SYM)) (eval s386) s386)) (setq;|a000|;
$rr (if (/= (type $rr) tip) elseuser $rr)) (if (and $rr (= elseuser 1)) (progn (setq;|a000|;
romania "You must sure the str MustHave>0"
$rr (if (> (strlen $rr) 0) $rr elseuser))))
$rr)

 How to use ? 

(setq nCount (strlen (if_str ArsenieBoca ""))

Can you update my If_str? I need control more the type of string? 

0 Likes
Message 6 of 8

Kent1Cooper
Consultant
Consultant

Your elseuser argument in the usage example [""] is a text string, but inside the code you have a function to check whether it's a particular number: (= elseuser 1).  That will never be true for a text string.  Should it be something like (= (strlen elseuser) 1) ?

Also, the last operation is to check whether $rr is not an empty string, i.e. that it is at least one character long, and if it is, use it, but if not, use what is in the elseuser argument.  But in the usage example, elseuser is itself an empty string "", which means that if $rr is an empty string "", then the routine will use the argument "", so $rr will remain unchanged, still "".

It is not clear to me what it is supposed to do, so it's hard to suggest which of those things to change, and in what way(s).  Can you describe in more detail what your inputs are, and what you want to know about them or do with them?   [For example, is ArsenieBoca a variable, and if so, what kind(s) of things might it contain?  Is elseuser supposed to be a text string?  What is the romania variable for, which is never used?  Etc.]

Kent Cooper, AIA
0 Likes
Message 7 of 8

CodeDing
Advisor
Advisor

@Kent1Cooper ,

 

It's a bot account. No need to review that code, it's gibberish. That's why that account has not been posting since November (the time the new forum layout started rolling out). Looks like it's back in business now though.

 

~DD

0 Likes
Message 8 of 8

diagodose2009
Collaborator
Collaborator

Please Can I replace ? How mix stringp with (setq etst "Arase" (if (> etst "")  ...  ...  .))

(defun stringp (var / )
  (eq 'STR (type var))
)

you fill ... ...  with your test/s.Same cases I need this 

(defun string0 (var / $rr)
    (setq $rr (if (and  (eq 'STR (type var)) (> var "") ...  .
. ..  

 

0 Likes