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
Related
I have a gui with nine checkbox in the following code i can select only one of each but what i wanted to add is if the NormeEm checkbox is selected i want to select another checkbox, which i tried to set up at the end of the code by using a switch and 2 cases so that only another one checkbox can be selected but it won't show and it doesn't give me an error code.
function kgexec4n(Init)
%KGEXEC4N boite de dialogue "norme" associée à kgexec4
%CAVIAR2, © ALSTOM + OL 2000/04-2003/03
error(nargchk(0,1,nargin));
persistent blkParamNorm
%%%% ouverture boite
if nargin==1
%"full block path name" du bloc ParamNorme
blkParamNorm=gcb;
if ~strcmp(get_param(blkParamNorm,'MaskType'),'ParamNor')
errordlg(kverranorm(14),'Caviar3','modal')
return
end
%création figure
hf=kgui4n;
%en cas de librairie verrouillée on interdit OK
%x=get_param(get_param(gcs,'Parent'),'Lock'); %modif2.4 10/03/2006
rep=findstr(gcs,'/');
if isempty(rep)
active_sys=gcs;
else
active_sys=gcs(1:rep-1)
end
x=get_param(active_sys,'Lock')
set( findobj(hf,'Tag','NormeOK'), 'Enable', onoff(~onoff(x)) )
else
hf=gcbf;
end
%%%% handles des contrôles et dévalidation de tout
hrb=[findobj(hf,'Tag','Norme0')
findobj(hf,'Tag','Norme1022')
findobj(hf,'Tag','NormeEm')
findobj(hf,'Tag','NormeG53')
findobj(hf,'Tag','NormeCh')
findobj(hf,'Tag','NormeUsrV')
findobj(hf,'Tag','NormeUsrI')
findobj(hf,'Tag','Norme50160')
findobj(hf,'Tag','Norme519')];
hrbVal=get(hrb,'Value');
set(hrb,'Value',0)
hno=[findobj(hf,'Tag','Param0')
findobj(hf,'Tag','Param1022')
findobj(hf,'Tag','ParamEm')
findobj(hf,'Tag','ParamG53')
findobj(hf,'Tag','ParamCh')
findobj(hf,'Tag','ParamUsrV')
findobj(hf,'Tag','ParamUsrI')
findobj(hf,'Tag','Param50160')
findobj(hf,'Tag','Param519-1')
findobj(hf,'Tag','Param519-2')
findobj(hf,'Tag','Param519-3')
findobj(hf,'Tag','Param519-4')];
set(hno,'Enable','off')
%%%% gestion dynamique de la boite
switch get(gcbo,'Tag'); %l'objet ayant provoqué l'appel
%dialogue dynamique
case {'Norme0','Norme1022'}
set(gcbo,'Value',1)
case 'NormeEm'
set(gcbo,'Value',1),enable(hno(3))
switch get(gcbo,'Tag');
case 'Norme1022'
set(findobj(hf,'Tag','Norme1022'),'Value',1)
case 'NormeUsrV'
set(findobj(hf,'Tag','NormeUsrV'),'Value',1),enable(hno(6))
end
case 'NormeG53'
set(gcbo,'Value',1),enable(hno(4))
case 'NormeCh'
set(gcbo,'Value',1),enable(hno(5))
case 'NormeUsrV'
set(gcbo,'Value',1),enable(hno(6))
case 'NormeUsrI'
set(gcbo,'Value',1),enable(hno(7))
case 'Norme50160'
set(gcbo,'Value',1),enable(hno(8))
case {'Norme519','Param519-1'}
set(hrb(9),'Value',1),Scr519(hno(9:12))
end
If i could have some help to figure out what's wrong in my code it would help me a lot
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.
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
in this script that I use i can replace only one word teams--> milan, juventus, inter..
But i want replace many words (not only one word) for example:
[simply word replacement jack-->beta]
alfa-->beta
[sentence replacement jack-->jack,john,alfa]
jack
jack
john
alfa
This is actually code that i use
loop {
While !RegexMatch(strCapture, "teams$") {
Input, strUserInput, V L1, {BackSpace} ; V: visible, L1: Character length 1
If ErrorLevel = Endkey:BackSpace
strCapture := SubStr(strCapture, 1, StrLen(strUserInput) - 1)
else
strCapture .= strUserInput
; tooltip % ErrorLevel "`n" strUserInput "`n" strCapture "`n" ; enable this to see what actually happens
}
SendInput,
(Ltrim
{Backspace 5}
milan
juventus
inter
roma
lazio
napoli
mantova
)
strCapture := ""
}
How can I modify the code?
It is also possible to run the script integrating copy-paste?
You could use a For loop to replace the contents, but this would become increasingly tedious to maintain at scale, so YMMV.
The following will use the clipboard contents as the to/from variables, but you can swap it out with a variable as desired (replace "clipboard" with your string variable).
F3::
{
replace := {"alfa":"beta", "gamma":"delta"}
For start, end in replace {
StringReplace, clipboard, clipboard, %start%, %end%, All
}}
Return
I'm struggling with a small program, I can't find how to correct one mistake.
My program:
program calcul
! ce programme permet d'effectuer des opérations mathématique de base
IMPLICIT NONE
REAL::x,y
character(len=1)::op
character(len=16)::op_msg
write(*,*)"entrer le type d'opération à effectuer(+,-,/,x,*)"
read(*,*)op
write(*,*)"entrer le premier nombre de l'opération"
read(*,*)x
write(*,*)"entrer le deuxième nombre de l'opération"
read(*,*)y
if(op=="+") then
write(*,*)x,"plus",y,"egale",x+y
else if(op=="-")then
write(*,*)x,"moin",y,"egale",x-y
else if ((op==("*").or.("x")) then
write(*,*)x,"multiplie par",y,"egale",x*y
else if (op=="/")then
write(*,*)x,"divise par",y,"egale",x/y
else
write(*,*)"erreur:operation incorrecte"
end if
end program calcul
The error message:
calculette.f90:21.26:
else if ((op==("*").or.("x")) then
1
Error: Invalid character in name at (1)
Any idea? I don't understand why "x" is an invalid character?
else if ((op==("*").or.op==("x")) then
You are evaluating two separate conditions, so each one needs a "left" and "right" side.