| View previous topic :: View next topic |
| Author |
Message |
attreus Valued Newbie

Joined: 30 Jul 2002 Posts: 46 Location: Berlin/Germany
|
Posted: Tue Feb 28, 2006 11:37 pm Post subject: how can i find out the current decimalsep? |
|
|
hi,
currently i'm making a custom-function for time calculations.
because of the different seperators for time, date and floatingpoint i want to change these within the function and set it back to the previous value when the function exits.
so at the begin of the function the original values are stored in variables like | Code: | | %D = @datetime(/), %T = @datetime(:) | but how can i find out the decimal separator that is used in the script that calls the function?
thanks
attreus |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Wed Mar 01, 2006 4:37 am Post subject: |
|
|
Here I can find it in the registry key 'sDecimal' under:
HKEY_CURRENT_USER\Control Panel\International _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Wed Mar 01, 2006 6:44 am Post subject: |
|
|
Or do a simple calculation and extract the separator:
| Code: | | @substr(@fdiv(1,2),2,) |
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
attreus Valued Newbie

Joined: 30 Jul 2002 Posts: 46 Location: Berlin/Germany
|
Posted: Wed Mar 01, 2006 12:25 pm Post subject: |
|
|
thank you both.
dr.dreads solusion is simple and perfect 'cause i needed the current setting within the script and cannot use the regional setting.
if you are interested in my function, here it is:
| Code: |
#
# Function @timecalc() by attreus
# -------------------------------------
#
# %1 = Time-Value in VDS-format e.g. "@datetime()"
# %2 = Opreator "plus" / "minus"
# %3 = Time-Value in normal format e.g. "10"
# %4 = Unit e.g. min or h
# valid are: "s" or "sec", "m" or "min", "h" or "hour", "d" or "day"
#
#
# Example:
# --------
#
# #include TimeCalc.dsu
#
# %%start = @datetime()
# %%timer = 15
#
# %T = 0
#
# repeat
# Dialog set,Status,Time is running ... %T
# wait 1
# %T = @succ(%T)
# until @greater(@datetime(),@timecalc(%%start,plus,%%timer,s))
#
# info Time is over.
#
#
#DEFINE Function,TimeCalc
:TimeCalc
%5 = @datetime(
%6 = @datetime(/)
%7 = @substr(@fdiv(1,2),2,)
option decimalsep,.
option timesep,:
option datesep,/
if @not(%1) @not(%2) @not(%3) @not(%4)
warn "Error in function [ @TimeCalc() ]"@tab()@cr()One or more parameters missing.@cr()@tab()
stop
end
# one day
%D = 1
# one hour
%H = @fdiv(%D,24)
# one minute
%M = @fdiv(%H,60)
# one second
%S = @fdiv(%M,60)
if @equal(@substr(%4,1),s)
%Z = @fmul(%3,%S)
elsif @equal(@substr(%4,1),m)
%Z = @fmul(%3,%M)
elsif @equal(@substr(%4,1),h)
%Z = @fmul(%3,%H)
elsif @equal(@substr(%4,1),d)
%Z = @fmul(%3,%D)
else
warn "Error in function [ @TimeCalc() ]"@tab()@cr()Wrong fourth parameter.@cr()@tab()
stop
end
if @equal(%2,plus)
%R = @fadd(%1,%Z)
elsif @equal(%2,minus)
%R = @fsub(%1,%Z)
else
warn "Error in function [ @TimeCalc() ]"@tab()@cr()Wrong second parameter.@cr()@tab()
stop
end
option timesep,%5
option datesep,%6
option decimalsep,%7
exit %R
|
|
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Wed Mar 01, 2006 3:39 pm Post subject: |
|
|
| Dr. Dread wrote: | Or do a simple calculation and extract the separator:
| Code: | | @substr(@fdiv(1,2),2,) |
|
Hey.. no thinking outside the box  _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|