Changeset 314 for cpp/frams/param
 Timestamp:
 01/26/15 13:03:22 (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

cpp/frams/param/param.cpp
r312 r314 139 139 case 'f': 140 140 { 141 double a = 0, b = 0, c= 0;142 if (getMinMax(i, a, b, c) < 3) c = a;143 setDouble(i, c);141 double mn = 0, mx = 0, def = 0; 142 if (getMinMax(i, mn, mx, def) < 3) def = mn; 143 setDouble(i, def); 144 144 } 145 145 break; 146 146 case 'd': 147 147 { 148 paInt a = 0, b = 0, c= 0;149 if (getMinMax(i, a, b, c) < 3) c = a;150 setInt(i, c);148 paInt mn = 0, mx = 0, def = 0; 149 if (getMinMax(i, mn, mx, def) < 3) def = mn; 150 setInt(i, def); 151 151 } 152 152 break; 153 153 case 's': case 'x': 154 154 { 155 int a, b; SString c;156 getMinMax(i, a, b, c);155 int mn, mx; SString def; 156 getMinMax(i, mn, mx, def); 157 157 if (*t == 's') 158 setString(i, c);158 setString(i, def); 159 159 else 160 160 { 161 if ( c.len() > 0) setExtValue(i, ExtValue(c)); else setExtValue(i, ExtValue::empty());161 if (def.len() > 0) setExtValue(i, ExtValue(def)); else setExtValue(i, ExtValue::empty()); 162 162 } 163 163 } … … 176 176 case 'f': 177 177 { 178 double a = 0, b = 0, c= 0;179 getMinMax(i, a, b, c);180 setDouble(i, a);178 double mn = 0, mx = 0, def = 0; 179 getMinMax(i, mn, mx, def); 180 setDouble(i, mn); 181 181 } 182 182 break; 183 183 case 'd': 184 184 { 185 paInt a = 0, b = 0, c= 0;186 getMinMax(i, a, b, c);187 setInt(i, a);185 paInt mn = 0, mx = 0, def = 0; 186 getMinMax(i, mn, mx, def); 187 setInt(i, mn); 188 188 } 189 189 break; … … 199 199 case 'f': 200 200 { 201 double a = 0, b = 0, c= 0;202 getMinMax(i, a, b, c);203 setDouble(i, b);201 double mn = 0, mx = 0, def = 0; 202 getMinMax(i, mn, mx, def); 203 setDouble(i, mx); 204 204 } 205 205 break; 206 206 case 'd': 207 207 { 208 paInt a = 0, b = 0, c= 0;209 getMinMax(i, a, b, c);210 setInt(i, b);208 paInt mn = 0, mx = 0, def = 0; 209 getMinMax(i, mn, mx, def); 210 setInt(i, mx); 211 211 } 212 212 break; … … 497 497 case 'o': ret.setObject(getObject(i)); break; 498 498 case 'x': ret = getExtValue(i); break; 499 default: FMprintf("ParamInterface", "get", FMLV_ERROR, "'%s.%s' is not afield", getName(), id(i));499 default: FMprintf("ParamInterface", "get", FMLV_ERROR, "'%s.%s' is not mn field", getName(), id(i)); 500 500 } 501 501 } … … 513 513 if (!stringIsNumeric(str)) 514 514 { 515 paInt a, b, c;516 if (getMinMax(i, a, b, c) >= 3)517 return setInt(i, c);515 paInt mn, mx, def; 516 if (getMinMax(i, mn, mx, def) >= 3) 517 return setInt(i, def); 518 518 else 519 519 return setInt(i, (paInt)0); … … 527 527 if (!stringIsNumeric(str)) 528 528 { 529 double a, b, c;530 if (getMinMax(i, a, b, c) >= 3)531 return setDouble(i, c);529 double mn, mx, def; 530 if (getMinMax(i, mn, mx, def) >= 3) 531 return setDouble(i, def); 532 532 else 533 533 return setDouble(i, (double)0); … … 605 605 if ((*(t = type(i))) == 'd') 606 606 { 607 paInt a, b, c;607 paInt mn, mx, def; 608 608 int value = getInt(i); 609 if (getMinMax(i, a, b, c) >= 2)610 { 611 if (value > b)609 if (getMinMax(i, mn, mx, def) >= 2) 610 { 611 if (value > mx) 612 612 return get(i); 613 value = a;613 value = mn; 614 614 } 615 615 if (value < 0) return get(i); … … 778 778 if (pe>flags&PARAM_READONLY) return PSET_RONLY; 779 779 paInt xcopy = x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below 780 paInt a = 0, b= 0;780 paInt mn = 0, mx = 0; 781 781 int result = 0; 782 782 const char* t = pe>type + 1; 783 783 while (*t) if (*t == ' ') break; else t++; 784 if (sscanf(t, PA_INT_SCANF " " PA_INT_SCANF, & a, &b) == 2)785 if ( a <= b) // if max<min then the min/max constraint check is not supported786 { 787 if (x < a) { x = a; result = PSET_HITMIN; }788 else if (x > b) { x = b; result = PSET_HITMAX; }784 if (sscanf(t, PA_INT_SCANF " " PA_INT_SCANF, &mn, &mx) == 2) 785 if (mn <= mx) // if max<min then the min/max constraint check is not supported 786 { 787 if (x < mn) { x = mn; result = PSET_HITMIN; } 788 else if (x > mx) { x = mx; result = PSET_HITMAX; } 789 789 } 790 790 … … 814 814 if (pe>flags&PARAM_READONLY) return PSET_RONLY; 815 815 double xcopy = x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below 816 double a = 0, b= 0;816 double mn = 0, mx = 0; 817 817 int result = 0; 818 818 const char* t = pe>type + 1; 819 819 while (*t) if (*t == ' ') break; else t++; 820 if (sscanf(t, "%lg %lg", & a, &b) == 2)821 if ( a <= b) // if max<min then the min/max constraint check is not supported822 { 823 if (x < a) { x = a; result = PSET_HITMIN; }824 else if (x > b) { x = b; result = PSET_HITMAX; }820 if (sscanf(t, "%lg %lg", &mn, &mx) == 2) 821 if (mn <= mx) // if max<min then the min/max constraint check is not supported 822 { 823 if (x < mn) { x = mn; result = PSET_HITMIN; } 824 else if (x > mx) { x = mx; result = PSET_HITMAX; } 825 825 } 826 826 … … 854 854 const char* t = pe>type + 1; 855 855 while (*t) if (*t == ' ') break; else t++; 856 int a = 0, b= 0;856 int mn = 0, mx = 0; 857 857 int result = 0; 858 if (sscanf(t, "%d %d", & a, &b) == 2) //using getMinMax would also get default value, which is not needed here859 { 860 if ((x.len() > b) && (b> 0))861 { 862 vs = x.substr(0, b);858 if (sscanf(t, "%d %d", &mn, &mx) == 2) //using getMinMax would also get default value, which is not needed here 859 { 860 if ((x.len() > mx) && (mx > 0)) 861 { 862 vs = x.substr(0, mx); 863 863 xx = &vs; 864 864 result = PSET_HITMAX;
Note: See TracChangeset
for help on using the changeset viewer.