1 /*
2    Copyright (C) 1999-2000 T. Scott Dattalo
3 
4 This file is part of gpsim.
5 
6 gpsim is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10 
11 gpsim is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with gpsim; see the file COPYING.  If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.  */
20 
21 
22 #include <iostream>
23 #include <iomanip>
24 #include <string>
25 #include <stdio.h>
26 
27 #include "command.h"
28 #include "cmd_set.h"
29 #include "input.h"
30 
31 #include "../src/pic-processor.h"
32 
33 static int radix = 0;   // FIXME
34 
35 cmd_set c_set;
36 
37 enum {
38   SET_VERBOSE,
39   SET_RADIX,
40 };
41 
42 static cmd_options cmd_set_options[] =
43 {
44   {"r",          SET_RADIX,      OPT_TT_NUMERIC},
45   {"radix",      SET_RADIX,      OPT_TT_NUMERIC},
46   {"v",          SET_VERBOSE,    OPT_TT_BITFLAG},
47   {"verbose",    SET_VERBOSE,    OPT_TT_BITFLAG},
48   {0,0,0}
49 };
50 
51 
cmd_set()52 cmd_set::cmd_set()
53   : command("set",0)
54 {
55   brief_doc = string("display and control gpsim behavior flags");
56 
57   long_doc = string ("set\n"
58     "\twith no options, set will display the state of all of gpsim's\n"
59     "\tbehavior flags. Use this to determine the flags that may be\n"
60     "\tmodified.\n"
61     "\n");
62 
63   op = cmd_set_options;
64 }
65 
66 
67 
set(void)68 void cmd_set::set(void)
69 {
70 
71   cout << "r | radix = " << radix << " (not fully functional)\n";
72   cout << "v | verbose =  " << (unsigned int)verbose << '\n';
73   //  cout << "gui_update = " << gi.update_rate << '\n';
74 }
75 
set(int bit_flag,Expression * expr)76 void cmd_set::set(int bit_flag, Expression *expr)
77 {
78   int number=1;
79 
80   if(expr) {
81     try
82       {
83 	Value *v = expr->evaluate();
84 	if(v) {
85 	  gint64 i;
86 	  v->get(i);
87 	  number = (int)i;
88 	  delete v;
89 	}
90 	delete expr;
91       }
92     catch (Error &err)
93       {
94 	  std::cout << "ERROR:" << err.what() << '\n';
95 	return;
96       }
97   }
98 
99   switch(bit_flag) {
100   case SET_VERBOSE:
101     GetUserInterface().SetVerbosity(number);
102     break;
103   default:
104     cout << " Invalid set option\n";
105   }
106 }
107 
108