Author Topic: How do I set a variable to "Nothing"  (Read 11161 times)

0 Members and 1 Guest are viewing this topic.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
How do I set a variable to "Nothing"
« on: April 15, 2006, 09:54:48 AM »
How do I set a variable to nothing?  Not nil, not zero, not false.

I am setting up condition statements for multiple DCL toggles.  If action toggle = 1 ~ then set the variable to a value; if = 0 then set variable to nothing.  Then I will strcat all the variables together and hopefully only have a string showing only the toggle(s) that were checked.

Or will I have to use “nil” or like something mention above?  And use the vl-string-subst function? 
This I am foreseeing as a problem because I want to substitute it with nothing.  I don’t want to replace it with a space or a character.  My goal is to keep the final string as short as possible.


Or am I total mad and going about this wrong way.  I tried to do search and was getting too many hits with all the /promt “nothing selected” code.

Thanks
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How do I set a variable to "Nothing"
« Reply #1 on: April 15, 2006, 10:02:44 AM »
I am setting up condition statements for multiple DCL toggles.  If action toggle = 1 ~ then set the variable to a value; if = 0 then set variable to nothing.  Then I will strcat all the variables together and hopefully only have a string showing only the toggle(s) that were checked.

Sorry, should have clarified my intents one step further.

I have a condition statement for each toggle that evaluates that particular toggle.

Thanks again
Ted
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How do I set a variable to "Nothing"
« Reply #2 on: April 15, 2006, 10:35:14 AM »
I would need some code to figure out what you are trying to do.
But here is how I approach the dcl toggle.

I always set the lisp variable to some default.


Method one:
Use a string to hold the state of the lisp variable.
"0" = not checked
"1" = checked

Code: [Select]
;;  this is somewhere in the startup
(setq MyLispVar-ToggleOne "1") ; set default value

Code: [Select]
;;  This is in my DCL setup
(action_tile "MyToggleOne" "(setq MyLispVar-ToggleOne $value))")
(set_tile "MyToggleOne" MyLispVar-ToggleOne) ; set the default state

There is no need to get the DCL toggle state on exit from the Dialog because it is
set prior to entry & will update the Lisp variable if the user changed it.

Method two:
Use true nil to hold the state of the lisp variable.
nil = not checked
t   = checked

Code: [Select]
;;  this is somewher in the startup
(setq MyLispVar-ToggleOne t) ; set default value

Code: [Select]
;;  This is in my DCL setup
(action_tile "MyToggleOne" "(setq MyLispVar-ToggleOne (= $value \"1\"))")
(set_tile "MyToggleOne" (if MyLispVar-ToggleOne "1" "0")) ; set the default state

There is no need to get the DCL toggle state on exit from the Dialog because it is
set prior to entry & will update the Lisp variable if the user changed it.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How do I set a variable to "Nothing"
« Reply #3 on: April 15, 2006, 10:49:58 AM »
Here is the code that I have so far.  I believe that I am using Method 1 as you described. 
The portion that I need help in is at [;;Evaluating Toggles selected~~]

Code: [Select]
  ;; ;;PreSets Dialog Box Variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

(setq which_action 1)

(if (not toggle1) ;if no default
  (setq toggle1 "0") ;set default value
) ;if

(if (not toggle2) ;if no default
  (setq toggle2 "0") ;set default value
) ;if

 

  ;; ;;Starts Dialog Box Session~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

(setq dcl_id (load_dialog "samp4.dcl")) ;load dialog

(if (not (new_dialog "samp4" dcl_id) ;test for dialog

    ) ;not

  (exit) ;exit if no dialog

) ;if

  ;;;Radio Button Row~~~~~~~~~~~~~~~~~~~~~~
(setq which_action 1)
  (action_tile "rb1" "(setq which_action 1)")
;New version 2004 file with date Prefix
  (action_tile "rb2" "(setq which_action 2)")
;New version 2000 file with date Prefix
  (action_tile
    "cancel" ;if cancel button pressed
    "(done_dialog) (setq userclick nil)" ;close dialog, set flag
  );action_tile

;;;Toggle Alley~~~~~~~~~~~~~~~~~~~~~~
    (set_tile "tog1" toggle1)
  ;set toggle

  (set_tile "tog2" toggle2)
  ;set toggle

   (action_tile "tog1"
   ;if toggle 1 selected

      "(setq toggle1 $value)"
       ;get the value

   );action_tile

   (action_tile "tog2"
   ;if toggle 2 selected

      "(setq toggle2 $value)"
       ;get the value

   );action_tile

  ;;;Evaluating Toggles selected~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  (setq name1 " ")
(cond ;start of Cond
  ((= toggle1 "1") (setq name1 "BSE"))

  ((= toggle1 "0") (setq name1 "")) ;;  this is where I am trying to get the "Nothing"

) ;End of Cond
  ;;Strings all the selected together ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(setq ConNames (strcat name1))


  (action_tile
    "accept" ;if O.K. pressed
    " (done_dialog)(setq userclick T))" ;close dialog, set flag
  ) ;action tile

  (start_dialog) ;start dialog

  (unload_dialog dcl_id) ;unload

  (princ)

I have to go and be the gracious host to my in-laws.  :-D
Looking forward to your response on Monday. 
Thanks,
Ted
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How do I set a variable to "Nothing"
« Reply #4 on: April 15, 2006, 11:52:36 AM »
This is how I would aproach the code.
Although I still don't have an understanding of what you want refering to "nothing"

Code: [Select]
;;PreSets Dialog Box Variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;; set default values
(setq which_action 1)
(or toggle1 (setq toggle1 "0"))
(or toggle2 (setq toggle2 "0"))

;; ;;Starts Dialog Box Session~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(setq dcl_id (load_dialog "samp4.dcl")) ;load dialog

;; test for dialog
(if (not (new_dialog "samp4" dcl_id))
  (exit)
)

;;;Radio Button Row~~~~~~~~~~~~~~~~~~~~~~
(setq which_action 1)
(action_tile "rb1" "(setq which_action 1)") ;New version 2004 file with date Prefix
(action_tile "rb2" "(setq which_action 2)") ;New version 2000 file with date Prefix

;;;Toggle Alley~~~~~~~~~~~~~~~~~~~~~~
(set_tile "tog1" toggle1)
(set_tile "tog2" toggle2)

(action_tile "tog1" "(setq toggle1 $value)")
(action_tile "tog2" "(setq toggle2 $value)")



(setq userclick (= (start_dialog) 1))
(unload_dialog dcl_id) ;unload

;;;Evaluating Toggles selected~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(if userclick
  (setq connames
         (list
           (if (= toggle1 "1") "BSE" "")
           (if (= toggle2 "1") "BSE" "")
         )
  )
)

;;  at this point connames is nil if the user canceled
;;  or it contains a list of BSE or "" as per the toggles

(princ)


If you are using ok_cancel; or similar for exit buttons the (done_dialog) passes a 0 or 1
to the (start_dialog) and that is returned. So you can test the exit condition.

From the help file:
Quote
The start_dialog function returns the optional status passed to done_dialog. The
default value is 1 if the user presses OK, 0 if the user presses Cancel, or -1
if all dialog boxes are terminated with term_dialog. If done_dialog is passed an
integer status greater than 1, start_dialog returns this value, whose meaning is
determined by the application.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How do I set a variable to "Nothing"
« Reply #5 on: April 15, 2006, 01:45:18 PM »
Okay I managed to get a few minutes while the wife and mother-in-law go shopping.  This problem is nagging at me in back of my head so I jump on the wife's computer and dial-up (It hurts us, it hurts us) :-).  So therefore I have No Acad and no lisp to try things.

Okay so here goes on further explaining "Nothing" 
Let say I have 5 toggles and they all stand for consultants names.  My condition statement assigns initials for the consultants names for each of the toggles.  Lets say the user checks 3 out of the 5.  For the 2 that were not selected i am getting nil or zero.  (the variable watch told me so)  right what is happening I strcat the all the "name1 thru name5 variables i getting the 0 and/or nil in the return of the variable ConNames

for example
(setq ConNames (strcat name1 name2 name3 name4 name5))

and if tog1, tog2 & tog4 was selected

I am getting a return for the variable conNames = name1nam200name40.
I don't want zeros.  I want to remove them and squeeze the string together so the desired return for ConName variable would be = name1name2name4

I hope this helps.  See you Monday.
Thanks for your help.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How do I set a variable to "Nothing"
« Reply #6 on: April 15, 2006, 06:07:49 PM »
OK, use this:
Code: [Select]
(if userclick
  (vl-remove nil
             (setq connames
                    (list
                      (if (= toggle1 "1") "name1")
                      (if (= toggle2 "1") "name2")
                      (if (= toggle3 "1") "name3")
                      (if (= toggle4 "1") "name4")
                    )
             )
  )
)

Gives you this:
Code: [Select]
("name1" "name2" "name4")
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How do I set a variable to "Nothing"
« Reply #7 on: April 17, 2006, 06:46:22 AM »
Okay I see what you are doing and but I have questions on some parts of how you are doing it.  I spent this morning looking at Autodesk's help sectionwith very little success in explaining how you are doing it.  They always leave me hanging on some issues.

I arrived this morning to email from an industrious Sunday working architect giving me marching orders and to have those orders completed for a 10am meeting.  So I will be back questions.

Again thanks for you help.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: How do I set a variable to "Nothing"
« Reply #8 on: April 17, 2006, 09:27:39 AM »
nothing, just testing ..........
TheSwamp.org  (serving the CAD community since 2003)

whdjr

  • Guest
Re: How do I set a variable to "Nothing"
« Reply #9 on: April 17, 2006, 11:32:02 AM »
What about mode_tile?

You could use that to enable it or disable it.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How do I set a variable to "Nothing"
« Reply #10 on: April 17, 2006, 12:10:53 PM »
Okay I managed to get a few minutes while the wife and mother-in-law go shopping.  This problem is nagging at me in back of my head so I jump on the wife's computer and dial-up (It hurts us, it hurts us) :-).  So therefore I have No Acad and no lisp to try things.

Okay so here goes on further explaining "Nothing" 
Let say I have 5 toggles and they all stand for consultants names.  My condition statement assigns initials for the consultants names for each of the toggles.  Lets say the user checks 3 out of the 5.  For the 2 that were not selected i am getting nil or zero.  (the variable watch told me so)  right what is happening I strcat the all the "name1 thru name5 variables i getting the 0 and/or nil in the return of the variable ConNames

for example
(setq ConNames (strcat name1 name2 name3 name4 name5))

and if tog1, tog2 & tog4 was selected

I am getting a return for the variable conNames = name1nam200name40.
I don't want zeros.  I want to remove them and squeeze the string together so the desired return for ConName variable would be = name1name2name4

I hope this helps.  See you Monday.
Thanks for your help.

Not sure I understand, but for fun, and to think outside the box consider --

Replicate test environs --

Code: [Select]
(setq
    toggle1  t
    toggle2  t
    toggle3  nil
    toggle4  t
)

And then --

Code: [Select]
(apply 'strcat
    (mapcar
       '(lambda ( index / suffix )
            (if
                (vl-symbol-value
                    (read
                        (strcat "toggle"
                            (setq suffix (itoa index))
                        )
                    )
                )
                (strcat "Name" suffix)
                ""
            )   
        )
       '(1 2 3 4)
    )
)

Result --

Code: [Select]
"Name1Name2Name4"
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How do I set a variable to "Nothing"
« Reply #11 on: April 17, 2006, 12:20:14 PM »
If i understand correctly, Krushert wants to gather up the results of the user picked toggles
and combine them into a string created based on the states of the toggles. He was having a problem
ignoring the unchecked toggles.
My example returned a list of strings for the checked toggles only and if he wants to combine them
he could use this.

(setq str (apply 'strcat connames))

but I think the list may serve him better.


MP beat me to the enter key again. :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How do I set a variable to "Nothing"
« Reply #12 on: April 17, 2006, 12:26:39 PM »
Perhaps this will illuminate better --

Code: [Select]
(setq
    toggle1  t
    toggle2  nil
    toggle3  t
)

Code: [Select]
(setq
    toggles '(toggle1 toggle2 toggle3)
    names   '("Fred" "Barney" "Wilma")
)

Code: [Select]
(apply 'strcat
    (mapcar
       '(lambda (toggle name) (if (vl-symbol-value toggle) name ""))
        toggles
        names
    )
)

Code: [Select]
"FredWilma"
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How do I set a variable to "Nothing"
« Reply #13 on: April 17, 2006, 12:47:59 PM »
Yes Cab you understood me correctly.  Of course my day is screwed up so can not list all my questions at once.  Sorry about that.  Below is my first question.  I only have a few.  :-)  Please keep in mind that I question to learn the "hows & whys" not imply "Why aren't you doing this way?"  I almost had a shovel on the head because I made that implication a long time ago.   :-D


How does the your "or" replace my " if (not " and why?  I think you are streamling it but not sure.  For that matter I really don't understand how my " if (not " works.
Yours:

Code: [Select]
;;PreSets Dialog Box Variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;; set default values
(setq which_action 1)
(or toggle1 (setq toggle1 "0"))
(or toggle2 (setq toggle2 "0"))

Mine:
Code: [Select]
  ;; ;;PreSets Dialog Box Variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(setq which_action 1)
(if (not toggle1) ;if no default
  (setq toggle1 "0") ;set default value
) ;if
(if (not toggle2) ;if no default
  (setq toggle2 "0") ;set default value
) ;if
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How do I set a variable to "Nothing"
« Reply #14 on: April 17, 2006, 01:15:25 PM »
Second how & why question.

You replace my
Code: [Select]
  (action_tile "cancel" "(done_dialog) (setq userclick nil)" )
         ;;if cancel button pressed close dialog, set flag
 
  (action_tile "accept" " (done_dialog)(setq userclick T))")
         ;;if O.K. pressed close dialog, set flag

  (start_dialog) ;start dialog
  (unload_dialog dcl_id) ;unload



with yours
Code: [Select]
(setq userclick (= (start_dialog) 1))
(unload_dialog dcl_id) ;unload

Again I believe that your streamlining the code but not sure exactly how.  I do see the userclick variable being set to 1 instead of T so it can be used later on in "list".  Not sure how the Start Dialog activate it though. 
Where did the "cancel" go??
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How do I set a variable to "Nothing"
« Reply #15 on: April 17, 2006, 01:16:35 PM »
<1st question>
"Streamlining", well yes in my eyes. As you know "Beauty is in the eyes of the beholder"
Nothing wrong with the way you did it. I just changed it to expose you to an alternate method.
Nothing more than that.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Amsterdammed

  • Guest
Re: How do I set a variable to "Nothing"
« Reply #16 on: April 17, 2006, 01:17:50 PM »
Hi
If you want to set a string to nothing (that is how I understand your problem) why not set it to an empty string:
Code: [Select]
""

Bernd

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How do I set a variable to "Nothing"
« Reply #17 on: April 17, 2006, 01:19:59 PM »
Tried that, was getting the Quotes ("") in my string.

Hi
If you want to set a string to nothing (that is how I understand your problem) why not set it to an empty string:
Code: [Select]
""

Bernd
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: How do I set a variable to "Nothing"
« Reply #18 on: April 17, 2006, 01:25:50 PM »
In simplistic terms, OR produces a result by examining the items in the comparison individually, thus (or toggle1 (setq toggle1 "0")) will evaluate toggle1 and if it has a value (i.e. not nil) then it will not evaluate the second expression (setq toggle1 "0") ... you could theoretically string together many multiples of true/false statements and evaluate them until one evaluates true in this fashion. It would evaluate much like a conditional statement, evaluating each until a true is found. Once a single true statement is found, the code will exit from that line of code because what you are saying is essentially "if any one of the following statements are true" ... you don't need to evaluate the setq because it will always return a T unless you set it to nil.

I hope that explains it a little better ...

<edited for spelling>
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How do I set a variable to "Nothing"
« Reply #19 on: April 17, 2006, 01:27:24 PM »
<1st question>
"Streamlining", well yes in my eyes. As you know "Beauty is in the eyes of the beholder"
Nothing wrong with the way you did it. I just changed it to expose you to an alternate method.
Nothing more than that.

:-D  Yes I know my code is ugly when compared to yours and the other grand masters of the swamp.  My first thought was my code is like the old WW1 tanks; slow and clunky nest to todays Abrams tanks.   :-D

That is why i asked all the questions.

Off to my morning 10:00 meeting in the afternoon.
Be back in a little.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How do I set a variable to "Nothing"
« Reply #20 on: April 17, 2006, 01:51:22 PM »
If you are using ok_cancel; or similar for exit buttons the (done_dialog) passes a 0 or 1
to the (start_dialog) and that is returned. So you can test the exit condition.

From the help file:

Quote
The start_dialog function returns the optional status passed to done_dialog. The
default value is 1 if the user presses OK, 0 if the user presses Cancel, or -1
if all dialog boxes are terminated with term_dialog. If done_dialog is passed an
integer status greater than 1, start_dialog returns this value, whose meaning is
determined by the application.

You do not need an action_tile as the (done_dialog) is called by default & a 0 or 1 is
passed to the (start_dialog) for a return value.

All I did was to change the return value 0 or 1 to a nill or true representation of the result.

Did that answer your question?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How do I set a variable to "Nothing"
« Reply #21 on: April 18, 2006, 06:33:41 AM »

All I did was to change the return value 0 or 1 to a Nil or true representation of the result......So you can test the exit condition.


Okay I see it now.  By seeing if the start dialog is equal to one it would return a true and you used that to set the userclick variable.    It took along time to for me to see how it was setting the variable.  I was expecting a complicated test but in reality you made it very simple.  OOhhh you're good.

Did that answer your question?
It did but just brings more questions.  :-)
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How do I set a variable to "Nothing"
« Reply #22 on: April 18, 2006, 08:47:47 AM »
It did but just brings more questions.  :-)


I'll try.. :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How do I set a variable to "Nothing"
« Reply #23 on: April 18, 2006, 09:34:03 AM »
OK, use this:
Code: [Select]
(if userclick
  (vl-remove nil
             (setq connames
                    (list
                      (if (= toggle1 "1") "name1")
                      (if (= toggle2 "1") "name2")
                    ;;;  (if (= toggle3 "1") "name3")
                    ;;;  (if (= toggle4 "1") "name4")
                    )
             )
  )
)

Gives you this:
Code: [Select]
("name1" "name2" "name4")

Okay, I plunk the this into the code and commented out only the lines for toggles 3 & 4.  I have not set those toggles yet.  I am not getting the return as predicted.  See the Variable Watch below.
Code: [Select]
LOG Watch
CONNAMES = nil
DCL_ID = 1
NAME1 = nil
NAME2 = nil
TOGGLE1 = "1"
TOGGLE2 = "1"
USERCLICK = nil
WHICH_ACTION = 1

Correct me where I go astray in my thinking what this code is attempting to do.
Step one it looks at (= toggle1 "1") and if this is true it returns "name1" to the list that is Setq to the variable connames.  If (= toggle1 "0") then returns a nil which eventually is removed from the list by the (vl-remove nil) function.  This I understand and follow. 

What is the (if userclick) doing? What is it being compared to with IF function?

Oh yeah, why am I getting the results that I am getting?
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How do I set a variable to "Nothing"
« Reply #24 on: April 18, 2006, 10:07:36 AM »
Post the code you are now using.
Looks like you are exiting the dialog box via cancel.
USERCLICK should = true if you exit with OK.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Binky

  • Guest
Re: How do I set a variable to "Nothing"
« Reply #25 on: April 18, 2006, 10:17:27 AM »
Being somewhat new I often get results that I did not quite intend or in the manner I wished for reasons that will become clear to me as I learn more.  In the meantime I find I can keep the train on the tracks by 'fixing' the results I got until enlightment shines upon my soul.  I would attack the returned string (being thrilled that I got anything back).  If the problem is '0's in the string I would remove the '0's.

(setq abc "one0two00three")
(repeat 5 (setq abc (vl-string-subst "" "0" abc)))
returned "onetwothree"

However vl-string-subst only replace 1 instance so I wrapped it in a repeat.
elegant-probably not, more like using a rusty scalpel. but hey it worked

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How do I set a variable to "Nothing"
« Reply #26 on: April 18, 2006, 10:27:37 AM »
:oops: Me redfaced overhere.    :whistle:
I commented out your Accept/Cancel code to compare the results with my original code.  I forget to Un-Comment your code so as the userclick would work.  The routine works great.

That Apply function is a sweet little function.  One of the function that Autodesk explained nicely. Thanks for letting me know about that one.  I would have never thought to go down that road of thinking.

Now I am going to organize (pretty it up  :-D) this piece of the pie and dump back in to the main routine.  Hopefully everything everything will play nice with each other.

Thanks for your help.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How do I set a variable to "Nothing"
« Reply #27 on: April 18, 2006, 10:29:06 AM »
Thanks for your help.

This reminds me.
Thanks to all that have help and/or made suggestions. 
 :-)
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How do I set a variable to "Nothing"
« Reply #28 on: April 19, 2006, 08:38:21 AM »
I knew it was going too easy. :x

Does anyone know why the vl-remove function would stop working.  I was cleaning up and organizing the portion of code that been posted above.   All this morning, the vl-remove function was working great when I ran it numerous times giving me the expected returns.  When I copied this portion into the main routine it stop working right at the vl-remove function. Both lisp files have stop working at exactly the same spot.

Below is the portion of code with vl-remove function.
Code: [Select]
  ;; ;;PreSets Dialog Box Variables with Defaults~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

(setq which_action 1)
(or toggle1 (setq toggle1 "0"))
(or toggle2 (setq toggle2 "0"))
(or toggle3 (setq toggle3 "0"))
(or toggle4 (setq toggle4 "0"))
(or toggle9 (setq toggle9 "0"))
(or toggle10 (setq toggle10 "0"))

  ;; ;;Starts Dialog Box Session~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

(setq dcl_id (load_dialog "samp4.dcl")) ;load dialog

(if (not (new_dialog "samp4" dcl_id) ;test for dialog
    ) ;not
  (exit) ;exit if no dialog
) ;if

;;;  Radio Button Row~~~~~~~~~~~~~~~~~~~~~~
  (setq which_action 1)
  (action_tile "rb1" "(setq which_action 1)")
;New version 2004 file with date Prefix
  (action_tile "rb2" "(setq which_action 2)")
;New version 2000 file with date Prefix

 
;;; Toggle Alley~~~~~~~~~~~~~~~~~~~~~~
  (set_tile "tog1" toggle1)  ;set toggle
  (set_tile "tog2" toggle2)  ;set toggle
  (set_tile "tog3" toggle3)  ;set toggle
  (set_tile "tog4" toggle4)  ;set toggle
  (set_tile "tog9" toggle9)  ;set toggle
  (set_tile "tog10" toggle10)  ;set toggle

  (action_tile "tog1" "(setq toggle1 $value)");if toggle 1 selected - get the value
  (action_tile "tog2" "(setq toggle2 $value)");if toggle 2 selected - get the value
  (action_tile "tog3" "(setq toggle3 $value)");if toggle 3 selected - get the value
  (action_tile "tog4" "(setq toggle4 $value)");if toggle 4 selected - get the value
  (action_tile "tog9" "(setq toggle9 $value)");if toggle 9 selected - get the value
  (action_tile "tog10" "(setq toggle10 $value)");if toggle 10 selected - get the value


;;; Accepting & Canceling Buttons~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

(setq userclick (= (start_dialog) 1))
(unload_dialog dcl_id) ;unload
(princ)
 
;;;Evaulating Toggles selected~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

(if userclick
  (vl-remove nil
             (setq ConList
                    (list
                      (if (= toggle1 "1") "BSE")
                      (if (= toggle2 "1") "BEI")
                      (if (= toggle3 "1") "MnA")
                      (if (= toggle4 "1") "LnL")
      (if (= toggle9 "1") "Clnt")
      (if (= toggle10 "1") "OTH")
                    )
             )
  )
)

  (setq ConNames (strcat (apply 'strcat ConList) "_")) ;to be stored for the StrPath function

;;;;;; Main Application ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Posted from the Variable watch.
Code: [Select]
LOG Watch
...............
CONLIST = ("BSE" "BEI" nil nil nil nil)
CONNAMES = nil
DCL_ID = 3
NEWFILE = nil
OLDFILE = nil
TOGGLE1 = "1"
TOGGLE10 = "0"
TOGGLE2 = "1"
TOGGLE3 = "0"
TOGGLE4 = "0"
TOGGLE9 = "0"
USERCLICK = T
WHICH_ACTION = 1

 :realmad:
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How do I set a variable to "Nothing"
« Reply #29 on: April 19, 2006, 09:02:04 AM »
Because it's in the wrong place. :-)
Code: [Select]
(if userclick
  (setq ConList
             (vl-remove nil
                    (list
                      (if (= toggle1 "1") "BSE")
                      (if (= toggle2 "1") "BEI")
                      (if (= toggle3 "1") "MnA")
                      (if (= toggle4 "1") "LnL")
      (if (= toggle9 "1") "Clnt")
      (if (= toggle10 "1") "OTH")
                    )
             )
  )
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How do I set a variable to "Nothing"
« Reply #30 on: April 19, 2006, 09:23:37 AM »
Looking at this:
Code: [Select]
(setq ConNames (strcat (apply 'strcat ConList) "_")) ;to be stored for the StrPath function
Should it be this?
Code: [Select]
(setq ConNames (apply 'strcat (mapcar '(lambda (x) (strcat x "_" ))ConList)))
not sure what result you are looking for.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How do I set a variable to "Nothing"
« Reply #31 on: April 19, 2006, 09:27:54 AM »
Hey it works.

Because it's in the wrong place. :-)

 :-D OH the program was jumping off the side of Ship. It reminds me when I was navy shipwelder and they sent a bunch of us to a introduction class on computers.  They explained to us in "welders terms" of how a computer thinks, "be careful of what instructions you give to a computer or it will jump ship".  :-)
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How do I set a variable to "Nothing"
« Reply #32 on: April 19, 2006, 09:40:22 AM »
Code: [Select]
(mapcar '(lambda (x) (strcat x "_" ))ConList)))
Exposing me to that Greek stuff again aren't you? :-)


This is giving me what I need "now".  I need to place a  separator between CONNAMES and the OLDNAME.  However by doing this way, will it give me problems done the road?  I don't know.  Will it? 
Code: [Select]
(setq ConNames (strcat (apply 'strcat ConList) "_")) ;to be stored for the StrPath functionCONLIST = ("BSE" "BEI")
CONNAMES = "BSEBEI_"
OLDNAME = "Floor-Base.dwg"
DCL_ID = 10
NEWFILE = "M:\\.......\\Transfer-Outgoing\\04-19-06_BSEBEI_Floor-Base.dwg"
Code: [Select]
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How do I set a variable to "Nothing"
« Reply #33 on: April 19, 2006, 11:42:24 AM »
If the resulting file name is what you want then it looks fine to me. :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.