I want to know how the values of BATCH_INSTALL system variable changes during the installation process? In my installer when I was using it on Windows 7, during debugging I found that the value of BATCH_INSTALL system variable becomes -1 (i.e neither TRUE nor FALSE). So I want to know why the value of BATCH_INSTALL becomes -1?
The value -1 is the value of VARIANT_TRUE, a true value that works well with, or is required by, automation languages such as VB. There are so many definitions of "true" around, it can be hard to tell which one is being used. Generally the safest is to read values as zero and non-zero, and to specify either as 0 and 1, or as 0 and -1, depending on context. You only get tripped up there if someone has a "special" meaning for -1.
This is confirmed at both extremes by http://community.installshield.com/archive/index.php?t-118230.html where not only are people confused by the -1, but the later posts agree it means the non-zero form of true.
Related
I'm trying to understand the bounded buffer problem(consumer/producer) more clearly, As I know one of the solutions to this problem is using 3 semaphores
1. FULL-which holds full places in the array
2. EMPTY-which holds the available places in the array
3. MUTEX-which holds number 1 or 0
could it be possible to explain further what does that mean for example if the number of FULL is negative? or the number of empty is negative?
Could that be that mutex will not be 1 or 0? if so what does that mean?
x=0
for i in range(0,9):
x=x+1
When I run the script second time, I want x to start with a value of 9 . I know the code above is not logical. x will get the value of zero. I wrote it to be as clear as I can be. I found a solution by saving x value to a txt file as it is below. But if the txt file is removed, I will lose the last x value. It is not safe. Is there any other way to keep the last x value for the second run?
from pathlib import Path
myf=Path("C:\\Users\\Ozgur\\Anaconda3\\yaz.txt")
x=0
if myf.is_file():
f=open("C:\\Users\\Ozgur\\Anaconda3\\yaz.txt","r")
d=f.read()
x=int(d)
else:
f=open("C:\\Users\\Ozgur\\Anaconda3\\yaz.txt","w")
f.write("0")
deger=0
for i in range(0,9):
x=x+1
f=open("C:\\Users\\Ozgur\\Anaconda3\\yaz.txt","w")
f.write(str(x))
f.close()
print(x)
No.
You can't 100% protect against users deleting data. There are some steps you can take (such as duplicating the data to other places, hiding the file, and setting permissions), but if someone wants to, they can find a way to delete the file, reset the contents to the original value, or do any number of things to manipulate the data, even if it takes one unplugging the hard drive and placing it in a different computer.
This is why error-checking is important, because developers cannot make 100% reliable assumptions that everything in place is there and in the correct state (especially since drives do wear down after long periods of time causing odd effects).
You can use databases, they are less likely to be lost than files. You can read about MySQL using Python
However, this is not the only way you can save the value of x. You can have an environment variable in your operating system. As an example,
import os
os.environ["XVARIABLE"] = "9"
To access this variable later, simply use
print os.environ["XVARIABLE"]
Note: On some platforms, modifying os.environ will not actually modify the system environment either for the current process or child processes.
I have a memory array which consists of series of valid values, starting from location 0. Rest of the values are 'XX'.
I want to count the number of valid values in the memory. One way I can think of is by looking out for 'XX' for the first time using '==='. But it can't be synthesized.
Please suggest some other way to do the same.
Based on what you have described, I would suggest that you design in a register that indicated the address of the last valid value in your memory, that you can set when the memory is loaded with the values.
As mentioned in the comments, once synthesized, you have no way of knowing the values passed those you have set explicitly (1'bx is simply a simulation placeholder for "dont care", meaning the value could be 1'b1 or 1'b0 during the actual run). Thus, you can either have a special value for uninitialized memory addresses that the entire memory is filled with at boot and DOESNT appear in your valid data, or, better, use the register concept suggested above to keep track of the size/address of your last valid entry.
A value obtained for a (double precision) variable is written to the screen as part of my Fortran program. Following the write statement, the program continues uninterrupted.
However, when I add a stop statement immediately after the write, I get a different (screen printed) value for this variable. The change in values begins at the 6th significant digit.
The code includes:
enertot=energy0(x,y,z,size) !energy0 is a function
write (*,*) 'The initial energy is', enertot
This outputs some (plausible) value for enertot on the screen, and the program goes on.
Now adding the stop:
enertot=energy0(x,y,z,size) !energy0 is a function
write (*,*) 'The initial energy is', enertot
stop
This gives me a different value for enertot.
The same problem happens regardless of the compiler I use (f90/95 compilers). Could it have to do with the machine being very old, operating on an out of date Linux Fedora OS?
Even weirder - when I run the exact same program on my Windows laptop with the Silverfrost compiler, I get a third result for enertot altogether, differing from the previous results starting from the 5th significant digit. In this case, however, addition of the stop doesn't change the printed value at all.
Any thoughts?
My code was giving wrong answer on problem 400A on http://codeforces.com while it was working fine on my laptop. Somebody suggested to me that the problem can be solved by increasing the size of my string and after doing that, the code got accepted. To find the mistake in my original code, I placed print statements in the two codes to find out what is going wrong and made two submissions in codeforces. In the following submissions, I just changed the size of array w from 12 to 13:
http://codeforces.com/contest/400/submission/5948686
http://codeforces.com/contest/400/submission/5948717
As you can see, in the former case, the inner loop is not executed for i=0 but in the later case it is. Why is this happening (I know that string size must be kept greater than the string but how is this related to the functioning of the inner loop at i=0)?
Here's my best guess, but it depends on the compiler used, how the memory way laid out, - there may be no way to know for sure. Someone else may have a better guess.
So here's what maybe happened: scanf read in 13 characters - the 12 characters, plus a null terminating character (\0). The null terminator has a ascii value of 0
The 12 characters were thrown into the buffer correctly, and then the \0 character maybe overwrote the first value of ar. So the inner loop became for(j=0; j < 0; j++)
Moral of the story is that buffer overflows are bad.