void Show_Warning(const char* first_part, const char* second_part, const char* third_part) { char statement[MAX_STATEMENT_LENGTH]; strcpy(statement, first_part); strcat(statement, second_part); strcat(statement, third_part); Show_Warning(statement); }
Message_Stream & Show_Warning (string text) { return (Show_Warning (text.c_str ())); }
void Change_FP(char* line, double change_val) { //Determine the new value of the variable--- double orig_val = Get_FP_Number(line); double new_val = orig_val + change_val; //Characterize the floating-point string--- int val_size = 0; int after_dec = 0; int before_dec = 0; int number_location; bool num_found = FALSEV; bool period_found = FALSEV; bool is_num_dec; for (int a = 0; a < int(strlen(line)); ++a) { is_num_dec = (line[a] == '.') && (Is_Number(line[a + 1])); if (is_num_dec) { period_found = TRUEV; } if ( (Is_Number(line[a]) || period_found) && !num_found) //Start of the number string has been found. { number_location = a; num_found = TRUEV; } if (Is_Number(line[a]) && num_found) //Determine how many digits are before and after the decimal place. { ++val_size; if (period_found) { ++after_dec; } else { ++before_dec; } } if (!(Is_Number(line[a]) || is_num_dec) && num_found) //End of the number string has been encountered. { break; } } //Change the floating-point string to the new value--- int dif_from_ones_place = 0; int char_index; double temp_shift; double abs_val = abs(new_val); for (int b = 0; b < val_size; ++b) { char_index = b; dif_from_ones_place = (before_dec - 1) - b; temp_shift = pow(10.0, double(dif_from_ones_place)); if (b >= before_dec) //Skip the decimal point. { ++char_index; } line[number_location + char_index] = '0' + char( int(abs_val/temp_shift + FP_ERROR_FIX) % 10 ); } //Check for the need to remove a minus sign--- if ( (number_location != 0) && (line[number_location - 1] == '-') && (new_val > 0.0) ) //If number has been changed from negative value to positive value, //the minus sign must be removed. Reverse case is not allowed here. { line[number_location - 1] = '0'; //Replace with a zero. Keeps the string length the same. } //Check for a failed change to the FP value--- double num_temp = Get_FP_Number(line); if (!Check_FP_Equality(num_temp, new_val)) { Show_Warning("AUTOMATION OF FILE TEXT REQUIRES MORE SPACE FOR FP VALUES!"); Change_FP(line, -1.0*num_temp); //Zero the FP value. } }
void Change_Integer(char* line, int change_val) { //Determine the new value of the integer--- int orig_val = Get_Number(line); int new_val = orig_val + change_val; //Characterize the integer string--- int val_size = 0; int number_location; bool num_found = FALSEV; for (int a = 0; a < int(strlen(line)); ++a) { if (Is_Number(line[a]) && !num_found) //Found starting index for the integer. { number_location = a; num_found = TRUEV; } if (Is_Number(line[a]) && num_found) //Get string length of the integer. { ++val_size; } if (!Is_Number(line[a]) && num_found) { break; } } //Change the integer string to the new value--- int division_factor = 1; int abs_val = abs(new_val); for (int b = 0; b < val_size; ++b) { line[number_location + val_size - 1 - b] = '0' + char(abs_val/division_factor % 10); division_factor *= 10; } //Check for a minus sign that needs to be removed--- if ( (number_location != 0) && (line[number_location - 1] == '-') && (new_val > 0) ) //If number has been changed from negative value to positive value, //the minus sign must be removed. Reverse case is not allowed here. { line[number_location - 1] = '0'; //Replace with a zero. Keeps string length of the number the same. } //Check for a new value that is larger in string space than the original value--- int num_temp = Get_Number(line); if (new_val != num_temp) { Show_Warning("AUTOMATION OF FILE TEXT REQUIRES MORE SPACE IN INTEGER NUMBER STRINGS!"); Change_Integer(line, -1*num_temp); //Zero the integer string in the case of overflow. } }