Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

WHILE isnt working

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
202 Views, 3 Replies

WHILE isnt working

G'dat Group,

I have posted my code below (I have butchered it somewhat) but have filled in the missing parts to still achieve the error.
If you cut and past this into the VLISP Editor and select it to run I get a BLANK inspect window returned??

But when stepped through step by step, inside the WHILE statement it all works. (I have replaced STR with the string for the purpose of the exercise).

What am I doing wrong?


(setq counter 0)
(setq selectlength 2)

(while (< counter selectlength);2 times
(setq STR "%%U3 - OPP. HAND - 012B");next time this runs through it will change to "%%U2 - AS DRAWN - 012A"
(setq POS1 (vl-string-position (ascii " ") STR));4 INTEGER
(setq POS2 (vl-string-position (ascii "U") STR));2 INTEGER
(setq newnumber (substr STR (+ POS2 2) (- POS1 3)));"3"
(setq newnumber (atoi newnumber)); THIS IS NOW AN INTEGER 3
(setq newlisn (+ newnumber newlisn))
(setq newlist (cons newnumber newlist))
(setq counter (1+ counter));COUNTER EQUALS 1 NOW
)
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

What is newlisn? It doesn't get set in your code until you add it so the effect is (+ 3
nil)

wrote in message news:5528267@discussion.autodesk.com...
G'dat Group,

I have posted my code below (I have butchered it somewhat) but have filled in the missing
parts to still achieve the error.
If you cut and past this into the VLISP Editor and select it to run I get a BLANK inspect
window returned??

But when stepped through step by step, inside the WHILE statement it all works. (I have
replaced STR with the string for the purpose of the exercise).

What am I doing wrong?


(setq counter 0)
(setq selectlength 2)

(while (< counter selectlength);2 times
(setq STR "%%U3 - OPP. HAND - 012B");next time this runs through it will change to "%%U2 -
AS DRAWN - 012A"
(setq POS1 (vl-string-position (ascii " ") STR));4 INTEGER
(setq POS2 (vl-string-position (ascii "U") STR));2 INTEGER
(setq newnumber (substr STR (+ POS2 2) (- POS1 3)));"3"
(setq newnumber (atoi newnumber)); THIS IS NOW AN INTEGER 3
(setq newlisn (+ newnumber newlisn))
(setq newlist (cons newnumber newlist))
(setq counter (1+ counter));COUNTER EQUALS 1 NOW
)
Message 3 of 4
Anonymous
in reply to: Anonymous

Look attach file ,same as Doug comment.

"Doug Broad" wrote in message
news:5528283@discussion.autodesk.com...
What is newlisn? It doesn't get set in your code until you add it so the
effect is (+ 3
nil)

wrote in message news:5528267@discussion.autodesk.com...
G'dat Group,

I have posted my code below (I have butchered it somewhat) but have filled
in the missing
parts to still achieve the error.
If you cut and past this into the VLISP Editor and select it to run I get a
BLANK inspect
window returned??

But when stepped through step by step, inside the WHILE statement it all
works. (I have
replaced STR with the string for the purpose of the exercise).

What am I doing wrong?


(setq counter 0)
(setq selectlength 2)

(while (< counter selectlength);2 times
(setq STR "%%U3 - OPP. HAND - 012B");next time this runs through it will
change to "%%U2 -
AS DRAWN - 012A"
(setq POS1 (vl-string-position (ascii " ") STR));4 INTEGER
(setq POS2 (vl-string-position (ascii "U") STR));2 INTEGER
(setq newnumber (substr STR (+ POS2 2) (- POS1 3)));"3"
(setq newnumber (atoi newnumber)); THIS IS NOW AN INTEGER 3
(setq newlisn (+ newnumber newlisn))
(setq newlist (cons newnumber newlist))
(setq counter (1+ counter));COUNTER EQUALS 1 NOW
)
Message 4 of 4
Anonymous
in reply to: Anonymous

G'day Fella's

Yes your right I forgot to give you the

(setq newlisn 0)
(setq newlist nil)

Apart from that, now I have finished off the entire program, and ran it EXPECTING an error on the while statement...
Guess what it ran all the way through. I spent all day trying to find the problem with the WHILE statement, but it seems to only work once inside the entire program.

Sorry for wasting your time...but I cant explain why the while function wont evealuate inside VLIDE when only selected by itself.

Cheers
Mike
Australia

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report