Changeset 42
- Timestamp:
- Mar 30, 2018, 8:38:35 PM (7 years ago)
- Location:
- rxutilex/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
rxutilex/trunk/rxutilex.c
r41 r42 1067 1067 * must not contain any separators already, and any decimal point which it * 1068 1068 * contains must be a period (rather than any localized decimal symbol). * 1069 * The maximum value is that of a signed 64-bit integer, or a long double. * 1069 1070 * * 1070 1071 * REXX ARGUMENTS: * … … 1081 1082 PSZ pszSep = NULL; // Thousands separator string 1082 1083 PSZ pszDec = NULL; // Decimal point string 1084 PSZ pszNeg = NULL; // Negative sign string 1083 1085 #ifdef LEGACY_C_LOCALE 1084 1086 float fVal = 0; // Input value as floating point 1085 1087 int iVal; // Input value as integer 1086 1088 #else 1087 ULONGLONGllVal = 0;1089 LONGLONG llVal = 0; 1088 1090 long double ldVal = 0, 1089 1091 ldFrac = 0; 1090 PSZ p; 1091 CHAR achFrac[ 16 ]; 1092 int rc = 0; 1092 PSZ p, 1093 a; 1094 BOOL bNeg = FALSE; 1095 CHAR achFrac[ 16 ]; 1096 int rc = 0; 1093 1097 #endif 1094 1098 … … 1178 1182 } 1179 1183 1184 // Return the formatted number 1185 SaveResultString( prsResult, achNumber, strlen(achNumber) ); 1186 1180 1187 #else 1181 1188 … … 1184 1191 // GetLocaleString has already set the error indicator 1185 1192 SaveResultString( prsResult, NULL, 0 ); 1186 return ( 0 );1193 goto finish; 1187 1194 } 1188 1195 rc = GetLocaleString( &pszDec, LOCI_sDecimal ); … … 1190 1197 // GetLocaleString has already set the error indicator 1191 1198 SaveResultString( prsResult, NULL, 0 ); 1192 return ( 0 ); 1193 } 1199 goto finish; 1200 } 1201 rc = GetLocaleString( &pszNeg, LOCI_sNegativeSign ); 1202 if ( rc ) { 1203 // GetLocaleString has already set the error indicator 1204 SaveResultString( prsResult, NULL, 0 ); 1205 goto finish; 1206 } 1207 1208 // Check for negative value 1209 //if ( argv[0].strptr == '-') bNeg = TRUE; 1194 1210 1195 1211 // Check for a decimal place and treat as float or integer accordingly … … 1207 1223 else 1208 1224 sprintf( achFrac, "%.2Lf", ldFrac ); 1225 1209 1226 // Format the integer part 1210 GroupNumber( achNumber, llVal, pszSep ); 1227 a = achNumber; 1228 if ( llVal < 0 ) { 1229 sprintf( a, pszNeg ); 1230 a += strlen( pszNeg ); 1231 } 1232 GroupNumber( a, llabs( llVal ), pszSep ); 1211 1233 // Append the fractional part 1212 1234 if (( p = strchr( achFrac, '.')) != NULL ) { … … 1217 1239 else { 1218 1240 if (( sscanf( argv[0].strptr, "%lld", &llVal )) != 1 ) return ( 40 ); 1219 GroupNumber( achNumber, llVal, pszSep ); 1220 } 1221 1222 free( pszSep ); 1241 a = achNumber; 1242 if ( llVal < 0 ) { 1243 sprintf( a, pszNeg ); 1244 a += strlen( pszNeg ); 1245 } 1246 GroupNumber( a, llabs( llVal ), pszSep ); 1247 } 1248 1249 // Return the formatted number 1250 SaveResultString( prsResult, achNumber, strlen(achNumber) ); 1251 1252 finish: 1253 if ( pszSep ) free( pszSep ); 1254 if ( pszDec ) free( pszDec ); 1255 if ( pszNeg ) free( pszNeg ); 1256 1223 1257 #endif 1224 1225 // Return the formatted number1226 SaveResultString( prsResult, achNumber, strlen(achNumber) ); // 2016-02-20 SHL1227 1258 1228 1259 return ( 0 ); -
rxutilex/trunk/rxutilex.def
r41 r42 1 1 LIBRARY RXUTILEX INITINSTANCE TERMINSTANCE 2 2 DATA MULTIPLE NONSHARED 3 DESCRIPTION '@#Alex Taylor:0.1.6#@##1## 30 Mar 2018 1 2:07:43 REINFORCE::::::@@Extended REXX Utility Functions'3 DESCRIPTION '@#Alex Taylor:0.1.6#@##1## 30 Mar 2018 14:26:03 REINFORCE::::::@@Extended REXX Utility Functions' 4 4 5 5 EXPORTS Sys2LoadFuncs -
rxutilex/trunk/rxutilex.txt
r39 r42 169 169 Sys2FormatNumber 170 170 171 Formats a number to use thousands-grouping characters. The system values 172 for the current locale are used for the thousands-grouping character and 173 the decimal place, if any. Note that the IBM C runtime's locale 174 definitions are used; these may not correspond precisely to the system 175 locales as defined in the OS/2 Locale object. 171 Formats a number with locale-specific thousands-grouping characters, 172 decimal point, and/or negative sign, as applicable. The current locale 173 conventions will be used (as defined by the environment values %LC_ALL%, 174 %LC_NUMERIC%, or %LANG%, in that order of precedence). 176 175 177 176 The input number may be a positive or negative integer or floating point … … 180 179 point which it contains must be a period (rather than any localized 181 180 decimal symbol). 181 182 The range limits for the specified number are those of a 64-bit signed 183 integer (ñ9,223,372,036,854,775,807), or an 80-bit floating point value. 182 184 183 185 REXX ARGUMENTS: … … 496 498 497 499 ------------------------------------------------------------------------- 500 Sys2QuerySysValue 501 502 Query the given system value. 503 504 REXX ARGUMENTS: 505 1. The system value identifier (REQUIRED) 506 Valid identifiers are (see the Presentation Manager Programming 507 Reference description of WinQuerySysValue for descriptions): 508 ALARM 509 ALTMNEMONIC 510 ANIMATIONSPEED 511 ANIMATION 512 BEGINDRAG 513 BEGINDRAGKB 514 BEGINSELECT 515 BEGINSELECTKB 516 CHORDTIME 517 CICONTEXTLINES 518 CMOUSEBUTTONS 519 CONTEXTHELPKB 520 CONTEXTHELP 521 CONTEXTMENU 522 CONTEXTMENUKB 523 CPOINTERBUTTONS 524 CTIMERS 525 CURSORLEVEL 526 CURSORRATE 527 CXALIGN 528 CXBORDER 529 CXBYTEALIGN 530 CXCHORD 531 CXDBLCLK 532 CXDLGFRAME 533 CXFULLSCREEN 534 CXHSCROLLARROW 535 CXHSLIDER 536 CXICONTEXTWIDTH 537 CXICON 538 CXMINMAXBUTTON 539 CXMOTIONSTART 540 CXPOINTER 541 CXSCREEN 542 CXSIZEBORDER 543 CXVSCROLL 544 CYALIGN 545 CYBORDER 546 CYBYTEALIGN 547 CYCHORD 548 CYDBLCLK 549 CYDLGFRAME 550 CYFULLSCREEN 551 CYHSCROLL 552 CYICON 553 CYMENU 554 CYMINMAXBUTTON 555 CYMOTIONSTART 556 CYPOINTER 557 CYSCREEN 558 CYSIZEBORDER 559 CYTITLEBAR 560 CYVSCROLLARROW 561 CYVSLIDER 562 DBLCLKTIME 563 DEBUG 564 ENDDRAG 565 ENDDRAGKB 566 ENDSELECTKB 567 ENDSELECT 568 ERRORDURATION 569 ERRORFREQ 570 FIRSTSCROLLRATE 571 INSERTMODE 572 KBDALTERED 573 LOCKSTARTINPUT 574 MENUROLLDOWNDELAY 575 MENUROLLUPDELAY 576 MONOICONS 577 MOUSEPRESENT 578 NOTEDURATION 579 NOTEFREQ 580 NUMBEREDLISTS 581 OPEN 582 OPENKB 583 POINTERLEVEL 584 PRINTSCREEN 585 SCROLLRATE 586 SELECTKB 587 SETLIGHTS 588 SINGLESELECT 589 SWAPBUTTON 590 TASKLISTMOUSEACCESS 591 TEXTEDIT 592 TEXTEDITKB 593 TRACKRECTLEVEL 594 WARNINGDURATION 595 WARNINGFREQ 596 597 REXX RETURN VALUE: 598 String containing the requested system value, or "" in case of error. 599 600 601 ------------------------------------------------------------------------- 498 602 Sys2Read 499 603 -
rxutilex/trunk/testlib.cmd
r41 r42 53 53 54 54 say Sys2FormatNumber('9375739912303') 55 say Sys2FormatNumber(' 64583.449286', 5)55 say Sys2FormatNumber('-64583.449286', 5) 56 56 57 57
Note:
See TracChangeset
for help on using the changeset viewer.