Jump to content

Recommended Posts

Posted

(action_tile
   "accept"						;if O.K. pressed
   (strcat						;string 'em together
     "(progn 
     [color="red"] (setq SIZ (atof (get_tile \"selections\")))"[/color]	;get list selection
     " (done_dialog)(setq userclick T))"		;close dialog, set flag
   );strcat
 );action tile

 (start_dialog)					;start dialog

 (unload_dialog dcl_id)				;unload

  (if userclick					;check O.K. was selected
   (progn

     [color="red"](setq SIZ (fix SIZ))	[/color]			;convert to integer; 
    [color="red"] (setq SIZ (nth SIZ NAMES))[/color]			;get the size

   );progn

 );if userclick

(princ)

 

Hello Tigers

 

i'm stuck here,this tutorial was taken from link below. If value in tile "selection"

is "M8", how come that atof function processes it. http://www.afralisp.net/dialog-control-language/tutorials/dialog-boxes-and-autolisp-part-2.php

Posted

Since the 'selections' tile is a list tile, (applies to list_box / popup_list), get_tile return a string containing the zero-based index of the selected item. The author has used the atof function to convert this string to a real, then used fix to convert to an integer. If I were writing it, I would cut out the middle-man and use atoi to convert directly to an integer.

 

Lee

Posted

Thanks for reply.

get_tile returns a string containing the zero-based index of the selected item
, In the tutorial one of the element in list is "M10", (atof (of that) returns "M10"

if I plugin "m10" after couple of lines in this (setq SIZ (fix SIZ)) doesn't work.

 

atof - This function changes a string into a real number.

 

        Syntax : (atof string)

           string - any valid string.

                (atof "345") returns 345.0

                (atof "345.9") returns 345.9

                (atof 345) returns "Error: Bad Argument Type"   [345 is a number, not a string]

                (atof 345.9) returns "Error: Bad Argument Type"   [345.9 is a number, not a string]

                (atof "-345") returns -345.0

                (atof "-345.9") returns -345.9

                (atof "345JEFF49") returns 345.0

                (atof "JEFF49") returns 0.0

looked here too...

if it converts to a real number how come the output is string. I'm sure Lee answered fully covering the question...however it didn't click yet

Posted

re-read my post - for a list tile, get_tile returns the index of the selected item.

 

Hence, if the first item is selected, get_tile returns "0", if the second, "1" etc. etc.

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...