Menu

Values of switches

Help
arpi
2019-02-16
2019-02-19
  • arpi

    arpi - 2019-02-16

    Dear All,
    I cannot find in the help how to access the values of switches. What I actually wanted to do, is to save the value of a switch at the start of an included file (e.g., echo), set it to something (off), do what that file does, and then set it back to its original value. All the stuff I wrote is in normal algebraic mode.
    Can someone point me in the right direction?

    Thank you.

     
    • Francis Wright

      Francis Wright - 2019-02-16

      The setting of a switch called switch is represented by the value of the lisp variable !switch: the value is t for on and nil for off. However, changing the settings of some switches runs additional code, so in general you can't just change the value of !switch to change the switch setting. To save and then reset the switch called switch from algebraic-mode code, you could do this:

      global '(oldswitch!*);

      symbolic << oldswitch! := !switch; off1 'switch >>; % or use on1 to turn the switch on.

      Include your code here.

      symbolic onoff('switch, oldswitch!*);

      Note that I haven't checked that the code above runs correctly. If you have trouble with it then you are welcome to email me privately.

      If you want to see how switches work then please see the file packages/rlisp/switch.red in the REDUCE source code tree.

      Francis

      -----Original Message-----
      From: arpi lukacsarpad@users.sourceforge.net
      Sent: Saturday, 16 February 2019 1:36 pm
      To: [reduce-algebra:discussion] 899364@discussion.reduce- algebra.p.re.sourceforge.net
      Subject: [reduce-algebra:discussion] Values of switches

      Dear All,
      I cannot find in the help how to access the values of switches. What I
      actually wanted to do, is to save the value of a switch at the start of an
      included file (e.g., echo), set it to something (off), do what that file does,
      and then set it back to its original value. All the stuff I wrote is in normal
      algebraic mode.
      Can someone point me in the right direction?

      Thank you.


      Values of switches


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/reduce-algebra/discussion/899364/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
      • arpi

        arpi - 2019-02-19

        Thank you. Your code works.

         

Log in to post a comment.