/*
Copyright (c) 2019 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved.
*/
/*--------------------------------------------------------------------*\
Pro/TOOLKIT includes
\*--------------------------------------------------------------------*/
#include <ProToolkit.h>
#include <ProMenu.h>
#include <ProMessage.h>
#include <ProView.h>
#include <ProWindows.h>
#include <ProUtil.h>
/*--------------------------------------------------------------------*\
C System includes
\*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*\
Application includes
\*--------------------------------------------------------------------*/
#include <TestError.h>
#include "UtilMessage.h"
/*--------------------------------------------------------------------*\
Application macros
\*--------------------------------------------------------------------*/
#define MSGFIL "mess_msg.txt"
/*=============================================================*\
File: TestMessage.c
Function: ProTestMessage()
Purpose: Function used for testing ProMessage... functions
\*=============================================================*/
int ProTestMessage(ProAppData app_data, int option)
{
static int irange[2] = {0,10000};
static double drange[2] = {-1e20, 1e20};
int user_int;
double user_double;
ProCharLine string;
ProLine wstring, password, buffer;
ProFileName msgfil;
ProError status;
ProStringToWstring(msgfil, (char*)MSGFIL);
ProUtilMsgPrint( "gen", "TEST %0s", "Enter integer data:");
/* Obtain an integer value from the user */
status = ProMessageIntegerRead(irange, &user_int);
TEST_CALL_REPORT("ProMessageIntegerRead()", "ProTestMessage()",
status, status != PRO_TK_NO_ERROR);
status = ProMessageDisplay(msgfil, (char*)"TEST Integer = %0d", &user_int);
TEST_CALL_REPORT("ProMessageDisplay()", "ProTestMessage()",
status, status != PRO_TK_NO_ERROR);
/* Clear the prompt line */
ProMessageClear();
TEST_CALL_REPORT("ProMessageClear()", "ProTestMessage()", PRO_TK_NO_ERROR, 0);
/* Obtain an double value from the user */
ProUtilMsgPrint( "gen", "TEST %0s", "Enter double data:");
status = ProMessageDoubleRead(drange, &user_double);
TEST_CALL_REPORT("ProMessageDoubleRead()", "ProTestMessage()",
status, status != PRO_TK_NO_ERROR);
status = ProMessageDisplay(msgfil, (char*)"TEST Double = %0f", &user_double);
TEST_CALL_REPORT("ProMessageDisplay()", "ProTestMessage()",
status, status != PRO_TK_NO_ERROR);
/* Clear the prompt line */
ProMessageClear();
TEST_CALL_REPORT("ProMessageClear()", "ProTestMessage()", PRO_TK_NO_ERROR, 0);
/* Obtain an string from the user */
ProUtilMsgPrint( "gen", "TEST %0s", "Enter string data:");
status = ProMessageStringRead(PRO_LINE_SIZE-1, wstring);
TEST_CALL_REPORT("ProMessageStringRead()", "ProTestMessage()",
status, status != PRO_TK_NO_ERROR);
status = ProMessageDisplay(msgfil, (char*)"TEST String: %0w", wstring);
TEST_CALL_REPORT("ProMessageDisplay()", "ProTestMessage()",
status, status != PRO_TK_NO_ERROR);
/* Clear the prompt line */
ProMessageClear();
TEST_CALL_REPORT("ProMessageClear()", "ProTestMessage()", PRO_TK_NO_ERROR, 0);
/* Obtain an password from the user */
ProUtilMsgPrint( "gen", "TEST %0s", "Enter password:");
status = ProMessagePasswordRead(PRO_LINE_SIZE-1, password);
TEST_CALL_REPORT("ProMessagePasswordRead()", "ProTestMessage()",
status, status != PRO_TK_NO_ERROR);
status = ProMessageToBuffer(buffer, msgfil, (char*)"TEST Password: %0w", password);
TEST_CALL_REPORT("ProMessageToBuffer()", "ProTestMessage()",
status, status != PRO_TK_NO_ERROR);
ProWstringToString(string, buffer);
ProUtilMsgPrint( "gen", "TEST %0s", string);
/* Clear the prompt line */
ProMessageClear();
TEST_CALL_REPORT("ProMessageClear()", "ProTestMessage()", PRO_TK_NO_ERROR, 0);
status = ProMessageDisplay(msgfil,
(char*)"TEST Example format = %0w|%1(5)d|%2(7.2)f|%3(10.2)e|%4(10.4)g|",
wstring, &user_int, &user_double, &user_double, &user_double);
TEST_CALL_REPORT("ProMessageDisplay()", "ProTestMessage()",
status, status != PRO_TK_NO_ERROR);
return(1);
}