Results 1 to 3 of 3

Thread: If statement

  1. #1
    Member
    Join Date
    2011-03
    Location
    Kansas, US
    Posts
    5
    Login to Give a bone
    0

    Default If statement

    I am having problems with if statement in my routine. I want to simply want the user to choose
    if they wnt to create a new folder or not. The routine works but the response I is not what I want. It is
    suppose to say ""Folder Does Not Exists! Do You Want to Create a New Folder?" if the folder was not found.
    Or, ""Folder Aready Exists!" if it does find the folder. Instead it gives me both messages one after the other.
    What am I doing wrong?

    ------------
    Code:
     (defun C:MkFoldr (\Foldr1 JobNo FoldrName PathName ChkFoldr)
        (setq Foldr1
        (dos_getdir
          "Create new CAD Library Folder"
          "J:\\WMSP\\"
          "Select destination for the folder"
        )
        )
        (dos_chdir Foldr1)
        (setq JobNo
        (dos_editbox "Editor" "Enter Job Number" "XXXXX")
        )
        (setq FoldrName (strcat JobNo "-CAD Library"))
        (setq PathName (strcat Foldr1 FoldrName))
        (setq Chkfoldr
        (dos_dirp PathName)
        )                                                                 ;;this work ok to this point
        (if (= chkfoldr nil)
          (progn
     (setq yes
            (dos_msgbox
       "Folder Does Not Exists! Do You Want to Create a New Folder?"
       "CAD Library Folder"
       4
       3
            )
     )
     (if (= yes 6)
       (dos_mkdir PathName)
     )
          (progn
     (setq yes 
            (dos_msgbox
              "Folder Aready Exists!"
              "CAD Library Folder"
              1
              3
            )
            )
          )
        )
      )
    -----------------
    Last edited by Ed Jobe; 2012-05-04 at 07:06 PM. Reason: Added code tags

  2. #2
    Active Member
    Join Date
    2008-02
    Location
    Toronto, On
    Posts
    59
    Login to Give a bone
    0

    Default Re: If statement

    There was a parenthesis mis-match in (if (= chkfoldr nil)...

    Try the following:


    Code:
    (defun C:MkFoldr (\Foldr1 JobNo FoldrName PathName ChkFoldr)
      (setq Foldr1
    	 (dos_getdir
    	   "Create new CAD Library Folder"
    	   "J:\\WMSP\\"
    	   "Select destination for the folder"
    	   )
    	);end setq
    
      (dos_chdir Foldr1)
      (setq JobNo
    	 (dos_editbox "Editor" "Enter Job Number" "XXXXX")
    	);end setq
    
      (setq FoldrName (strcat JobNo "-CAD Library"))
      (setq PathName (strcat Foldr1 FoldrName))
      (setq Chkfoldr
    	 (dos_dirp PathName)
    	) ;;this work ok to this point
    
      (if (= chkfoldr nil)
        (progn
          (setq yes
    	     (dos_msgbox
    	       "Folder Does Not Exists! Do You Want to Create a New Folder?"
    	       "CAD Library Folder"
    	       4
    	       3
    	       );end dos_msgbox
    	    );end setq
          
          (if (= yes 6)
    	(dos_mkdir PathName)
    	);end if
          );end progn
    
        (progn
          (setq yes
    	     (dos_msgbox
    	       "Folder Aready Exists!"
    	       "CAD Library Folder"
    	       1
    	       3
    	       );end dos_msgbox
    	    );end setq
          );end progn
        );end if
      (princ)
      );end defun
    Last edited by Ed Jobe; 2012-05-04 at 07:07 PM. Reason: Added code tags

  3. #3
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: If statement

    First line might be like this:
    Code:
    (defun C:MkFoldr ( /  Foldr1 JobNo FoldrName PathName ChkFoldr)
    bad copy-paste reason i think
    Regards,

    ~'J'~

Similar Threads

  1. If statement help
    By prose in forum AutoLISP
    Replies: 3
    Last Post: 2010-01-06, 05:35 PM
  2. WHILE Statement...
    By BeKirra in forum AutoLISP
    Replies: 9
    Last Post: 2009-03-26, 02:57 PM
  3. Bad if statement?
    By clog boy in forum Revit Architecture - Families
    Replies: 0
    Last Post: 2009-01-15, 12:48 PM
  4. Need help with an If else then Statement
    By prose in forum AutoLISP
    Replies: 2
    Last Post: 2008-11-14, 04:04 PM
  5. Help with IF statement
    By kelly.195705 in forum AutoLISP
    Replies: 2
    Last Post: 2008-10-02, 05:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •