BCS c++ Numeric Editing Symbol Insertion

There are those occasions when numeric editing or symbol insertion is required for make integer values more readable for humans. When those time arise the following c++ method can be used.
[codesyntax lang=”cpp”]

void MyFrame::repRecs(int intVal) { // @suppress("Type cannot be resolved")
	string buf; // @suppress("Type cannot be resolved")
	buf = std::to_string(IntVal); // @suppress("Function cannot be resolved")
	int insertPosition = buf.length() - 3; // @suppress("Method cannot be resolved")
	while (insertPosition > 0) {
		buf.insert(insertPosition, ","); // @suppress("Method cannot be resolved")
		insertPosition -= 3;
	buf = buf + " Records";
	SetStatusText(buf); // @suppress("Function cannot be resolved")

Pass the integer value to be formatted to method and comma insertion is completed for you.
Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.

Leave a Reply

Your email address will not be published. Required fields are marked *