Posts

Showing posts with the label if-statement

Error in conversion of upper and lower cases

Error in conversion of upper and lower cases Below code is to convert upper case to lower case and vice vers? if(s1.charAt(i)>=97 && s1.charAt(i)<=122){ s1.charAt(i)=s1.charAt(i)-32; } else if(s1.charAt(i)>=65 && s1.charAt(i)<=90){ s1.charAt(i)=s1.charAt(i)+32; } Please refer above and help what is the issue with this program? Possible duplicate of Replace character in StringBuilder – Shubhendu Pramanik Jun 29 at 10:08 what is s1 ? a String ? String is immutable, cannot be changed; anyway charAt is a method that returns a char, you cannot assign a new value to that returned value. – Carlos Heuberger Jun 29 at 10:15 s1 String charAt ...

if statement to skip certain values in loop

if statement to skip certain values in loop I have a range of X and Y values, and I have a domain that I don't want to calculate the values of nodes within. I want to have an if statement within a loop in Matlab to skip these. X Y if For example: X = [1:20] Y = [1:20] X = [5:7] Y = [12:14] I think the code should be something like this: for X=1:20 for Y=1:20 if X=2:7 & Y=12:14 return end % the operation here ! T(X,Y) = lab lab lab end end However, I'm not sure how to properly write the condition. 1 Answer 1 You could use ismember or a combination of any and == for the condition, and continue is the command for skipping to the next loop index... ismember any == continue % ismember example for X = 1:20 for Y = 1:20 if ismember( X, 2:7 ) && ismember( Y, 12:14 ) continue end % your loop...

Skip part of script on error

Skip part of script on error I've been banging my head against the wall for awhile on this one. No amount of Googling has yielded me any successful results thus far. Wondering if someone can give me a hand? # Load the PowerShell module for Active Directory Import-Module ActiveDirectory # For each computer in AD that is a member of the target group Get-ADGroupMember -Identity "CN=RenameComputer,CN=Users,DC=int,DC=example,DC=com" | ForEach { # Define the new name as the old one, minus one letter at the end $NewComputerName = $_.Name -replace ".$" # Perform the rename operation Rename-Computer -ComputerName $_.Name -NewName $NewComputerName -Force -PassThru -Restart -WhatIf # Remove the computer from the target group # THIS SHOULD NOT OCCUR IF THE RENAME ABOVE FAILED!!! Remove-ADGroupMember -Identity "CN=RenameComputer,CN=Users,DC=int,DC=example,DC=com" -Members $NewComputerName -WhatIf } TL;DR: Thi...