############################################################################# 
##                                                                         ## 
## Function:                                                               ##
##    RawNumX ( inout OrigText, out ModText )                              ##
##                                                                         ##
## Description:                                                            ##
##    This function will purge the following Three characters from the     ##
##    OrigText string.  Dollar Sign, Comma, Space   $ , " "                ##
##    It is meant to remove formating from numbers                         ##
##    that may be used in comparisons, etc.                                ##
##                                                                         ##
## Parameters:                                                             ##
##    OrigText   -   Original text passed into the Function.               ##
##    ModText    -   Global variable modified by Function.                 ##
##                                                                         ##
## Returns:                                                                ##
##    E_OK (0) or E_GENERAL_ERROR (-10001)                                 ##
##                                                                         ##
## Syntax:                                                                 ##
##    RawNumX ( OrigText, ModText );                                       ##
##                                                                         ##
## Examples:                                                               ##
##    rc1 = RawNumX ( OrigText, ModText );                                 ##
##    rc1 = RawNumX ( "$ 12345.67", ModText );                             ##
##                                                                         ## 
#############################################################################
function RawNumX ( inout OrigText, out ModText ) 
{  
	auto BefText;
	auto AftText;
	auto Loc;
	auto NumArray[];
	auto Elements;
	
	ModText = OrigText;
	BefText = "";
	AftText = "";
	Elements = 0;
	
	# Strip out the " " characters
	while ( index(ModText, " ") > 0 )
	{
		Loc = index(ModText, " ");
		BefText = substr(ModText, 1, Loc - 1);
		AftText = substr(ModText, Loc + 1);
		ModText = BefText & AftText;
	}
	
	# Strip out the "," characters 
	while ( index(ModText,",") > 0 )
	{
		Loc = index(ModText, ",");
		BefText = substr(ModText, 1, Loc - 1);
		AftText = substr(ModText, Loc + 1);
		ModText = BefText & AftText;
	}
	# Strip out the "$" characters
	while ( index(ModText, "$") > 0 )
	{
		Loc = index(ModText, "$");
		BefText = substr(ModText, 1, Loc - 1);
		AftText = substr(ModText, Loc + 1);
		ModText = BefText & AftText;
	}
	# Strip out trailing decimal point if nothing to the right.
	Elements = split( ModText, NumArray, "." );
	if ( Elements == 2 && NumArray[1] != "")
	{
		if ( NumArray[2] == "" )
			{ ModText = NumArray[1]; }
		else
			{ ModText = NumArray[1] & "." & NumArray[2]; }
	}
	return ( E_OK ); # Left this out before ...
}


# Start of Test Script ...

LogFileName = "c:\\a.txt";
DirX = "C:\\ScrnCap\\";
FileSpecX = "*.*";


dos_system ( "dir " & DirX & FileSpecX & " /A-D > " & LogFileName );

rc1 = file_open ( LogFileName, FO_MODE_READ );
if ( rc1 != 0 )
{
	pause ( "file_open FAILED!" );
}

while ( file_getline(LogFileName, OutLine) == E_OK )
{
	if ( index(OutLine, "file(s)") > 0 )
	{
		# Exit the while loop ...
		break;	
	}
}

file_close ( LogFileName );

# Split the string into an Array ...
rc1 = split(OutLine, ArrayX, " ");
# 1 = Number of files ...
# 2 = The word "file(s)" ...
# 3 = Size of file(s) ...
# 4 = Unit of size "bytes" etc. ...

rc1 = RawNumX(ArrayX[3], NoCommasTempNumX);

printf ( "Size of file(s) in directory is : %s %s\r\n", ArrayX[3], ArrayX[4] );

printf ( "Size of file(s) in directory is : %s %s\r\n", NoCommasTempNumX, ArrayX[4] );







