Problem: I tried to create a formula in Crystal reports to convert dates from numerical to text in French (example: 01/01/2002 -> deux mil deux le un janvier) but when I print it in sageX3 it converts to ENG.
This is my code:
Local StringVar year_ := ToText(Votre_Date, "yyyy");
Local StringVar day_ := ToText(Votre_Date, "dd");
Local StringVar month_:= MonthName(month(Votre_Date));
ProperCase( ToWords(ToNumber(year_),0) ) + " Le " + ProperCase( ToWords(ToNumber(day_), 0) ) + " " + month_
It takes default language from "The Environment Locale settings".
Try changing language for server where SAGE is installed
For windows : Start->Control Panel-> Region & language
Related
My current script copies text like this with a shortcut:
:WiltedFlower: aetheryxflower ─ 4
:Alcohol: alcohol ─ 3,709
:Ant: ant ─ 11,924
:Apple: apple ─ 15
:ArmpitHair: armpithair ─ 2
and pastes it modified into a single line
Pls trade 4 aetheryxflower 3 alcohol 11 ant 15 apple 2 armpithair <#id>
As you can see there are already two little problems, the first one is that it copies only the number/s before a comma if one existed instead of ignoring it. The second is that I always need to also copy before hitting the hotkey and start re/start the script, I've thought of modifying the script so that it uses the already selected text instead of the copied one so that I can bind it with a single hotkey.
That is my current script, it would be cool if anyone can also tell me what they used and why exactly, so that I also get better with ahk
!q::
list =
While pos := RegExMatch(Clipboard, "(\w*) ─ (\d*)", m, pos ? pos + StrLen(m) : 1)
list .= m2 " " m1 " "
Clipboard := "", Clipboard := "Pls trade " list " <#951737931159187457>"
ClipWait, 0
If ErrorLevel
MsgBox, 48, Error, An error occurred while waiting for the clipboard.
return
If the pattern of your copied text dont change, you can use something like this:
#Persistent
OnClipboardChange:
list =
a := StrSplit(StrReplace(Clipboard, "`r"), "`n")
Loop,% a.Count() {
b := StrSplit( a[A_Index], ": " )
c := StrSplit( b[2], " - " )
list .= Trim( c[2] ) " " Trim( c[1] ) " "
}
Clipboard := "Pls trade " list " <#951737931159187457>"]
ToolTip % Clipboard ; just for debug
return
With your example text, the output will be:
Pls trade aetheryxflower ─ 4 alcohol ─ 3,709 ant ─ 11,924 apple ─ 15 armpithair ─ 2 <#951737931159187457>
And this will run EVERY TIME your clipboard changes, to avoid this, you can add at the top of the script #IfWinActive, WinTitle or #IfWinExist, WinTitle depending of your need.
The answer given would solve the problem, assuming that it never changes pattern as Diesson mentions.
I did the explanation of the code you provided with comments in the code below:
!q::
list = ; initalize a blank variable
; regexMatch(Haystack, regexNeedle, OutputVar, startPos)
; just for frame of reference in explanation of regexMatch
While ; loop while 'pos' <> 0
pos := RegExMatch(Clipboard ; Haystack is the string to be searched,
in this case the Clipboard
, "(\w*) ─ (\d*)" ; regex needle in this case "capture word characters
(a-z OR A-Z OR 0-9 OR _) any number of times, space dash space
then capture any number of digits (0-9)"
, m ; output var array base name, ie first capture will be in m1
second m2 and so on.
, pos ? pos + StrLen(m) : 1) ; starting position for search
"? :"used in this way is called a ternary operator, what is saying
is "if pos<>0 then length of string+pos is start position, otherwise
start at 1". Based on the docs, this shouldn't actually work well
since 'm' in this case should be left blank
list .= m2 " " m1 " " ; append the results to the 'list' variable
followed with a space
Clipboard := "" ; clear the clipboard.
Clipboard := "Pls trade " list " <#951737931159187457>"
ClipWait, 0 ; wait zero seconds for the clipboard to change
If ErrorLevel ; if waiting zero seconds for the clipboard to change
doesn't work, give error msg to user.
MsgBox, 48, Error, An error occurred while waiting for the clipboard.
return
Frankly this code is what I would call quick and dirty, and seems unlikely to work well all the time.
in C langage we have get_usec() which gives us the number of microseconds since the start of the current second.
-Speaking of the "current second" necessarily refers to time reference which is often EpochTime.
-In Ada.Calendar package, I see Seconds or Clocks functions by example with ability to split & get the seconds.
But how to get the number of microseconds since the start of the current second, please?
Thanks
Mark
Note that Ada.Calendar is for local time, and may jump backwards. If it's available (are there any post-83 compilers that don't provide it?), you'll be better off using Ada.Real_Time ARM D.8:
Now : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
Count : Ada.Real_Time.Seconds_Count;
Sub : Ada.Real_Time.Time_Span;
...
Ada.Real_Time.Split (T => Now, SC => Count, TS => Sub);
Now Count contains the number of whole seconds since the epoch and Sub contains the fraction of a second in addition to Count. Ada.Real_Time.To_Duration converts a Time_Span to Duration, allowing you to multiply it by 1E6 to get microseconds.
The packages Ada.Calendar and Ada.Calendar.Formatting provide the information you will need.
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
procedure Main is
Now : Time := Clock;
Seconds : Second_Duration := Sub_Second (Now);
begin
Put_Line
("Sub seconds since current second: " &
Second_Duration'Image (Seconds));
end Main;
The output of one execution of this program is:
Sub seconds since current second: 0.655316600
In this execution the value indicated 655316.6 microseconds.
It can also be done (of course) without Ada.Calendar.Formatting, like this for example:
with Ada.Calendar; use Ada.Calendar;
...
type Seconds_In_Day is range 0 .. 86_400;
-- Or use Integer if it is 32 bits.
Now : constant Day_Duration := Seconds (Clock);
Subsec : Duration := Now - Day_Duration (Seconds_In_Day (Now));
...
if Subsec < 0.0 then
-- Conversion of Now rounded up instead of down.
Subsec := Subsec + 1.0;
end if;
with the result in Subsec.
But using Ada.Calendar.Formatting.Sub_Second is shorter, and may be better (faster or more accurate) for all I know; I did not compare the two methods.
Many thaks for yours answers.
Using all yours examples, i made some trials, one is below :
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Real_Time; use Ada.Real_Time;
procedure Display_Current_Year is
--need to precise the origin package Ada.Real-Time else ambiguous
Now : Ada.Calendar.Time := Clock;
Now_Year : Year_Number;
Now_Month : Month_Number;
Now_Day : Day_Number;
Now_Seconds : Day_Duration;
Current_Real_Time : Ada.Real_Time.Time;
Time_Span : Ada.Real_Time.Time_Span;
Seconds_Count : Ada.Real_Time.Seconds_Count;
Hour : float;
begin
--- Ada.Calendar
Split (Now,
Now_Year,
Now_Month,
Now_Day,
Now_Seconds);
Put_Line("Calendar : Date du jour = ");
Put_Line ("Current year is: "
& Year_Number'Image (Now_Year));
Put_Line ("Current month is: "
& Month_Number'Image (Now_Month));
Put_Line ("Current day is: "
& Day_Number'Image (Now_Day));
Put_Line ("'Current' seconde is: "
& Day_Duration'Image (Now_Seconds));
New_Line;
--Ada.Real_Time;
Current_Real_Time := Ada.Real_Time.Clock;
Ada.Real_Time.Split (T => Current_Real_Time,
Sc => Seconds_Count,
Ts => Time_Span);
Put_Line ("Real_Time : Seconds_Count = " & Seconds_Count'Img);
Hour := (float(Seconds_count) / 3600.00);
Put_Line ("Hour since seconds origin : "
& (Hour'Img));
end Display_Current_Year;
with result :
$ ./display_current_year
Calendar : Date du jour =
Current year is: 2022
Current month is: 2
Current day is: 27
'Current' seconde is: 68625.325897000
Real_Time : Seconds_Count = 30953
Hour since seconds origin : 8.59806E+00
$
-Results for calendar are OK, but why 30953 seconds !!
Where does GNAT take the Epoch, if this is, in this case, please?
Thanks
Mark
You can do a dirty trick where you define a record My_raw_duration_Type : whole_part, fraction_part, both U32. Define Unchecked_Conversion To_Raw (Ada.Real_Time.Duration, My_Raw_Duration_Type). Then take the result of that and call it My_Raw_Duration. The milliseconds result you want is integer(float(My_Raw_Duration.Fraction_Part)/float(4*1032**2) * 1000.0);
VB6 (not VB.Net or VBScript)
I'm using the Printer object and recently found that some printers
are not being returned if the name has certain characters.
In VB6 it would be something like:
Dim pr As Printer
For Each pr In Printers
MsgBox pr.DeviceName
Next pr
I can easily rename any printer in Windows (any OS version) and
make it fail.
I suspect it's related to a UTF-8/Unicode issue, but I don't know how to resolve it.
For example, this printer name works fine: "MyPrinter 1", but this does not: "MyPrinter 1 ę".
How can I get the Printer when the name has a non-standard (for US English anyway) character?
EDIT:
I've found this code to access the printers, and it will correctly return all of them, even with special characters.
However, I don't know how to either:
1) Use the object for printing (as I would with a Printers object)
2) Or set a Printer object to the returned object from WMI
(FYI - The InkEdit control will correctly show the special characters without any Unicode wrangling - I'm using for display purposes only.)
Dim strComputer As String
Dim objWMIService As Object
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery ("Select * from Win32_Printer")
Dim myPrinter As Printer
Dim junk As String
For Each objprinter In colInstalledPrinters
List1.AddItem objprinter.Name & " --- " & objprinter.ShareName & " --- " & objprinter.ServerName
InkEdit1.Text = InkEdit1.Text & objprinter.Name & " --- " & objprinter.ShareName & " --- " & objprinter.ServerName & vbNewLine
If InStr(1, objprinter.Name, "HP") > -1 Then
myPrinter = objprinter.
End If
Next
ClassNN= TDBEditArpa16
I want AutoHotKey to get this value as a number and save it to an integer variable. How can I do this?
Note: I tried to do it through the following code, but the program can not identify it as a number.
ControlGetText, qtp1, TDBEditArpa16, Alteração de Produtos, Informações de Custo
StringTrimRight, qtp1, qtp1, 4
qtp1 = (%qtp1% + 2)
msgbox %qtp1%
Storing the result of an expression:
To assign a result to a variable, use the := operator.
ControlGetText, qtp1, TDBEditArpa16, Alteração de Produtos, Informações de Custo
StringTrimRight, qtp1, qtp1, 4
qtp1 := (qtp1 + 2)
msgbox %qtp1%
Variable names in an expression are not enclosed in percent signs
This is a bit complicated to explain but I sure will do my best!
I want to register the current time and date "Year,Week,day + Time", in my program IBM Personal Communications (Session A). I have to use a .MAC extension for the final file in order for the program to read it.
This is the code that I have at the moment:
[PCOMM SCRIPT HEADER]
LANGUAGE=VBSCRIPT
DESCRIPTION=
[PCOMM SCRIPT SOURCE]
OPTION EXPLICIT
autECLSession.SetConnectionByName(ThisSessionName)
REM This line calls the macro subroutine
subSub1_
sub subSub1_()
autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "151441652 " **<--This is where the date has to appear**
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[enter]"
autECLSession.autECLPS.WaitForAttrib 12,1,"00","3c",3,10000
autECLSession.autECLPS.Wait 3401
autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[pf12]"
end sub
autECLSession.autECLPS.SendKeys "151441652 " <--- The final values must appear here in the same order. The numbers have been entered manually by me. So what I essentially need the final program to do is to recognize the date and enter them manually.
This is what the numbers stand for:
15 = The year 2015
14 = The current week, the date right now is 02-04-2015 which is Week 14
4 = Day 4 of the week. thursday
1652 = Current time, I need the time to be a 24hour clock.
DatePart() can do all of this.
autECLSession.autECLPS.SendKeys _
Right(DatePart("yyyy", Now()), 2) & _
Right("0" & DatePart("ww", Now()), 2) & _
DatePart("w", Now()) & _
Right("0" & DatePart("h", Now()), 2) & _
Right("0" & DatePart("n", Now()), 2)
Take note of the optional FirstDayOfWeek and FirstWeekOfYear parameters, test your edge cases and set those parameters accordingly for the relevant calls.