IF IS nothing then count - if-statement

I want to create statement such as
=IIf(IsNothing(Fields!Amount.Value)),0,(Sum(Fields!Amount.Value)/1)
but from some reason it does not work. It should check value if it is null. If it's null, just enter 0, if it is not null, just make the calculation.
What am I doing wrong here? I am getting error for the first part of "IsNothing" code which says "Wrong number of arguments" but I do not see the error.

Found it.
=IIf((IsNothing(Fields!Amount.Value)),0,(Sum(Fields!Amount.Value)/1))
Just missed brackets.

Related

What does an exit value of -1 mean when compiling and how to debug it?

I am a C++ beginner. For some reason I cannot find a page with error codes and what they mean. Often my eclipse does this:
Does this -1 rather than 0 mean the same thing all the time? A segmentation fault perhaps? Or is it just a general "we didn't reach the end of the program" error?
Right now I put cout statements before and after every line until I find where it stops running. Is there somewhere specific I should look when seeing this -1?

"Invalid expression, assumed zero" error on if-statement

I'm getting the following error whenever I compile my code: "Error 029: Invalid expression, assumed zero"
The error is thrown on the following line:
if ((PlayerInfo[playerid][ADMINLevel])) || (IsPlayerAdmin(playerid))
I want the if-statement to check if "ADMINLevel" is above zero or if the player is logged in as an RCON admin.
You're constructing your if-statement wrong. The correct way to do it is
if(PlayerInfo[playerid][ADMINLevel] > 0 || IsPlayerAdmin(playerid))
{
/* Put your desired script here */
}
Your code was nearly correct (although it did have some unnecessary brackets), you just need to actually add a comparison to the ADMINLevel check. An if-statement should be like a question ("is admin level more than 0", rather than just "is admin level"). You can find more information about if-statements in Pawn here, and I think it will be useful for you to read.
PlayerInfo[..][..] does not return a boolean. Add > 0 to fix it

C++ - Creating folder method

I have the following method in C++:
In case the folder already exists, the correct message is displayed on the screen. However, if the folder does NOT exist, nothing is displayed on the screen, that is, the part identified by case NULL is not executed. How can I solve this problem?
In other words, how can I get the code after the case NULL to run if the folder does not exist?
First, if the folder does not exist, CreateDirectory() will probably succeed and return a non-zero value, so the if condition will return false and you will never get to the switch statement.
Second, GetLastError() does as advertised: it returns the last error. If CreateDirectory() does not raise an error, it will return whatever was the last error set by any other function. Checking for NULL is not very useful.
The spec say that as long as CreateDirectory succeeds, the return value is nonzero.
CreateDirectory
So why don't you use an else to the if clause to print that
At max you can use a default in your switch to print
"There was some error".
Since the switch only executes in case of an error

C++ Console INT Input Validation - Detect ENTER before no data entered?

I have this block of code form my input class I wish to improve. It works fine at the moment.
http://ideone.com/ryatJ
You use it like this... What it dose is pass a reference to the stream, and a reference to the userinput and a int to mark the max range the input has to be. The usrinput is referenced so we can use that elsewhere and it returns a true false so we can use it like this.. to get input...
while (!(validate(cin, returnval, a))){
//# Error Code code here
}
Basically everything works.. it asks the user to input a number that we are expecting as a int.
Using if (cin >> int) - I get a true false based on if the user entered a int or not. (so any string or anything... errors)
Using > and < we make sure the int is in the correct range, or it errors.
Useing peek we check the stream for a \n.. if it is not found.. it errors. (so 2.2 or 2:3 4#3 etc etc will error)
So that is all working, so well in fact I only just recently noticed that there is one more error check I need. Though I am not sure how to do it.
Basically if you just press enter with out first putting in ANY value, cin just goes to a new line. Is there a way to detect that the user just hit enter and nothing else, so I can return teh correct error message and redraw the menu screen and all the other stuff I wish to do.?
SUMMERY
How can I add to this a function to check if enter is pressed with out entering any other vales?
Thanks for the help
--Jynks
EDIT------
I can not answer my own question.. but this is the answer...
I was very close.. but the answer was in my code already.... meaning that cin.peek() is looking at the stream, at the moment it is calling it after it is read into a variable. This means it is seeing the "2nd" char and why the test works... all I needed to do was make a new test b4 the cin was read and it checked the 1st character..
Solved
http://ideone.com/mt7jH

Strange error trying to read registry value with Windows/C++

I'm trying to read the install path for an application, and I'm baffled at the behaviour I'm getting. First, here's the code that didn't work (formatted it a little so it doesn't take up a huge line):
LONG status = RegQueryValueEx(
hkRegistry,
"InstallPath",
0,
&regType, (LPBYTE)installPath,
&regSize );
if (status == ERROR_SUCCESS) {
// Handle success.
}
I realized that it was failing on the call to RegQueryValueEx, so I decided to probe the return value by throwing it within an exception by adding:
else {
throw Exception( status );
}
But then... the code started to work and the call to RegQueryValueEx succeeded. I've been able to repeat this behaviour as long as I throw something within the else. If I comment out the body of the else, the error returns.
Edit: Okay, I tried calling MessageBox instead of an exception and I get the same behaviour. If I comment it out, it stops working again.
Is there a rational explanation for this?
It's possible that the buffer for installPath is too small compared to the value contained in regSize (which must be initialized to the size of the buffer).
If installPath is a stack-allocated value I suspect that it is overflown, causing the value of status to get overwritten.