SC: get(SystemInfo, setting); getreg(path, name);

Features wanted...
Post Reply
Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

SC: get(SystemInfo, setting); getreg(path, name);

Post by Stefan »

For international and general selective scripting, can we get a command like

get("SystemInfo", setting);


setting could be for example one of: ( //with example result)

OS // W2k, XP, Win7
Bit// 32, 64
locale// 407, 409
LocaleName// de-DE, en-US
localeID// 1031,1033
sThousand// ., ,
sDecimal// ,, .
sTime// :
sDate// ., /
uptime
active CP
HomeDrive
HomePath
SystemDrive

and like that (e.g. more form SET command)



Usage Examples:

$CommentLang = get("SystemInfo", "LocaleName");
if($CommentLang == DE) msg "Willkommen!"; ELSE msg "Hi!";



- - -



That above is for convenient, but I would also like to suggest a more general "getreg( path [,name] );"

$intern = getreg("HKEY_CURRENT_USER\Control Panel\International");
$sTime = getreg("HKEY_CURRENT_USER\Control Panel\International", "sTime");



- - -

Status Quo:

Currently we have to do a workaround with command line tools:

Code: Select all

 run "cmd /c reg query ""HKCU\Control Panel\International"" /v sDecimal > %TEMP%\xy.txt",,1;
     run "notepad ""%TEMP%\xy.txt""";
 
This will result in something like:

Code: Select all

 -----------------
 
HKEY_CURRENT_USER\Control Panel\International
    sDecimal    REG_SZ    ,

-----------------

Here is a example POC code to make that by a script:

Code: Select all


$ValueName = "sDecimal"; //name of the value to extract

 //run command, [directory], [wait=0], [show=1]
   run "cmd /c reg query ""HKCU\Control Panel\International"" /v $ValueName > %TEMP%\xyregvalue.txt",,1;

 //readfile(filename, [mode], [numbytes], [codepage], [start=1])
  $RegValue = readfile( "%TEMP%\xyregvalue.txt" );
    //RESULT:   
    //RESULT:HKEY_CURRENT_USER\Control Panel\International
    //RESULT:    sDecimal    REG_SZ    ,
    //RESULT:

 //regexreplace(string, pattern, replacement, [matchcase])
  $RegValue = regexreplace($RegValue, "<crlf>", ""); //merge lines
    //RESULT:   HKEY_CURRENT_USER\Control Panel\International    sDecimal    REG_SZ    ,
  
  $RegValue = regexreplace($RegValue, ".+$ValueName\s+\w+\s+(.+)", "$1"); //extract value
    //RESULT:,
    
  // now you can use $RegValue in your code....
  text "Value of $ValueName is $RegValue";
   
This will result in something like:

Code: Select all

-----------------
Value of sDecimal is ,
-----------------



- - -

For reference, here are my local settings, from english win7 with german language and region settings:
( Please post yours too for different countries )

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Control Panel\International]
"Locale"="00000407"
"LocaleName"="de-DE"
"s1159"=""
"s2359"=""
"sCountry"="Deutschland"
"sCurrency"="€"
"sDate"="."
"sDecimal"=","
"sGrouping"="3;0"
"sLanguage"="DEU"
"sList"=";"
"sLongDate"="dddd, d. MMMM yyyy"
"sMonDecimalSep"=","
"sMonGrouping"="3;0"
"sMonThousandSep"="."
"sNativeDigits"="0123456789"
"sNegativeSign"="-"
"sPositiveSign"=""
"sShortDate"="dd.MM.yyyy"
"sThousand"="."
"sTime"=":"
"sTimeFormat"="HH:mm:ss"
"sShortTime"="HH:mm"
"sYearMonth"="MMMM yyyy"
"iCalendarType"="1"
"iCountry"="49"
"iCurrDigits"="2"
"iCurrency"="3"
"iDate"="1"
"iDigits"="2"
"NumShape"="1"
"iFirstDayOfWeek"="0"
"iFirstWeekOfYear"="2"
"iLZero"="1"
"iMeasure"="0"
"iNegCurr"="8"
"iNegNumber"="1"
"iPaperSize"="9"
"iTime"="1"
"iTimePrefix"="0"
"iTLZero"="1"
Date/Time for German locale at 13 March 2014, 3pm:

C:\Users\stefan>echo %DATE%
13.03.2014

C:\Users\stefan>echo %TIME%
15:13:22,27


.

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: SC: get(SystemInfo, setting); getreg(path, name);

Post by SkyFrontier »

As asked (and as a THANK YOU), here it is:

Code: Select all


HKEY_CURRENT_USER\Control Panel\International
    Locale    REG_SZ    00000416
    LocaleName    REG_SZ    pt-BR
    s1159    REG_SZ    
    s2359    REG_SZ    
    sCountry    REG_SZ    Brasil
    sCurrency    REG_SZ    R$
    sDate    REG_SZ    /
    sDecimal    REG_SZ    ,
    sGrouping    REG_SZ    3;0
    sLanguage    REG_SZ    PTB
    sList    REG_SZ    ;
    sLongDate    REG_SZ    dddd, d' de 'MMMM' de 'yyyy
    sMonDecimalSep    REG_SZ    ,
    sMonGrouping    REG_SZ    3;0
    sMonThousandSep    REG_SZ    .
    sNativeDigits    REG_SZ    0123456789
    sNegativeSign    REG_SZ    -
    sPositiveSign    REG_SZ    
    sShortDate    REG_SZ    dd/MM/yyyy
    sThousand    REG_SZ    .
    sTime    REG_SZ    :
    sTimeFormat    REG_SZ    HH:mm:ss
    sShortTime    REG_SZ    HH:mm
    sYearMonth    REG_SZ    MMMM' de 'yyyy
    iCalendarType    REG_SZ    1
    iCountry    REG_SZ    55
    iCurrDigits    REG_SZ    2
    iCurrency    REG_SZ    2
    iDate    REG_SZ    1
    iDigits    REG_SZ    2
    NumShape    REG_SZ    1
    iFirstDayOfWeek    REG_SZ    6
    iFirstWeekOfYear    REG_SZ    0
    iLZero    REG_SZ    1
    iMeasure    REG_SZ    0
    iNegCurr    REG_SZ    9
    iNegNumber    REG_SZ    1
    iPaperSize    REG_SZ    9
    iTime    REG_SZ    1
    iTimePrefix    REG_SZ    0
    iTLZero    REG_SZ    1

HKEY_CURRENT_USER\Control Panel\International\Geo
I know the difference real data makes when it comes to scripting - that's why I'm always concerned on compatibility, after getting several hours of work ruined by a simple dot.
By the way, current get("locale") should support something like

get("localeKey", 14); // returns 'sDecimal' or 'LOCALE_SDECIMAL'

so each key\value can be paired in a per-index base, allowing a minimum validation as mirco$ft tends to change corresponding indexes on each OS change, afaicr (can't verify as I'm away from my park, now).
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Post Reply