Jump to content

Recommended Posts

Posted

Dear friends,

 

I would like to learn how to apply a edit_box imput rules.

For example, if you only want to accept a number with the following format:

 

888.8.88

 

How do I impose this rule?

 

Thank you, and sorry for my bad English.:oops:

Posted

Try to rewrite this code to your suit:

(defun C:NUMP   (/ dcl_id text pick) 
  
 (defun box_callback(text act) 
 (if (member act (list 1 2))
  (if  (not (wcmatch text "###.#.##" ))
    (progn
 (set_tile "txt" (substr text 1 (1- (strlen text))))
 (alert "Wrong character removed, try again")
      ) 
 ) 
) 
)  
(defun rem_blanks  (input) 
   (vl-list->string 
     (vl-remove 32 
      (vl-string->list input) 
  ) 
     ) 
 ) 
  
 (setvar "CMDECHO" 0) 
 (setq dcl_id (load_dialog "NUMP.dcl")) 
 (if (not (new_dialog "NUMP" dcl_id)) 
   (exit)) 
(action_tile 
 "txt" 
 "(box_callback $value $reason)" 
) 
 (action_tile "accept" (strcat 
      "(progn "   
   "(setq text (get_tile \"txt\"))" 
    "(done_dialog 1))")) 
 (action_tile 
   "cancel" 
   "(done_dialog 2)") 
 (setq pick (start_dialog)) 
 (unload_dialog dcl_id) 
 (if (= pick 1) 
   (alert (strcat "You entered: " (rem_blanks text)))) 
 (setvar "CMDECHO" 1) 
 (princ) 
 ) 

 

//DCL

 

   NUMP : dialog { 
  label = "Validate Text Input";
  spacer;
   :row {                                   
   fixed_width = true; 
   : boxed_column { 
   label = " Enter numbers in format of  XXX.X.XX:"; 
   fixed_width = true; 
   width=30; 
   : edit_box { 
   key = "txt"; 
   initial_focus=true; 
   edit_width =29;
   fixed_width_font =true;
   } 
   spacer; 
   } 
   } 
   ok_cancel; 
   }  

Guest kruuger
Posted

load attached file and then:

(cd:DCL_StdEditBoxDialog
 (list 3
   (list
     (cons 1 "Enter real number")
     (cons 2 "Number can't be a zero")
     (cons 8 "Space not allowed")
     (cons 16 "This is not a number")
     (cons 32 "Number to small")
     (cons 64 "Number to big")
   )
   "19" -100 100 2 2
 )
 "Level" "Enter level: (-100 < X < 100)" 40 13 (list "&Ok" "&Cancel") T nil
)

kruuger

CADPL-Pack-v1.lsp

editbox.gif

Posted

Tharwat, this is for you.

I know that I am a newbie in these adventures of programming, and I am sorry if you think do you questions require wasting time. I'm not a programmer, and my English is not good, but I want to learn. And I try to learn to my pace. I am sorry if it upset you.

To my friends Fixo and Kruuger. Thank you very much for the help and for everything.

A hug.

Posted

@Kruuger: You may want to simplify the syntax of the list used as argument to avoid some evaluations:

'(3
 ((1  . "Enter real number")
  (2  . "Number can't be a zero")
  (8  . "Space not allowed")
  (16 . "This is not a number")
  (32 . "Number to small")
  (64 . "Number to big"))
 "19" -100 100 2 2)

Guest kruuger
Posted
@Kruuger: You may want to simplify the syntax of the list used as argument to avoid some evaluations:

thanks MSasu

 

one more:

(cd:DCL_StdEditBoxDialog
'(1
   (
     (1  . "Empty string error")
     (2  . "Invalid layer name")
     (4  . "Layer already exist")
     (8  . "Space not allowed")
     (16 . "Layer do not match pattern")
     (32 . "Number to small")
   )
   "" "LAYER" "??-???"
 )
 "Layer" "Enter layer name (format ##-###)" 40 13 (list "&Im sure" "&Leave window") T 6
)

Posted
Tharwat, this is for you.

I know that I am a newbie in these adventures of programming, and I am sorry if you think do you questions require wasting time. I'm not a programmer, and my English is not good, but I want to learn. And I try to learn to my pace. I am sorry if it upset you.

To my friends Fixo and Kruuger. Thank you very much for the help and for everything.

A hug.

 

I believe it is customary to respond with some sort of feedback after help/advise/solutions has been provided, at least a 'thank you' (as highlighted in your last post) or whether the advice/help/solution was sufficient. Your other thread asks for help and you provided 0 feedback.

 

Your feedback also provides help for others seeking similar solutions.

Posted

I recognise that you are full of reason SLW210 and I apologise for that. Because of an accident at work I am the bearer of a deficiency that affects cognitive ability and that makes me forget what I studied last month, but that's a personal problem that doesn't tell you about and as such I apologise and promise that I will not ask any questions. To be here to write these lines I have to use an online translator, I hope that doesn't bother.

Thank you from the bottom of my heart to all those who have helped me.

Until always.

 

R. Mateus

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...