Special charecters on non english keyboard - arduino

I needed some special charecters to be printed on cmd with Keyboard.h, but i dont have a English layout keyboard,ive got a Estoninan layout because im from Estonia. Lets get to the point!
Ive triend every special key but i havent got the \ key yet, anyone knows how can i get it?
Board used: Arduino Pro Micro
Currently got special charecters:
! = !
~ = ~~
" = Ä
# = #
¤ = +15708
% = %
& = /
/ = -
( = )
) = =
= = ´´
? = _
Õ = +15467
Ü = +15460
Ä = +15484
Ö = +15466
* = (
_ = ?
: = Ö
; = ö
> = :
# = "
£ = +15709
$ = ¤
€ = +32084
{ = Ü
[ = ü
] = õ
} = Õ
\ = '
§ = +15705
½ = +15683
ž = +14914
| = *
< = ;
š = +14943
ˇ = +13433
´ = +15692
+ = `
` = ˇ
ˇ = +13433
' = ä
ü = +15428
õ = +15435
ö = +15434
ä = +15452
- = +
. = .
, = ,

Keyboard.press(KEY_LEFT_ALT);
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press('_');
to get Backslash

Related

How can I use last-of in a QUERY-PREPARE()?

I made a huge code and it was taking a very long time to process. Following suggestions here, I made it shorter and better and now it's running much faster. However, I noticed I should be getting a sum of the values whereas I'm just getting the values. I tried using ACCUMULATE TOTAL, but it didn't work because the LAST-OF can only be used with a BREAK BY and my break by is inside the QUERY-PREPARE().
How can I get the sum of the following values?
doc-fiscal.vl-cont-doc
doc-fiscal.vl-bicms
doc-fiscal.vl-icms
doc-fiscal.vl-icmsou
doc-fiscal.vl-ipiou
doc-fiscal.vl-ipi
Bellow is the code I'm using, which is working almost perfectly.
//Query
cQuery = "FOR EACH doc-fiscal WHERE doc-fiscal.dt-docto >= " + QUOTER(pd-data-1) + " AND doc-fiscal.dt-docto <= " + QUOTER(pd-data-2) + " AND (doc-fiscal.cod-observa <> 4 OR doc-fiscal.tipo-nat <> 3) AND doc-fiscal.cd-situacao <> 06 AND doc-fiscal.cd-situacao <> 22".
cQuery = cQuery + semCodEmitente + comCodEmitente + CheckBoxindSitDoc.
cQuery = cQuery + ", EACH natur-oper USE-INDEX natureza WHERE doc-fiscal.nat-operacao = natur-oper.nat-operacao" + modeloEletronico + tipoEntrada + natOper.
cQuery = cQuery + " BREAK BY doc-fiscal.dt-docto BY doc-fiscal.nr-doc-fis ".
QUERY qRelatorio:QUERY-PREPARE(cQuery).
QUERY qRelatorio:QUERY-OPEN().
GET FIRST qRelatorio.
DEF VAR soma-vl-cont-doc AS DECIMAL.
DO WHILE AVAILABLE doc-fiscal:
soma-vl-cont-doc = soma-vl-cont-doc + doc-fiscal.vl-cont-doc.
IF LAST-OF(doc-fiscal.nr-doc-fis) THEN DO:
CREATE tt-relatorio.
ASSIGN
tt-relatorio.nr-doc-fis = doc-fiscal.nr-doc-fis
tt-relatorio.serie = doc-fiscal.serie
tt-relatorio.char-2 = SUBSTRING(doc-fiscal.char-2,155,44, "CHAR")
tt-relatorio.cod-model-nf-eletro = natur-oper.cod-model-nf-eletro
tt-relatorio.tipo = natur-oper.tipo
tt-relatorio.cod-estabel = doc-fiscal.cod-estabel
tt-relatorio.cod-emitente = doc-fiscal.cod-emitente
tt-relatorio.nome-ab-emi = doc-fiscal.nome-ab-emi
tt-relatorio.cgc = doc-fiscal.cgc
tt-relatorio.dt-emis-doc = doc-fiscal.dt-emis-doc
tt-relatorio.dt-docto = doc-fiscal.dt-docto
tt-relatorio.ind-sit-doc = doc-fiscal.ind-sit-doc
tt-relatorio.vl-cont-doc = doc-fiscal.vl-cont-doc
tt-relatorio.vl-bicms = doc-fiscal.vl-bicms
tt-relatorio.vl-icms = doc-fiscal.vl-icms
tt-relatorio.vl-icmsou = doc-fiscal.vl-icmsou
tt-relatorio.vl-ipiou = doc-fiscal.vl-ipiou
tt-relatorio.vl-ipi = doc-fiscal.vl-ipi
tt-relatorio.imp-nota = natur-oper.imp-nota.
GET NEXT qRelatorio.
END.
END.
QUERY qRelatorio:QUERY-CLOSE().
Thanks for the help and sorry for being such a newbie. I hope my question can help other people.
I managed to do it.
I used LAST-OF() METHOD. My code became the following.
DEF VAR soma-vl-cont-doc AS DECIMAL. //INICIO DAS SOMAS
DEF VAR soma-vl-bicms AS DECIMAL.
DEF VAR soma-vl-icms AS DECIMAL.
DEF VAR soma-vl-icmsou AS DECIMAL.
DEF VAR soma-vl-ipiou AS DECIMAL.
DEF VAR soma-vl-ipi AS DECIMAL.
DO WHILE AVAILABLE doc-fiscal:
soma-vl-cont-doc = soma-vl-cont-doc + doc-fiscal.vl-cont-doc.
soma-vl-bicms = soma-vl-bicms + doc-fiscal.vl-bicms.
soma-vl-icms = soma-vl-icms + doc-fiscal.vl-icms.
soma-vl-icmsou = soma-vl-icmsou + doc-fiscal.vl-icmsou.
soma-vl-ipiou = soma-vl-ipiou + doc-fiscal.vl-ipiou.
soma-vl-ipi = soma-vl-ipi + doc-fiscal.vl-ipi.
IF QUERY qRelatorio:LAST-OF(2) THEN DO:
CREATE tt-relatorio.
ASSIGN
tt-relatorio.nr-doc-fis = doc-fiscal.nr-doc-fis
tt-relatorio.serie = doc-fiscal.serie
tt-relatorio.char-2 = SUBSTRING(doc-fiscal.char-2,155,44, "CHAR")
tt-relatorio.cod-model-nf-eletro = natur-oper.cod-model-nf-eletro
tt-relatorio.tipo = natur-oper.tipo
tt-relatorio.cod-estabel = doc-fiscal.cod-estabel
tt-relatorio.cod-emitente = doc-fiscal.cod-emitente
tt-relatorio.nome-ab-emi = doc-fiscal.nome-ab-emi
tt-relatorio.cgc = doc-fiscal.cgc
tt-relatorio.dt-emis-doc = doc-fiscal.dt-emis-doc
tt-relatorio.dt-docto = doc-fiscal.dt-docto
tt-relatorio.ind-sit-doc = doc-fiscal.ind-sit-doc
tt-relatorio.vl-cont-doc = soma-vl-cont-doc
tt-relatorio.vl-bicms = soma-vl-bicms
tt-relatorio.vl-icms = soma-vl-icms
tt-relatorio.vl-icmsou = soma-vl-icmsou
tt-relatorio.vl-ipiou = soma-vl-ipiou
tt-relatorio.vl-ipi = soma-vl-ipi
//tt-relatorio.idi-sit-nf-eletro = nota-fiscal.idi-sit-nf-eletro
tt-relatorio.imp-nota = natur-oper.imp-nota.
soma-vl-cont-doc = 0.
soma-vl-bicms = 0.
soma-vl-icms = 0.
soma-vl-icmsou = 0.
soma-vl-ipiou = 0.
soma-vl-ipi = 0.
END.
GET NEXT qRelatorio.
END.
With this, I managed to get the answers I wanted andthe query is quite fast. If there's any suggestions as to how make it faster, I'm open for them. Thanks.

how can I use return values from a function?

I use some functions in my main code which they return some values (scalar).
These values will compare in main code.
But when I run the code it has this Error:
"ERROR: MethodError: no method matching isless(::Array{Float64,1}, ::Array{Float64,1})"
Please help me. This is the code:
using JuMP, CPLEX
ZT = [-36 ; -244.5 ];
ZB = [27.149 ; -288.747];
M = 5;
model = CreateModel();
WES = model[1];
f1 = model[2]; f2 = model[3];
rf1 = model[4]; rf2 = model[5];
lf1 = model[6]; lf2 = model[7];
x = WES[:x] ; y = WES[:y] ;
JuMP.setRHS( rf1, ZB[1] ); JuMP.setRHS( lf1, ZT[1] );
JuMP.setRHS( rf2, ZT[2] ); JuMP.setRHS( lf2, ZB[2] );
ZI, ofvInt = Intpoint( ZB, ZT );
Hgap, Vgap, ZG, ofvGap = Gappoint( ZB, ZT );
if ofvInt !== NaN
y = ZI[2];
elseif ofvGap !== NaN
if isless( Hgap, M + Vgap ) # "MethodError: no method matching
# isless(::Array{Float64,1}, ::Array{Float64,1})"
y = ZG[1]
end
y = ZG[2];
else
y = ( ZB[2] + ZT[2] ) / 2;
end

Error in textConnection(): all connections are in use

I have read most of the posts concerning an error of this type but neither applies to my case. I am new in R, working on an assignment for school based on Nolan and Lang's book Data Science Case Studies in R. I am working on using stats to identify spam, url for the code can be found here, which require working with files from http://spamassassin.apache.org/old/publiccorpus/ (which are pretty big)
Now the problem I am facing is the following (just posting the chunks of code where I have encountered the issue):
sampleSplit = lapply(sampleEmail, splitMessage)
processHeader = function(header)
{
# modify the first line to create a key:value pair
header[1] = sub("^From", "Top-From:", header[1])
headerMat = read.dcf(textConnection(header), all = TRUE)
headerVec = unlist(headerMat)
dupKeys = sapply(headerMat, function(x) length(unlist(x)))
names(headerVec) = rep(colnames(headerMat), dupKeys)
return(headerVec)
}
headerList = lapply(sampleSplit,
function(msg) {
processHeader(msg$header)} )
contentTypes = sapply(headerList, function(header)
header["Content-Type"])
names(contentTypes) = NULL
contentTypes
hasAttach = grep("^ *multi", tolower(contentTypes))
hasAttach
boundaries = getBoundary(contentTypes[ hasAttach ])
boundaries
boundary = boundaries[9]
body = sampleSplit[[15]]$body
bString = paste("--", boundary, sep = "")
bStringLocs = which(bString == body)
bStringLocs
eString = paste("--", boundary, "--", sep = "")
eStringLoc = which(eString == body)
eStringLoc
diff(c(bStringLocs[-1], eStringLoc))
### This code has mistakes in it - and we fix them later!
processAttach = function(body, contentType){
boundary = getBoundary(contentType)
bString = paste("--", boundary, "$", sep = "")
bStringLocs = grep(bString, body)
eString = paste("--", boundary, "--$", sep = "")
eStringLoc = grep(eString, body)
n = length(body)
if (length(eStringLoc) == 0) eStringLoc = n + 1
if (length(bStringLocs) == 1) attachLocs = NULL
else attachLocs = c(bStringLocs[-1], eStringLoc)
msg = body[ (bStringLocs[1] + 1) : min(n, (bStringLocs[2] - 1),
na.rm = TRUE)]
if ( eStringLoc < n )
msg = c(msg, body[ (eStringLoc + 1) : n ])
if ( !is.null(attachLocs) ) {
attachLens = diff(attachLocs, lag = 1)
attachTypes = mapply(function(begL, endL) {
contentTypeLoc = grep("[Cc]ontent-[Tt]ype", body[ (begL + 1) : (endL - 1)])
contentType = body[ begL + contentTypeLoc]
contentType = gsub('"', "", contentType )
MIMEType = sub(" *Content-Type: *([^;]*);?.*", "\\1", contentType)
return(MIMEType)
}, attachLocs[-length(attachLocs)], attachLocs[-1])
}
if (is.null(attachLocs)) return(list(body = msg, attachInfo = NULL) )
else return(list(body = msg,
attachDF = data.frame(aLen = attachLens,
aType = attachTypes,
stringsAsFactors = FALSE)))
}
bodyList = lapply(sampleSplit, function(msg) msg$body)
attList = mapply(processAttach, bodyList[hasAttach],
contentTypes[hasAttach],
SIMPLIFY = FALSE)
lens = sapply(attList, function(processedA)
processedA$attachDF$aLen)
head(lens)
attList[[2]]$attachDF
body = bodyList[hasAttach][[2]]
length(body)
body[35:45]
processAttach = function(body, contentType){
n = length(body)
boundary = getBoundary(contentType)
bString = paste("--", boundary, sep = "")
bStringLocs = which(bString == body)
eString = paste("--", boundary, "--", sep = "")
eStringLoc = which(eString == body)
if (length(eStringLoc) == 0) eStringLoc = n
if (length(bStringLocs) <= 1) {
attachLocs = NULL
msgLastLine = n
if (length(bStringLocs) == 0) bStringLocs = 0
} else {
attachLocs = c(bStringLocs[ -1 ], eStringLoc)
msgLastLine = bStringLocs[2] - 1
}
msg = body[ (bStringLocs[1] + 1) : msgLastLine]
if ( eStringLoc < n )
msg = c(msg, body[ (eStringLoc + 1) : n ])
if ( !is.null(attachLocs) ) {
attachLens = diff(attachLocs, lag = 1)
attachTypes = mapply(function(begL, endL) {
CTloc = grep("^[Cc]ontent-[Tt]ype", body[ (begL + 1) : (endL - 1)])
if ( length(CTloc) == 0 ) {
MIMEType = NA
} else {
CTval = body[ begL + CTloc[1] ]
CTval = gsub('"', "", CTval )
MIMEType = sub(" *[Cc]ontent-[Tt]ype: *([^;]*);?.*", "\\1", CTval)
}
return(MIMEType)
}, attachLocs[-length(attachLocs)], attachLocs[-1])
}
if (is.null(attachLocs)) return(list(body = msg, attachDF = NULL) )
return(list(body = msg,
attachDF = data.frame(aLen = attachLens,
aType = unlist(attachTypes),
stringsAsFactors = FALSE)))
}
readEmail = function(dirName) {
# retrieve the names of files in directory
fileNames = list.files(dirName, full.names = TRUE)
# drop files that are not email
notEmail = grep("cmds$", fileNames)
if ( length(notEmail) > 0) fileNames = fileNames[ - notEmail ]
# read all files in the directory
lapply(fileNames, readLines, encoding = "latin1")
}
processAllEmail = function(dirName, isSpam = FALSE)
{
# read all files in the directory
messages = readEmail(dirName)
fileNames = names(messages)
n = length(messages)
# split header from body
eSplit = lapply(messages, splitMessage)
rm(messages)
# process header as named character vector
headerList = lapply(eSplit, function(msg)
processHeader(msg$header))
# extract content-type key
contentTypes = sapply(headerList, function(header)
header["Content-Type"])
# extract the body
bodyList = lapply(eSplit, function(msg) msg$body)
rm(eSplit)
# which email have attachments
hasAttach = grep("^ *multi", tolower(contentTypes))
# get summary stats for attachments and the shorter body
attList = mapply(processAttach, bodyList[hasAttach],
contentTypes[hasAttach], SIMPLIFY = FALSE)
bodyList[hasAttach] = lapply(attList, function(attEl)
attEl$body)
attachInfo = vector("list", length = n )
attachInfo[ hasAttach ] = lapply(attList,
function(attEl) attEl$attachDF)
# prepare return structure
emailList = mapply(function(header, body, attach, isSpam) {
list(isSpam = isSpam, header = header,
body = body, attach = attach)
},
headerList, bodyList, attachInfo,
rep(isSpam, n), SIMPLIFY = FALSE )
names(emailList) = fileNames
invisible(emailList)
}
Everything runs fine right up to:
emailStruct = mapply(processAllEmail, fullDirNames,
isSpam = rep( c(FALSE, TRUE), 3:2))
emailStruct = unlist(emailStruct, recursive = FALSE)
sampleStruct = emailStruct[ indx ]
save(emailStruct, file="emailXX.rda")
I get the error Error in textConnection(header) : all connections are in use, therefore it doesn't recognize "emailStruct", which I need later on. I seriously don't know how to overcome it so that I can continue with the rest of the code, which requires some of these variables to work.
When you run textConnection() you are opening a text connection, but you are never closing it. Try closing it explicitly after you read from it
read.dcf(tc<-textConnection(header), all = TRUE)
close(tc)

Tkinter Module refresh window

My program is for a hangman game and I can't get the window to refresh once the button is clicked. At least i think that is the problem Here is my code for the window and the function linked to the button, let me know if you need more code:
def game(self, num):
self.game_window = tkinter.Tk()
self.game_window.title('Hangman')
self.game_window.geometry('200x150')
self.f1 = tkinter.Frame(self.game_window)
self.f2 = tkinter.Frame(self.game_window)
self.f3 = tkinter.Frame(self.game_window)
self.f4 = tkinter.Frame(self.game_window)
self.f5 = tkinter.Frame(self.game_window)
self.f6 = tkinter.Frame(self.game_window)
self.f7 = tkinter.Frame(self.game_window)
self.f8 = tkinter.Frame(self.game_window)
self.f9 = tkinter.Frame(self.game_window)
self.num = num
word_list = ['PYTHON','SOMETHING','COMPLETELY','DIFFERENT',
'LIST','STRING','SYNTAX','OBJECT','ERROR',
'EXCEPTION','OBJECT','CLASS','PERFORMANCE','VISUAL',
'JAVASCRIPT','JAVA','PROGRAMMING','TUPLE','ASSIGN',
'FUNCTION','OPERATOR','OPERANDS','PRECEDENCE',
'LOOPS','SENTENCE','TABLE','NUMBERS','DICTIONARY',
'GAME','SOFTWARE','NETWORK','SOCIAL','EDUCATION',
'MONITOR','COMPUTER']
shuffle = random.shuffle(word_list)
rand = random.choice(word_list)
self.word = rand.lower()
self.current = len(self.word)*'*'
self.letters = []
#self.start_lives = tkinter.Label(self.f1, text = 'You\'ve started the '
#'game with %s lives.\n'%(self.num))
#self.start_lives.pack(side = 'left')
self.lives_rem = tkinter.Label(self.f2,
text = 'Lives remaining: '+str(self.lives_left()))
self.lives_rem.pack(side = 'left')
self.guess_letter = tkinter.Label(self.f3, text = 'Guess a letter: ')
self.guess_entry = tkinter.Entry(self.f3, width = 10)
self.guess_letter.pack(side = 'left')
self.guess_entry.pack(side = 'left')
#self.f1.pack()
self.f2.pack()
self.f3.pack()
self.guess_button = tkinter.Button(self.f6,
text = 'Guess!',
command = self.update(self.guess_entry.get()))
self.guess_button.pack(side = 'left')
self.quit_game = tkinter.Button(self.f6,
text = 'Quit Game',
command = self.game_window.destroy)
self.quit_game.pack(side = 'left')
self.f6.pack()
def update(self, letter):
if letter in self.word and letter not in self.letters:
pos = self.word.index(letter)
self.current1 = list(self.current)
self.current1[pos] = letter.upper()
self.current2 = ''.join(self.current1)
self.letters.append(letter)
elif letter in self.letters:
self.already_guessed = tkinter.messagebox.showinfo('Error!',
'This letter has already '
'been guessed')
#letter is not in the word
elif letter not in self.word:
self.sorry = tkinter.Label(self.f5,
text = 'Sorry, guess again!')
self.sorry.pack(side = 'left')
self.letters.append(letter)
self.num -= 1
self.incorrect_word = tkinter.Label(self.f4,
text = 'Word: '+self.current)
self.incorrect_word.pack(side='left')
self.f5.pack()
self.f4.pack()
return self.current
These are two methods in a Hangman class.
The line that defines the guess button:
self.guess_button = tkinter.Button(self.f6, text = 'Guess!', command = self.update(self.guess_entry.get()))
requires modification. the command argument for the Button class should be a function, but this line is calling that function (which sends the output of the function as the value for the command argument). As you may see on the quit_game button definition, the self.game_window.destroy function is provided as the command, but is not called right now.
I suggest changing this line like this:
self.guess_button = tkinter.Button(self.f6, text = 'Guess!', command = self._on_guess_button_click)
and then add a new method to your class like this:
def _on_guess_button_click (self):
self.update(self.guess_entry.get())

After the "printingSystem1.ExportToImage (file name)", I do not want to run any software to view the images. What should I do?

/* I use of DevExpress component */
BrickGraphics gr = printingSystem1.Graph;
BrickStringFormat bsf = new BrickStringFormat(StringAlignment.Near, StringAlignment.Center);
gr.StringFormat = bsf;
gr.BorderColor = SystemColors.ControlDark;
ImageBrick imagebrick;
gr.Modifier = BrickModifier.Detail;
printingSystem1.Begin();
Image pageimage = Image.FromFile("Data\\sorathesab.jpg");
printingSystem1.PageSettings.Landscape = false;
gr.BeginUnionRect();
// Detail section creation.
gr.Modifier = BrickModifier.Detail;
printingSystem1.PageSettings.LeftMargin = 5;
printingSystem1.PageSettings.RightMargin = 5;
printingSystem1.PageSettings.TopMargin = 5;
printingSystem1.PageSettings.BottomMargin = 5;
float X = gr.ClientPageSize.Width - 1, Y = gr.ClientPageSize.Height - 1;// X = 736.32, Y = 930.24;
printingSystem1.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.A4;
imagebrick = gr.DrawImage(pageimage, new RectangleF(1, 1, X - 22, Y - 10), BorderSide.None, Color.Transparent);
HeaderReport(ROW[0, 8],ROW[0, 1], ROW[0, 2], X, Y);
BodyReport(ROW, X, Y, Rowcount);
ImageExportOptions ImageOption = printingSystem1.ExportOptions.Image;
ImageOption.PageRange = "1";
ImageOption.Format = ImageFormat.Jpeg;
ImageOption.ExportMode = ImageExportMode.SingleFile;
ImageOption.Resolution = 100;
TextBrick2(TxtFooterEmail.Text, (float)0.170 * X, (float)0.949 * Y, (float)0.680 * X, (float)0.019 * Y, "B Nazanin", (float)10.5);
if (Picload != string.Empty)
{
Image img = Image.FromFile(Picload);
imagebrick = gr.DrawImage(img, new RectangleF((float)0.345 * X, 0, (float)0.280 * X, (float)0.150 * Y),
BorderSide.None, Color.White);
}
// Create a report instance.
gr.EndUnionRect();
printingSystem1.End();
string FileName = #"Data\" + DateTime.Now.Hour.ToString()+ " _"+ DateTime.Now.Minute.ToString()+ " _"+
DateTime.Now.Second.ToString()+ ".jpg";// " _"+ "_"+ ROW[0, 8] +
printingSystem1.ExportToImage(FileName);
Process process = new Process();
process.StartInfo.FileName = FileName;
process.Start();
MyEmail.SendMailForYahyaee(TxtEmailfrom.Text, SearchemailAcount(ROW[0, 1], MainDataTable), TxtEmailPass.Text,
FileName, Rowcount);
Thread.Sleep(5000);
If you don't want to open the image, why are you using Process.Start? That's what is opening your default image viewer program.

Resources