I get error when I use zip.au3 and console.au3 together in an autoit script - autoit

I get the following error when I use zip.au3 and console.au3 together. To simulate this error please create a new script in SciTE script editor and include zip.au3 and console.au3 and then run it (just two include lines are sufficient to simulate). You will get two pop up messages.
Here are the error messages:
First Popup message:
AutoIt Error:
Line 456 (File "C:\Program Files (z86)|AutoIt3\Include\zip.au3:):
$ZipFile=#ZipSplit[2]
$ZipFile=^Error
Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.
Second popup message:
Line 455 (File "C:\Program Files (z86)|AutoIt3\Include\Console.au3:):
If $_Amount_Startup_COnsole Then If^Error
Error: Variable used without being declared.
(I would like to attach zip.au3 and console.au3. How can I do it? They are available for download rom Autoit Forum - Example scripts)
Regards,
Nazir

As far as i can see, the Problem is that the Zip.au3 starts a function at startup which it should not do.
If you delete the first Lines in Zip.au3 then it should work fine:
If UBound($CMDLine) > 1 Then
If $CMDLine[1] <> "" Then _Zip_VirtualZipOpen()
EndIf
So my AutoIt dont gives back any Error Messages anymore. But I'm not sure if the other functions will work now. Try it out.
Teifun2
PS: sorry for my bad english!

Related

How to stop R from stopping execution on error?

I'm having an issue where if I execute several lines of code at once and one of them has an error, the lines below don't get executed.
For example if I have:
table(data$AGE)
table(dataREGION)
table(date$SEXE)
I get the table for the first line, and then
Error in table(dataREGION) : object 'dataREGION' not found
>
And the last line does not execute.
Does anyone know why it does that and how to fix it?
(I work with R 4.2.2 and RStudio 2022.12.0+353 "Elsbeth Geranium" Release)
Thanks!
Have a nice day,
Cassandra
Fixed: In Global Options > Console, under "Execution" uncheck the "Discard pending console input on error"
It seems like you want to use try().
try(table(data$AGE), silent = F, outFile = T)
try(table(dataREGION)) # also works without any params
try(table(date$SEXE))
You can also use tryCatch() if you want more control but it doesn't seem necessary for your purpose.
__
As for why your dataREGION doesn't exectue:
Hazarding a guess it might be because you forgot the $ between data and REGION

How to eliminate security concern while accessing to the file through program in R in Windows?

While accessing to CSV file from disk with the help of the R program, where a path to the CSV file is provided in the configuration file ( A path is like "testData/Amazon S3/Inventory/Accounts.csv" which is provided in the Configuration file and cfig[2]$save.location is variable who is having value of this path accessed from Configuration file). Few lines of code are below
path <- cfig[2]$save.location
test_data <- fread(path,stringsAsFactors = FALSE,drop=col_ignor,blank.lines.skip = TRUE)
but it gave the message below:
Taking input= as a system command ('testData/Amazon
S3/Inventory/Accounts.csv') and a variable has been used in the
expression passed to input=. Please use fread(cmd=...). There is a
security concern if you are creating an app and the app could have a
malicious user and the app is not running in a secure environment;
e.g. the app is running as root. Please read item 5 in the NEWS file
for v1.11.6 for more information and for the option to suppress this
message.
'testData' is not recognized as an internal or external
command, operable program or batch file. Warning messages:
1: In (if
(.Platform$OS.type == "unix") system else shell)(paste0("(", :
'(testData/Amazon S3/Inventory/Accounts.csv) >
C:\Users\sharmb5\AppData\Local\Temp\RtmpOa25kH\filea78b5351f1'
execution failed with error code 1.
2: In fread(cfig[2]$save.location,
stringsAsFactors = FALSE, drop = col_ignor, : File
'C:\Users\sharmb5\AppData\Local\Temp\RtmpOa25kH\filea78b5351f1' has
size 0. Returning a NULL data.table.
when the following line of code executes,
config[4]$save.location <- stri_replace_all(config[4]$save.location, cp_val, fixed = cp_key)
It gives an error like as, Error in [<-.data.table(*tmp*, j, value = list(TestCaseID = "C419760", : Supplied 14 columns to be assigned 15 items. Please see NEWS for v1.12.2.
The above error was a warning but after manually updating of packages. This warning turns into an error. What will be the reason behind this issue and how to solve it? Thanks for Advance!!!

How to avoid printing / showing messages

this question has been asked before but non of the answers is working for me.
I am using the library rhdf5 from bioconductor.org to read HDF5 files: source("http://bioconductor.org/biocLite.R"); biocLite("rhdf5"); library(rhdf5);
When I use the h5read function to read particular variables that contain references the following warning message is printed:
"Warning: h5read for type 'REFERENCE' not yet implemented. Values replaced by NA's"
(It is not shown in red like errors and warnings in RStudio. Just in black)
The warning is OK for me as I don't need those references. But I use this function to read hundreds of variables, so my screen gets polluted with these messages.
For example:
a <-h5read(f, "/#Link2#")
Warning: h5read for type 'REFERENCE' not yet implemented. Values replaced by NA's
Warning: h5read for type 'REFERENCE' not yet implemented. Values replaced by NA's
I have tried all suggestions I found (capture.output, suppressMessage/Warning, sink, options(warn, max.print, show.error.messages):
capture.output(a <- h5read(f, "/#Link2#"), file='/dev/null')
I also tried invisible just in case: invisible(capture.output(a <- h5read(f, "/#Link2#"), file='/dev/null'))
suppressWarnings(suppressMessages(a <- h5read(f, "/#Link2#")))
I also tried suppressForeignCheck and suppressPackageStartupMessages just in case
{sink("/dev/null"); a <-h5read(f, "/#Link2#"); sink()}
{options(warn=-1, max.print=1,show.error.messages=FALSE); a <-h5read(f, "/#Link2#") }
They all keep producing the same warning messages.
Does anyone knows any other thing I might try, or why are these things not working?
How does the library manages to print the messages skipping all these? Sounds that I might be doing something wrong...
Any help is appreciated.
Just as reference these are the other posts I used:
r: do not show warnings
How to suppress warnings globally in an R Script
suppress messages displayed by "print" instead of "message" or "warning" in R
Suppress one command's output in R
You should ask maintainer("rhdf5") to provide a solution -- print message less frequently, and use standard R warnings -- the message is from C code and uses printf() rather than Rf_warning() or Rf_ShowMessage() or Rprintf() / REprintf().
Here's an illustration of the problem
> library(inline)
> fun = cfunction(character(), 'printf("hello world\\n"); return R_NilValue;')
> fun()
hello world
NULL
> sink("/dev/null"); fun(); sink()
hello world
>
and a solution -- use Rf_warning() to generate R warnings. The example also illustrates how writing to R's output stream via Rprintf() would then allow the output to be captured with sink.
> fun = cfunction(character(), 'Rf_warning("hello world"); return R_NilValue;')
> x = fun()
Warning message:
In fun() : hello world
> x = suppressWarnings(fun())
> fun = cfunction(character(), 'Rprintf("hello world\\n"); return R_NilValue;')
> sink("/dev/null"); fun(); sink()
>
None of this helps you directly, though!
UPDATE the maintainer updated the code in the 'devel' branch of the package, version 2.17.2.

In R, after installed a package,' pixmap', Error in file(file, open = "rb") : cannot open the connection

I'm learning R programming, using the book, "The Art of R Programming".
In chapter 3.2.3 Extended Example: Image Manipulation. The author Matloff tries to use a Mount Rushmore gray-scale image to illustrate that the image is stored in matrix. He used a library called pixmap. And I downloaded the package, installed it.
> library(pixmap)
> mtrush1 <- read.pnm("mtrush1.pgm")
> mtrush1
Pixmap image
Type : pixmapGrey
Size : 194x259
Resolution : 1x1
Bounding box : 0 0 259 194
> plot(mtrush1)
This is what the book has written, and I tried to run this, but got the error message,
> library(pixmap)
> mtrush1 <- read.pnm("mtrush1.pgm")
Error in file(file, open = "rb") : cannot open the connection
In addition: Warning message:
In file(file, open = "rb") :
cannot open file 'mtrush1.pgm': No such file or directory
starting httpd help server ... done
What does this mean? cannot open the connection? And also the mtrush1.pgm does not exist? How should I fix it here? Any help? Much appreciated.
Summary:
Add the argument cellres=1 to your function call and you should be fine.
Answer:
The second error you saw--Warning message: In rep(cellres, length = 2) : 'x' is NULL so the result will be NULL--is because you haven't set the cellres argument and, as a result, "cellres" assumes its default value (i.e. 'NULL'--hence the warning). For what you're working on, setting the cellres argument to 1 will do the trick (though you can pass in a two-element vector with unequal values and see just how it affects your figure by plotting the resulting object).
Note: Though it's a little late to be answering, I figure that since I had the same problem earlier today (and since Google was no help) a response was probably warranted.
This means that the file mtrush1.pgm is not in current directory. You should either setwd to the directory that contains this file, or specify the complete path in read.pnm.
For the file mtrush1.pgm, you can download it from http://heather.cs.ucdavis.edu/~matloff/
The file mtrush1.pgm and the R scripts from the book "The Art Of R Programming" can be found at this GitHub site.

error in reading R file while submitting a r job to condor

I have a R Job that is submitted to the condor, The R file(one.R) which is submitted to the condor is reading another R file(two.R), when I submit the job to the condor its is failed and the reason for that is the submitted R(one.R) file is not reading the called R file(two.R)
Error in text file is :
Error in file(file, "rt") : cannot open the connection
Calls: read.table -> file
In addition: Warning message:
In file(file, "rt") :
cannot open file 'C:/Users/pcname/Desktop/test_case/two.R': Permission denied
Execution halted
and my submit file is
#test_input.condor
#
executable = C:\R\R-2.10.1\bin\Rscript.exe
arguments = one.R
universe = vanilla
getenv = true
#requirements = ARCH == "INTEL" && OPSYS == "WINNT60"
input = one.R
should_transfer_files = yes
transfer_executable = false
when_to_transfer_output = ON_EXIT
transfer_input_files = C:/Users/OmegaAdmin/Desktop/test_case/two.R
log = test_input.log
output = test_input.out
error = test_input.err
queue
Appreciate any ideas on this.
Thanks,
This is not an R-related problem, but a problem of accessibility. The error message seems rather clear to me: the server has no reading rights for that file. Make sure you share the file or folder you want to read in. I don't know what the setup is of the network and clusters wherever you're located, but you better contact the admins to ask how you get your files to the right places.
Also make sure that if you transfer files to the servers/cluster, you adapt your R script so it points to the right directories. Which is probably not your own harddrive...
When you say
transfer_input_files = C:/Users/OmegaAdmin/Desktop/test_case/two.R
That tells Condor to copy two.R into the current working directory when the job starts. The current working directory is a specially created workspace, not (usually) a home directory. Thus I would expect the full path to look something like
C:/condor/execute/dir_28412/two.R
However, R is actually looking in
C:/Users/pcname/Desktop/test_case/two.R
Why is R looking there? Does one.R potentially say "Find two.R in $HOME/Desktop/test_case"? Does it perhaps say, "Look in Desktop/testcase/two.R" and R has configuration that wants to look relative to the user's home directory?
The solution is almost certainly to modify one.R or your R configuration to look for two.R in the current working directory. If for some reason R changes its current working directory, the environment variable _CONDOR_SCRATCH_DIR should contain it.
On a related note, you said:
arguments = one.R
input = one.R
The first is an argument passed to Rscript.exe, which I'm guessing tells R to load and run a file called one.R. Except that script isn't present! If you want that to work, you'll need to add it to transfer_input_files. But it obviously appears to work; why? Because "input=one.R" means "take the contents of one.R and pipe it in as standard input to Rscript.exe; the same as if you'd typed those contents in." I'm guessing you can remove the arguments, or remove the input and add one.R to your transfer_input_files, removing the ambiguity.

Resources