Conditional operator question?

Hello,
Quick question, are we not allowed to use the conditional operator this way... see code below:
char volatile ProgString_[] = "\
{Fan code} \
12 <Limit11> [C1_ACM2]_[B1] _AND_ \
bla bla \
unsigned char UPC_SYSZ_EndOfTable(unsigned long i){ // Find the double '*' in string
char volatile *u;
u = &ProgString_[i];
if(!(strncmp("*", u, 1))){
i++;
u = &ProgString_[i];
if(!(strncmp("*", u, 1))){
return TRUE;
else {
return FALSE;
else
return FALSE;
void UPC_SYSZ_Parse(){
unsigned char volatile iOCntr = 0;
unsigned long volatile i;
for(i=0; i<200; i++){
(UPC_SYSZ_EndOfTable(i))?(break):(continue); //<<<<< Invalid expression ??
I would of used the following compact line:
(UPC_SYSZ_EndOfTable(i))?(break):(continue);    //<<<<< Invalid expression ??
to periodically test the end of the string by fetching the "EndOfTable() function and evaluating if the double star is detected.
If detected, I would break out of the for loop, if not then I would continue.
Is it possible to do it this way?
thanks for all help!
r

Think of it along the lines of each of the operands of the ternary operator must produce a value (which of course break and continue being statements cannot do).
Based on your brief example here is what I would do
for(i=0; i<200; i++){
if (UPC_SYSZ_EndOfTable(i)) break;
// doesn't make any sense to put more code down here anyway, so no real point to continue}

Similar Messages

  • Powershell equivalent of a conditional operator?

    Hi,
    I've got a small snippet of Powershell code that works perfectly well, but I'd like to make it better. here it is:
    if ($discoveredIssues.Length -gt 0){
    $returnHash += @{"IsBatchValid"=$false}
    else{
    $returnHash += @{"IsBatchValid"=$true}
    I don't like the fact that the string literal "IsBatchValid" exists in two places as there's always the chance that someone could change it one place and not the other (very minor quibble, I know).
    I was wondering if there was a way to write this such that I don't have the if...then...else. I tried to do this:
    $returnHash += @{"IsBatchValid"={if ($discoveredIssues.Length -gt 0){$false}else{$true}}}
    but that doesn't work. It just returns "if ($discoveredIssues.Length -gt 0){$false}else{$true}}" rather than the actual result of that expression. I was hoping there might be something like C#'s conditional operator so that I could do something
    like this:
        $discoveredIssues.Length -gt 0 ? $false : $true
    but sadly not.
    Any ideas how I can achieve this? I suspect there isn't a way, but it'd be nice if there were.
    thanks
    Jamie

    $returnHash.IsBatchValid = $discoveredIssues.Length -gt 0
    Oh nice. Didn't quite work. Powershell ISE complained:
    But it prompted me to go away and change it to this:
    $returnHash += @{"IsBatchValid"=$discoveredIssues.Length -eq 0}
    which I suppose would have been obvious had I bothered to pay any attention to what I was doing. Always pays to have someone else put eyes on something. thanks mjolinor.
    Glad to help.
    It wasn't obvious from the code whether $returnHash already exists or not.  I was assuming it did:
    $returnHash = @{}
    $returnHash.IsBatchValid = $discoveredIssues.Length -gt 0
    $returnHash
    Name Value
    IsBatchValid False
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • Conditional Operator for Popup Pages!!

    Hi All,
    In my application there are 2 two different pages say 85 and 45. In page 85 i am calling the Iframe in which it will redirect to page 45. Now in that page i.e 45 i have used template as popup. In that i have an IR and HTML regions and a button in IR region. when i click on button then only should show the HTMl Region for that i ahave used conditional operator. But that is not working!!
    So i would like to know wheather conditional will work popup pages. If not let me know the procedure for that!!!!
    Thanks,
    Anoo..

    .. Apart from that, there is no need for your original long list of "if .. else". For a list of possible inputs, you should consider something like this:
    switch(myYear.selection.text)
    case "10": yearSelect=0; break;
    case "11": yearSelect=1; break;
    case "12": yearSelect=2; break;
    case "13": yearSelect=3; break;
    case "14": yearSelect=4; break;
    default: yearSelect=5;
    or, with your input and output, something as simple as
    yearSelect = Number(myYear.selection.text)-10;
    -- but I don't know what your possible range of inputs is. If it's "anything goes", you have to check for a not-in-range and then set it to your default of 5.

  • Conditional operator and nulltype

    hi,
    i have a little problem, it's actually not really a problem, im just curious. i have the following testclass
    public class Test{
      public static void main(String[] args) {
        Double a = false? 1.00: (Double)null; // nullpointer (A)
        Double b = false? 1.00: null;  // works (B)
    }when line (A) is uncommented a NullPointerException is thrown and i have no idea why.
    when i comment out line (A), line (B) works. because the type of the conditional operator is of the other if one of them is NullType.
    so not really a problem because it's better to use (B) but i still want to know why (A) doesn't work.
    Edited by: creichlin on Oct 27, 2008 12:15 PM

    ouch, i am just to stupid. i forgot autoboxing, the NullType is cast to a null Double, then it's autoboxed to a double and then to a Double again.

  • Conditional Operator for else if?

    I used the google compiler on one of my scripts. It worked fine except I am getting hung up on some of the conditional statements it made. Originally I had a series of if else if statements. When changed to Conditional Operator it changes the fuctionality of it. Here we go if anyone can help I will take any tips.
    My version:
    if(myYear.selection.text=="10"){yearSelect=0;}
             else if(myYear.selection.text=="11"){yearSelect=1;}
             else if(myYear.selection.text=="12"){yearSelect=2;}
             else if(myYear.selection.text=="13"){yearSelect=3;}
             else if(myYear.selection.text=="14"){yearSelect=4;}
            else{yearSelect=5;}
    Google version:
    yearSelect="10"==b.selection.text?0:"11"==b.selection.text?1:"12"==b.selection.text?2:"13"==b.selection.text?3:"14"==b.selection.text?4:5,
    Thanks in advance for any advice.
    Brett.

    .. Apart from that, there is no need for your original long list of "if .. else". For a list of possible inputs, you should consider something like this:
    switch(myYear.selection.text)
    case "10": yearSelect=0; break;
    case "11": yearSelect=1; break;
    case "12": yearSelect=2; break;
    case "13": yearSelect=3; break;
    case "14": yearSelect=4; break;
    default: yearSelect=5;
    or, with your input and output, something as simple as
    yearSelect = Number(myYear.selection.text)-10;
    -- but I don't know what your possible range of inputs is. If it's "anything goes", you have to check for a not-in-range and then set it to your default of 5.

  • NEED HELP:To Parse Conditional Operator Within An Expression.

    Hi there:
    I'm having some difficulties to parse some conditoional operator. My requirements is:
    Constants value: int a=1,b=2,c=3
    Input/Given value: 2
    conditional operator expression: d=a|b|c
    Expected result: d=true
    Summary: I like to receive a boolean from anys expressions defined, which check against Input/Given value.Note: The expression are various from time to time, based on user's setup, the method is smart enough to return boolean based on any expression.
    Let me know if you have any concerns.
    Thanks a million,
    selena

    here is a simple example.
    BNF changes
    EXPR ::= OPERATOR
    EXPR ::= OPERATION OPERANT EXPR
    This is as far as I can go, please use it as a template only
    because you need to take into account the precedence using ()
    the logic of the eval was simply right to left so I think it is not what you want
    Cheers
    public interface Expression
         String OR = "|";
         String AND = "&";
         public boolean eval(int value) throws Exception;
    public class ExpressionImpl implements Expression
         public String oper1;
         public String operant;
         public Expression tail;
         /* (non-Javadoc)
          * @see parser.Expression#eval()
         public boolean eval(int value) throws Exception
              int val1 = getValue(oper1);
              if (null == tail)
    System.out.println(val1 + ":" + value);               
                   return (val1 == value);
              else
                   if (OR.equals(operant))
                        return (val1 == value || tail.eval(value));
                   else if (AND.equals(operant))
                        return (val1 == value && tail.eval(value));
                   else
                        throw new Exception("unsupported operant " + operant);
         private int getValue(String operator) throws Exception
              Integer temp = ((Integer)Parser.symbol_table.get(operator));
              if (null == temp)
                   throw new Exception("symbol not found " + operator);
              return temp.intValue();
         public String toString()
              if (null == operant) return oper1;
              return oper1 + operant + tail.toString();
    public class Parser
         public static HashMap symbol_table = new HashMap();
          * recursive parsing
         public Expression parse(String s)
              ExpressionImpl e = new ExpressionImpl();
              e.oper1 = String.valueOf(s.charAt(0));
              if (s.length() == 1)
                   return e;
              else if (s.length() > 2)
                   e.operant = String.valueOf(s.charAt(1));
                   e.tail = parse(s.substring(2));
              else
                   throw new IllegalArgumentException("invalid input " + s);
              return e;
         public static void main(String[] args) throws Exception
              Parser p = new Parser();
              Parser.symbol_table.put("a", new Integer(1));
              Parser.symbol_table.put("b", new Integer(2));
              Parser.symbol_table.put("c", new Integer(3));
              Parser.symbol_table.put("d", new Integer(4));
              Expression e = p.parse("a|b|c&d");
              System.out.println("input " + e.toString());
              System.out.println(e.eval(2));
    }

  • What is the conditional operator for AND, OR .....?

    what is the conditional operator for AND, OR .....? in ABAP language...
    AND, OR .. & is not accepting or recognising.
    Is these feature available in abap ??? if yes, how to use?
    thanks...
    shiva

    Hi,
    Conditional operator for AND and OR are same AND and OR.
    A logical expression consists of comparisons (see expressions 1 to 4 below) and/or selection criteria checks (expression 5) using the operators AND, OR and NOT , as well as the parentheses " (" and ")".
    The individual operators, parentheses, values and fields must be separated by blanks:
    Incorrect:
    f1 = f2 AND (f3 = f4).
    Correct:
    f1 = f2 AND ( f3 = f4 ).
    NOT takes priority over AND, while AND in turn takes priority over OR:
         NOT f1 = f2 OR f3 = f4 AND f5 = f6
    thus corresponds to
         ( NOT ( f1 = f2 ) ) OR ( f3 = f4 AND f5 = f6 )
    The selection criteria comparisons or checks are processed from left to right. If evaluation of a comparison or check proves part of an expression to be true or false, the remaining comparisons or checks in the expression are not performed.
    All data objects that can be converted among each other can be used as operands for logical expressions.
    Check if u are using the AND or OR operator this way.
    IF f1 AND f2.
    ENDIF.
    In this case it will throw error. Here it act as relational operator.
    Regards,
    Prakash

  • SSRS Using Sum and = in a conditional operator

    Hi,
    Still getting to grips with SSRS so any help would be appreciated.
    My aim is to calculate a conditional field using the SSRS expression feature, the datasource is a shared dataset which i can't alter so i can't just go an alter the SQL query or anything.
    In SQL my query would be like this: SELECT COUNT(TotalHours) FROM TableName WHERE TotalHours <= 24
    Is there anyway to combined the Iff and Sum operator's to get a result like the above?
    At present all i managed to come up with is the below but obviously it's not returning the correct amount.
    =IIf(Fields!TotalHours.Value <= "24", Sum(Fields!TotalHours.Value), 0 )
    Please help!
    Edit: Please note that i'm not trying to sum a field based on a condition that relates to another column, i just need a sum of 'TotalHours' that are less than or equal to 24, please also note there is another field called category, each category needs a
    sum of the above.
    Regards,
    Marcus
    Plain_Clueless

    Hi Marcus,
    According to your description, you want to count [TotalHours] when the value of this field is less than 24, right?
    In your scenario, you could use the expression like below:
    =Sum(IIF(Fields!TotalHours.Value<=24,1,0))
    Please note don’t put this expression in the detail rows, you could refer to our test results:
    If you have any question, please feel free to ask.
    Best regards,
    Qiuyun Yu
    Qiuyun Yu
    TechNet Community Support

  • Multiple condition checking question

    Hi I have a newbie question -
    if ((temp == null) && (!temp.text.equals(""))) {
    statement;
    If temp really is null, would this give a compiler error? or would it simply break after the first condition?
    Thanks,
    Mike

    whatsupdoc wrote:
    Hi I have a newbie question -
    if ((temp == null) && (!temp.text.equals(""))) {
    statement;
    If temp really is null, would this give a compiler error?Compile it and see.
    I'm curious though what you're trying to accomplish. You seem to be confused about the meaning of &&.
    or would it simply break after the first condition?&& and || are "short-circuit" operators. They stop evaluating once the truth of the operation is known. So if the first operand to && is false, it stops there and does not evaluate the second, since the result of the && must be false, regardless of what the second operand is. Likewise, if the first operand to || is true, then it doesn't evaluate the second one, because the result is true regardless.

  • Save As operation Question

    Scenario - I have a web application that generates Excel documents that can be downloaded or opened directly. The web pages are a mixture of both ASP.NET and Classic ASP so the Excel file is actually generated as an HTML table. When a Save or Save As operation
    is done when the .xls file is downloaded a specified file name passed from the web page is used in the save operation. When you open the Excel file after saving Excel displays "The file you are trying to open "filename.xls" is in a different
    format than specified by the file extension...Do you want to open the file now?" informing me that the file is not a true xls file. When you continue with the opening the file it opens normally with no issues.
    Question or Possible issue: Taking one of these files after it has been saved to a location on the computer outside of the download folder, and perform a Save As operation to change the format to a true .xls file the theExisting File Name is not displayed in
    the File Name field. The Save as type defaults to Web Page which is understandable due to how the file is generated.
    I've tried this with actual Excel spreadsheets and the File Name field on the Save As operation is populated with the current name of the file and keeps it even if you change the Save as type.
    Main Question: Is there a setting somewhere in Excel to prevent the loss of the File Name?

    Hi,
    According to your description, the "The file you are trying to open "filename.xls" alert is from a feature called Extension Hardening, and you can find more information about it here. 
    http://blogs.msdn.com/b/vsofficedeveloper/archive/2008/03/11/excel-2007-extension-warning.aspx
    As you said and tested, Excel will retain the current file name in file name field when we save/save as the file. It's a default behavior. I suppose that the issue may be caused by the Excel that generated by web application.
    I recommend we try the 3 workarounds:
    1. Modify the ASP.NET program and make the file change to new excel format when generated
    Please see the thread:
    http://stackoverflow.com/questions/940045/how-to-suppress-the-file-corrupt-warning-at-excel-download
    2. Use "Office Migration Planning Manager" to convert the XLS to XLSX format.
    The toolkit also contains the Office File Converter (OFC), which enables bulk document conversions from binary to OpenXML formats. 
    Overview on Technet
    Download Link
    3. Use a macro to convert batch of XLS file to XLSX file and retain the file name.
    Sample code:
    Sub ProcessFiles()
    Dim Filename, Pathname, saveFileName As String
    Dim wb As Workbook
    Pathname = "C:\Users\myfolder1\Desktop\myfolder\Macro\"
    Filename = Dir(Pathname & "*.xls")
    Do While Filename <> ""
    Set wb = Workbooks.Open(Pathname & Filename)
    saveFilename = Replace(Filename, ".xlsx", ".xls")
    wb.SaveAs Filename:=Pathname & saveFilename, _
    FileFormat:=xlExcel8, Password:="", WriteResPassword:="", _
    ReadOnlyRecommended:=False, CreateBackup:=False
    wb.Close SaveChanges:=False
    Filename = Dir()
    Loop
    End Sub
    Regards,
    George Zhao
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • Related to conditional operator

    hai SDNs,
    in select stmt or delete stmt in where clause i have condition like this:
    need the somes values based on condition "A" is in the range 10 - 1000.
    how to write it in where clause...
    what is the operator or any alternative???
    thanking you,

    You should use BETWEEN operator OR you can use RANGES / SELECT-OPTIONS if you are writing this in ABAP.
    SELECT * FROM MARA WHERE MATNR BETWEEN '1' AND '10000'.
    T_RANGES-SIGN = 'BT'.
    T_RANGES-OPTION = 'EQ'.
    T_RNAGES-LOW = '1'.
    T_RANGES-HIGH = '1000'.
    APPEND T_RANGES.
    SELECT * FROM MARA WHERE MATNR IN T_RANGES.
    Regards,
    Ravi
    Note : Please mark all the helpful answers

  • The Shift operator Question

    Dear sir/madam
    I having question for the shift operator.
    What different between >>> and >> ?
    I have refer to sun tutorial, it state >>> is unsign, what does it mean?
    and last is
    if integer is 13
    what anwer for 13>>8
    is it move for 8 right by position? pls told me in detail
    is it answer same with the 13>>>8 ?
    Thanks for ur solutions

    You can play with the following for a while.
    final public class BinaryViewer{
      final static char[] coeffs = new char[]{(char)0x30,(char)0x31};
    public static String toBinary(int n) {
      char[] binary = new char[32];
      for(int j=0;j<binary.length;j++) binary[j]=(char)0x30;
      int charPointer = binary.length -1;
      if(n==0) return "0";
      while (n!=0){
          binary[charPointer--] = coeffs[n&1];
          n >>>= 1;
    return new String(binary);
    public static void print(int n){
        System.out.print(BinaryViewer.toBinary(n));
        System.out.print("   ");
        System.out.println(String.valueOf(n));
    public static void main(String[] args) throws Exception{
       int n=Integer.MIN_VALUE;//Integer.parseInt(args[0]);
       int m=Integer.MAX_VALUE;//Integer.parseInt(args[1]);
       BinaryViewer.print(n);
       BinaryViewer.print(n>>8);
       BinaryViewer.print(n>>>8);
       System.out.println();
       BinaryViewer.print(m);
       BinaryViewer.print(m>>8);
       BinaryViewer.print(m>>>8);
      System.out.println();
        n=1024;
        m=-1024;
       BinaryViewer.print(n);
       BinaryViewer.print(n>>8);
       BinaryViewer.print(n>>>8);
       System.out.println();
       BinaryViewer.print(m);
       BinaryViewer.print(m>>8);
       BinaryViewer.print(m>>>8);
      System.out.println();
       n=2048;
       m=-2048;
       BinaryViewer.print(n);
       BinaryViewer.print(n>>8);
       BinaryViewer.print(n>>>8);
       System.out.println();
       BinaryViewer.print(m);
       BinaryViewer.print(m>>8);
       BinaryViewer.print(m>>>8);
      System.out.println();
    }

  • Range Operator Question

    Hello all,
    I asked a question yesterday under the title of "Range
    Operator for first 2 letters of item" which was answered promptly and was much appreciated. I have since encountered another problem and would like another example if possible.
    How would I search for all folders under C:\ that start with "Commercial_Global_Trading" through the end of all folders that start with "C"? Can I use a Range Operator for this as well?
    Hopefully it makes sense what I'm asking!
    Thanks!

    Yes it is a bit confusing. Maybe an answer from my previous post will help clear up what I'm asking:
    Using range operators, we can get folders that start with A, B, and C by saying:
    get-childitem 'C:\Folder\[a-c]*'
    We can also get folders that start with Aa, Ab, and Ac by saying:
    get-childitem 'C:\Folder\A[a-c]*'
    What I'm wondering is, is there a way to get all folders in a range, beginning with a specific
    word and then continue through the rest of the range? For example:
    The folder C:\Folder contains the following 6 folders:
    Account
    Commercial
    Commodity
    Commodity_Product
    Conduct
    Finance
    How would I use range operators in get-childitem to return the folders that start with Commodity, and then continue on through the rest of the C's? So the output would be the folders Commodity, Commodity_Product, and Conduct. The folder "Commercial" would
    be excluded from the output. Is this possible using Range Operators and Get-ChildItem?

  • CWMS 1.5 Operational Questions

    Hello All:
    I am looking for some help with my new CWMS 1.5 system.  I have several problems listed below.  If the features aren't in the current release, I am interested if they might be planned for an upcoming release.
    1.  How do you delete a user or a mis-typed email address?
    2.  How do you delete the branding logo?  We uploaded a logo but can't find a way to set it back to default.
    3.  How do you restrict some people to WebEx with desktop sharing and others to just personal audio conference calls?  Looking for some sort of class of service capability.  Might want to also allow Mobile and other features by class as well. 
    4.  How do you generate a report of the Userids, pins, and host/moderator numbers assigned? 
    5.  How do you turn off email notifications?  We want to load a large list of users but when we do it sends everyone an email.  We are trying to stage the system and get ready for testing.
    6.  Is there a way to allow someone from our Service Desk to act as an operator on a call that would be able to mute a line?  Looking for some sort of BigBrother capability.  Should have full access to someones account and all active conference calls.
    7.  Is there a way to get a report of what numbers were dialed?  Looking to determine number of internal versus external callers.
    8.  Why is public access required for IOS functionality?  The IPAD or IPHONE can be on the company local network or connected with a VPN connection.  We don't have IRP installed but IOS should still work.

    Hello David,
    Let me answer some of your questions:
    1. You cannot delete a user profile. If you mis-typed an e-mail address, all you can do is DEACTIVATE the profile. The behavior is the same as in WebEx SaaS.
    2. At this time there is no supported way to delete the company logo using GUI. I am sure there is a way to remove it via CLI, but you would need TAC assistance for this.
    3. At this time, it is not possible to differentiate privilege levels on per user bases. Any changes to capabilities is done on per system basis.
    4. All the available reports are found in the Reports section. There is no such a report that you are looking for. Only available reports that come within Customize Your Report are:
    UserLicenseUtilizationReportForThisMonth.csv
    UserLicenseUtilizationReportForLastMonth.csv
    SystemDowntimeReport.csv
    NetworkBandwidthUtilizationReport.csv
    MeetingReport.csv
    FraudAttemptsReport.csv
    5. At this time, if you are importing users via CSV file, only if you mark the user as INACTIVE during the import (in a csv file under column ACTIVE you mark N for the user profile) the system won't send an e-mail. Once you mark the user as ACTIVE, the system will e-mail the end user.
    6. At this time, only host of the meeting can perform those actions within the WebEx Meeting Room.
    7. There is no such a report in CWMS.
    8. I cannot provide you an answer for this question as this is rooted in product design. Mobile devices require IRP server to be able to join meetings on CWMS.
    I hope any of these answers will help.
    -Dejan

  • Modulus Operation Question

    The code below prints out
    Answer 5 %3 = 2
    Answer 8 %3 = 2
    whether or not the inner if statment expression is (i % 3 == 0) or (i % 3 ==1). If the inner if statment expression is (i % 3 ==2 ) nothing prints out. Yet I would expect since 5 % 3 = 2 then the code should throw exception E2.
    My question is why does this work the way it does?
    public class TestMod {
         public static void main(String[] args) {
              for(int i =0; i < 10; ++i) {
                   try {
                        if(i % 3 == 0 ) {
                             throw new Exception("E1");
                        }else{
                             try{
                                  if( i % 3 == 1 ) throw new Exception("E2");
                                  System.out.println("Answer " + i + "  %3 = " + (i%3));
                             }catch (Exception inner){
                                  i *= 2;
                             }finally {
                                  ++i;
              }catch (Exception outer){
                   i += 3;
              }finally {
                   ++i;
         }//end for
         

    The try and catch blocks are throwing me all around
    that even in debug mode I am confused about how the
    code (i % 3 ==0 ) is true when i = 5.I don't blame you for being confused, because your code is utterly confusing. But trust me, your code is not confusing enough to confuse the JVM, and (i % 3 = 0) is not true when i = 5.
    Look, the first time through the loop i = 0. (0 % 3) == 0, so the "E1" exception is thrown. In the catch-block for that exception you add 3 to i, making it 3. Then the outer finally-block adds 1, making it 4.
    The second time you enter the loop, 1 is added to i, making it 5. (5 % 3) is not 0 or 1, so no exception is thrown and you print out the "Answer..." line. Then the inner finally-block adds 1 to i, making it 6. Then the outer finally-block adds 1 to i, making it 7.
    The third time you enter the loop, 1 is added to i, making it 8. As the previous time, (8 % 3) is not 0 or 1, so again you print out the "Answer..." line. Then the each of the two finally-blocks adds 1 to i, making it 10.
    Since the loop condition (i < 10) is now false, the loop will break, and your program is done.

Maybe you are looking for