Return error code after first detected error

I have a function which does some initialization and calls other functions, each of which returns an error code. I want to be able to return from this function after the first detected error like this: int error_code = FirstFunction(); if (error_cod...
more »

2017-12-03 20:12 (6) Answers

Loop to add new columns with ifelse

I would like to make my code more efficient, I have a survey where my data looks like: survey <- data.frame( x = c(1, 6, 2, 60, 75, 40, 27, 10), y = c(100, 340, 670, 700, 450, 200, 136, 145)) #Two list...
more »

2017-11-27 10:11 (3) Answers

My if statement gives me the wrong output

window.onload = start; function start() { document.getElementById("kalk").onclick = find; find(1, 9999); } function find(min, max) { var factor = document.getElementById("tall").value; var factor2 = document.getElementById(...
more »

2017-11-25 23:11 (2) Answers

Use validation on GridView with BoundField

I'm new in aspx and I have a grid like this: <asp:GridView ID="grdViewTareas" AutoGenerateColumns="false" runat="server" CssClass="Grid"> <Columns> <asp:BoundField DataField="stardate" HeaderText="Fecha Inicio" DataFormatString=...
more »

2017-10-12 19:10 (1) Answers

vba word: If Then find and replace

in this code, I want to do the following: If the word is finished with a letter M Replace with letter N. If the word ends with a letter N, Replace with letter M. I do not know well using the IF - Then statement. Any help would be greatly appreciate...
more »

2017-10-12 19:10 (1) Answers

Both if else statements executing together

I have written a function to search words in a qtable widget (which has 10 rows) and display the relevant word on the the 1st row if the word is in the table widget. But unforutnately, when I enter a word in the table widget and click the button th...
more »

2017-10-01 05:10 (0) Answers

Removing file using name contains in Ruby

I have written the below code to keep a file that matches the passed in name and removes the rest of the files in the folder. def removeFiles2(path, namePart) Dir[path+'/*'].each do |fname| break if !(fname.include?...
more »

2017-09-29 10:09 (2) Answers

How to make global empty integer?

How to declare global empty integer? I have simple code but i don't know how to declare a variable before def. In java I can do just that: public int a; but how to do it in python? Without this, the third if not working My code: def abcd: if s<...
more »

2017-09-16 01:09 (4) Answers

If Exists command in setting a variable

I've got a working IF EXISTS command to select a PID_GUID that's already in the tables, or to select a value to use as a PID_GUID if it does not exist already in the tables. The command looks like this; IF EXISTS (SELECT PID_GUID FROM PID WHERE EDI_...
more »

2017-09-15 20:09 (2) Answers

How to address the value in the next row

I have a data set of equity returns for some thousand companies for the past 30 years. Some of these companies are "DEAD" (usually delisted or bankrupt), and therefore they have returns = 0. I want to assign NAs to the returns of these companies, but...
more »

2017-09-12 15:09 (3) Answers

How to use Optional Ints in a Switch statement

I have made some progress on my app to play RoShambo, but am stumped on one particular thing. In one ViewController, I have established two properties of the class. I want them to be integers because I use a switch statement later on in the class wit...
more »

2017-09-03 02:09 (2) Answers

Reviewing IF conditional code to save CPU cycles

I am reviewing the usage of if condition in my program, in there, I have lines like the following: if(count > 4) count = 4; Would it be a good idea to write the above if conditional statement as the following non-branched one? count = 4*(count...
more »

2017-08-29 17:08 (2) Answers

PHP: RegEx for nested {IF} {ENDIF} Conditions

I am searching the whole day for a RegEx that matches just the inner {IF} - {ENDIF}-Statement in a nested condition code. Does anyone have an idea? for example: {IF bla}Text 1{ELSEIF ble}Text 2 {IF bli}Text 2.1{ELSE blo}Text 2.1{ENDIF} Main text en...
more »

2017-08-28 00:08 (2) Answers

If find a date, then do...- VBA Excel

I struggle with one simple code that does not cooperate with me ;) I have in the column L some dates beginning from the row 5. The dates are in format but in the formula bar is visible the whole date in the format In column F ar...
more »

2017-08-11 15:08 (2) Answers