How to read only valid input

Hi!
I need to validate data. Users can enter either binary, hex, oct or decimal numbers but the program should check for two things length of the number and each digit that constitute the number. For example
the user could mix other chars in a binary number eg. 100g110 or they could do something like 4583y90 for decimal number. i need to check the strings like the one which would contain 100g110, and print error message and ask for another input, now when the user enters a new input i will have to check both of the things again the length and the valid character for that number type...please help...thanks in advance
speedOfLife

I think i got it. Or at least it shouldn't be wildly different than how I think the error should be checked. But, I wish there were an easier and more efficient way to do the same.
please take a look at how i am checking numbers.
I have two functions, they check string length and then check each and every digit to see if they are either (0 or 1) or not. These two functions are being called from the main and after the boolean results are returned from the functions...i m using a while loop to doulbe check if both of the boolean are true...if not then i m throwing error messages...so i mean to say...it works and i m happy but i hate to admit that it took over 6 hours of total time just to do a tiny thing...i wish there was something else i could do...because now i have to do the same kind of coding for hex, decima and octal...please have a look how i did for binary
static boolean getRightSize(String str)throws IOException{
          boolean ok1, ok2;
          ok1 = false;
          ok2 = false;
          long num;
           if (str.length()<=31 )
            ok1 = true;
          else
            ok1 = false;
     return ok1;
   }//end getRightSize()             
     static boolean getValidDigit(String str){
          boolean ok;
          int length = str.length() - 1;
          int l;
          ok = false;
           for ( l = 0; l <= length;  l++ ){
                 if( str.charAt(l) == 48 )
                  ok = true;
                else if(str.charAt(l) == 49 )
                  ok = true;                 
                else
                  ok = false;
           return ok;
     }//end getValidDigit()the main is four times conbined the codes above...which looks messy...
anyway...thanks a lot.
it is fun for me being a rookie...
later

Similar Messages

  • How many Read Only Cache Groups?

    How many Read Only Cache Groups we can createin in one DSN?
    I mean if e.g. 100 are possible?
    Thanks
    BR
    Andrzej
    Edited by: user8181100 on 2009-04-07 05:53

    As many as you like. There is no fixed upper limit.
    Chris

  • How to Read from Standard Input?

    Hi,
    I am new to Java. Been reading the tutorial, but still unable to find How to read from standard Input.
    Can anyone help? Thanks.
    Here is my simple & error code:
    public class test
    public static void main(String[] args)
    char filename[];
    int i=0;
    System.out.print("Type in a filename to read: ");
    while ( System.in(filename) != -1 )
    i++;
    System.out.print(filename);
    RP

    import java.io.*;
    public class forum{
         public static void main(String args[]) throws IOException
    InputStreamReader is = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(is);
    String input = "";
    do
    try
    System.out.println("Enter command: ");
    input = br.readLine();
    catch ( IOException io ) {}
    } while (!input.equals("exit"));
    [code\]
    package to import is java.io.*;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Ho to make a read only / disabled input text mandatory?

    Hi All,
    I'm using ADF to display data for a human task. Part of my requirement is to display a payload attribute as an output text/ read only input text. If this is null, the form should compel the user to choose from a list of values.
    How do I make an output text mandatory? Is there another way around this?
    I tried creating an input text and making it read only and mandatory, this doesn't work. Apparently, you cant make a disabled/read only input text mandatory?
    JDev : 11.1.1.4
    Thanks
    PP

    Hello! What does mandatory field mean for you? If there should be validation while saving, it will be: faces message will be shown with text, as it is defined in business rules in entity object. If you just wish to see blue “*” in front of label, just use “panelLabelAndMessage” component with “showRequired” property = “true”. If you wish to see some red frame around disabled field or button, if it has null value, I don’t know how to help you, but wish to know how to do that too.

  • How to read 2 analog inputs with VISA

    Hello everyone! I want to read two analog inputs using VISA serial communication from the arduino.  I'm currently able to read one of the input but how do I read two analog inputs on labview?

    Hi lamela,
    again I have to ask: HOW does the string look like? Is it so hard to provide an exact example of your received string???
    I think the string is showing one value from the two inputs
    Are you sure or are you guessing? How can we tell what you might "think" when you aren't able to provide examples?
    You wrote you send values from the Arduino using the command "println(value1, value2)", but now you "think" you only receive ""value1" in LabVIEW?
    Get your data communications clear! (And learn to provide meaningful examples!)
    Edit after your edit:
    my code to serial print two inputs: Serial.println(Voltage, Current);
    Even if I print separately: Serial.println(Voltage);
                                                 Serial.println(Current);
    The first command is completely different then the second part! In the first you should receive two values in one line, in the 2nd one you receive one value per line: You need to adapt your string parsing to these strings!
    Again: send both values in one line. Use the LF as termchar. Separate the values by some separator char like comma. Check the received string for validity. Use some error checking in your VI.

  • How enable read only access for ACS server itself

    Hi,
    We would like to know whether its possible to create a read only access to the ACS server. Currenlty ACS server has a generic login with full admin rights.
    We need to create a login to couple of users to log into ACS to check the "Report and Activity" tab. Access to all other tabs should be disabled.
    We are using ACS4.0 verison. Please let me know whether its possible.
    Thanks
    Nachi

    Hi,alexchy8
    We can make use of 2 PowerShell commands to achieve this goal.
    Add-MailboxPermission and Add-MailboxFolderPermission.
    Execute the Add-MailboxPermission command to delegate the read permission at mailbox level.
    Execute the Add-MailboxFolderPermission command to delegate the required permissions on specific folders inside the mailbox.
    You can read the following article as reference:
    http://www.exchangedictionary.com/articles/assign-read-only-mailbox-permission-on-exchange-2010-2013-powershell
    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety,
    or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.
    Best Regards.

  • How to read only particualr columns from excel sheet to internal table

    Hi,
    I have and excel sheet which has around 20 columns, in which i want to read only 6 columns. They are at different column positions, means the 1st column, 6thcolumn, 8th column so on..
    Can we do this in sap? do we have any FM to do this?
    Thanks.
    Praveena.

    hi,
    Use the below logic to fetch the data into internal table..You need to read the data cell by cell and update the internal table,
    DATA l_count TYPE sy-tabix.
       CONSTANTS: lc_begin_col TYPE i VALUE '1',
                  lc_begin_row TYPE i VALUE '2',
                  lc_end_col   TYPE i VALUE '2',
                  lc_end_row   TYPE i VALUE '3000'.
      CLEAR p_i_excel_data. REFRESH p_i_excel_data.
    * Function module to read excel file and convert it into internal table
       CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
         EXPORTING
           filename                = p_p_file
           i_begin_col             = lc_begin_col
           i_begin_row             = lc_begin_row
           i_end_col               = lc_end_col
           i_end_row               = lc_end_row
         TABLES
           intern                  = i_data
         EXCEPTIONS
           inconsistent_parameters = 1
           upload_ole              = 2
           OTHERS                  = 3.
    * Error in file upload
       IF sy-subrc NE 0 .
         MESSAGE text-006 TYPE 'E'.
         EXIT.
       ENDIF.
       IF i_data[] IS INITIAL .
         MESSAGE text-007 TYPE 'E'.
         EXIT.
       ELSE.
         SORT i_data BY row col .
    * Loop to fill data in Internal Table
         LOOP AT i_data .
           MOVE i_data-col TO l_count .
           ASSIGN COMPONENT l_count OF STRUCTURE p_i_excel_data TO <fs_source> .
           MOVE i_data-value TO <fs_source> .
           AT END OF row .
    * Append data into internal table
             APPEND p_i_excel_data.
             CLEAR p_i_excel_data.
           ENDAT .
         ENDLOOP .
       ENDIF .

  • How do I change permissions for West Dig USB HD, how said "read only" and can't use it.

    I have a West Did Hard drive from my PC that want to use on my Macbook.  Looking at the permissions said "read only".  I tried to move files on the drive and could not when attached to my Macbook.  Where do I change these settings that will allow me to use this drive.  Thanks for any help.
    This is my first Mac so do not know much about the Mac process, moving slow and steady.
    Donco

    Was this drive in use with a windows machine previously?
    If yes then I would guess that it is formatted as NTFS, Mac's can not write to NTFS discs.
    If you have sufficient space on your Mac copy the disk contents to a folder on your desktop and reformat the drive for use with Mac and Windows, then put the files back.
    Post back with some answers and I'll try to guide you through this

  • How do your restrict valid input into a JFormattedTextField

    Hi
    I'm interested in setting up a text box that only accepts a one or two digit integer value - so it would stop the user from inputting any character that wasnt a digit, and stop the user from inputting more than two digits - this must be something that is commonly done.
    Thanks, Dave

    Well, I'm confused by your question. JDK1.4 has a class called JFormattedTextField. I don't have JDK1.4 so I can't tell you how to use it, but from other posts I've seen on the forum I think it is something like:
    JFormattedTextField field = new JFormattedTextField( "##" );
    If you don't use JDK1.4 then you can create a custom Documents which will do what you need. The Swing tutorial on "General Rules for Using Text Components" will help:
    http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html
    http://java.sun.com/docs/books/tutorial/uiswing/components/textfield.html#validation
    The first link shows how to limit a document to 'x' character. The second on how to check for numeric values.

  • How to read only the most current records in PL/SQL

    Oracle version: 11.2
    I have a table in ORACLE called RATES and there is a EFFECTIVE_DATE, RATE_NAME, RATE_AMOUNT
    RATE
    1 RATE_ONE 1/1/2000 0.10
    2 RATE_ONE 5/1/2005 0.15
    3 RATE_ONE 12/1/2010 0.20
    4 RATE_TWO 10/15/2009 0.33
    5 RATE_THREE 9/7/2011 0.05
    6 RATE_THREE 12/31/2011 0.06
    A rate can be in there multiple times, but the most recent rate is the active rate. I need to query this table and only want to bring back the currently active rows:
    RECORDS 3, 4 and 6
    How can I do this in the most elegant way?
    Can I say:
    SELECT RATE WHERE trunc(sysdate) between EFFECTIVE_DATE and trunc(sysdate);
    (this will not work. I'm not sure how to do this without an exp date column and then I could say
    SELECT RATE WHERE trunc(sysdate) between EFFECTIVE_DATE and END_DATE
    The problem is that I cannot add that column at this time, so need to find a way to do it programatically
    Edited by: userLynx on Feb 1, 2012 8:56 AM

    Try This:
    WITH a
            AS (SELECT 'RATE_ONE' ratename,
                       TO_DATE ('1/1/2000', 'mm/dd/yyyy') eff_date,
                       0.10 amount
                  FROM DUAL
                UNION ALL
                SELECT 'RATE_ONE' ratename,
                       TO_DATE ('5/1/2005', 'mm/dd/yyyy') eff_date,
                       0.15 amount
                  FROM DUAL
                UNION ALL
                SELECT 'RATE_ONE' ratename,
                       TO_DATE ('12/1/2010', 'mm/dd/yyyy') eff_date,
                       0.20 amount
                  FROM DUAL
                UNION ALL
                SELECT 'RATE_TWO' ratename,
                       TO_DATE ('10/15/2009', 'mm/dd/yyyy') eff_date,
                       0.33 amount
                  FROM DUAL
                UNION ALL
                SELECT 'RATE_THREE' ratename,
                       TO_DATE ('9/7/2011', 'mm/dd/yyyy') eff_date,
                       0.05 amount
                  FROM DUAL
                UNION ALL
                SELECT 'RATE_THREE' ratename,
                       TO_DATE ('12/31/2011', 'mm/dd/yyyy') eff_date,
                       0.06 amount
                  FROM DUAL)
    SELECT ratename, eff_date, amount
      FROM (SELECT ratename,
                   eff_date,
                   amount,
                   RANK () OVER (PARTITION BY ratename ORDER BY eff_date DESC) rk
              FROM a)
    WHERE rk = 1

  • How to read only files with a certain format from folder with java

    I have this folder on the server and I only want to read files from this folder on the server... I only want to read files with the files format starting with error_ and ending with xml... an example of a file would be..
    error_123.xml
    I want something like this
    if(fileName.startsWith("error_") && fileName.endsWith(".xml")){
    but which java package will I have to use to read the file from the directory...

    Create an implementation of the java.io.FilenameFilter interface to match the pattern you need.
    Create a java.io.File object for the folder.
    Use the File.listFiles(FilenameFilter) method to get an array of File objects for the files in the folder that match the pattern.
    For each file in the array, create a FileInputStream, wrap it in an InputStreamReader, and wrap that in a BufferedReader (assuming you want to read the XML files as character streams).

  • WAD : 2 Queries in 2 tables : How to get only one input parameter ? :-(

    Hi,
    In my WAD Report, I've several tables ( each include a query result ). Those query have one variable ( which is a range of month ).
    How can I link the range of month to all my queries ?
    ( for the moment, the parameters(variables) screen display as much month variable as query )
    Thx,
    Regards,
    Erwan

    hi,
    u should use the same variable across all your queries.In the WAD there is a propoerty "display same variable once". Check that.
    hope it helps,
    regards,
    Parth

  • Input Help for Read Only Inputfield

    I have a requirement where an inputfield should be grayed-out so the user can't simply type whatever they want into the field.  However, the user should still be able to change the value of the inputfield via the input help (F4).  After searching around in the forums, I see that the only way to do this is to use a custom input help (as opposed to DDIC or OVS).  I've done that, and it works fine when the inputfield is open.  However, as soon as I set the inputfield to "Read Only", the input help button goes away.
    How do I get the input help button to stay even though the field is set to "Read Only"?
    Thanks,
    Tom Peng

    Hi,
    I have a requirement where an inputfield should be grayed-out so the user can't simply type whatever they want into the field.
    If the user shouldnot  enter the data what ever he wants in input field ,you can use foreign key check ,
    So that it throws an error message, when use enters the data   other than the values in F4 help.
    So  with out making  the field  read only  you can solve the problem.
    Priya

  • Help with read only text field

    trying to refine a KW form
    I don’t want user to enter value in a box so I made it read only.  $<input name="proptax" type="text" size="10" readonly="true">
    Validation says:
    "true" is not valid value for the "readonly" attribute in any of the currently active versions. See the above warnings for more details.[HTML 4.0]
    So now what?

    DW's validation gives me an error.  W3C  says it's ok.  I wonder why DW (v8) disagrees.
    Actually I 'disabled' the field instead which actually works better for me but they all behave the same,  errors in DW  and ok in W3C
    Thanks

  • System goes read only, after reboot all is fine for a day or two

    OK, so here's the problem, I got a new PC, all fanless, SSD hard and all.
    Works well for a day or so, then goes read only. For example - I come back from work, type something in the terminal and I get Input/Output Error. I cannot reboot, it says Input/Output Error as well.
    So I hard-reset it, it boots up, everything is fine again for a day or two.
    The HDD is Corsair CSSD-F40GB2, the MB is Gigabyte H55N-USB3, proc i3 540,
    The / and /home are both ext4 mounted with defaults,noatime,discard.
    I tried with/without discard.
    I also tried changing the SATA/power cables - same results.
    I also tried enabling/disabling features in BIOS like DMA/SMART/AHCI/compatibility stuff - same results.
    Here's a dmesg I managed to get (errors are near the end).
    http://pastebin.com/vJfdW90z
    And here's a smartctl -a /dev/sda:
    http://pastebin.com/eQxASEBM
    Any suggestions are welcome. Also is there some diagnostic app for Corsair SSD that I can run and check the drive?
    Cheers.

    Well I don't recall how freshly booted, it was the only time that the system was read-only - giving input/output error to everything but dmesg was working so I saved it all to pastebin.
    The system is a PC so I never tried anything else different from poweroff/reboot (works fine).

Maybe you are looking for

  • Help: iTunes freezes when I try to change the music folder location

    Hi everyone, I want to change my iTunes music folder location but every time I click on the change button (Edit > Preferences > Advanced > Change) iTunes freezes. All of my music is in an external drive and I recently reinstalled windows, so I had to

  • Accordion issues in IE 6&7

    I'm having an issue with the accordion where the items open underneath the top panel in IE. The top panel stays open and the subsequent panels reveal underneath. Everything works fine in Safari and FF, but surprisingly IE isn't rendering the same. ht

  • Coloring a table cell with swing

    Hello, I am trying to write a java program in swing. Basically I am setting up a table and adding labels to the table's cells. Rather than displaying the label, the table is inserting the labels' string value. Here is a compilable example: import jav

  • Asset value adjustments.

    Hi Gurus, i have a problem in asset accounting. one of my user did GR wrongly so i need to transfer the asset vlaue to correct asset. the Gr was done in 2008 Dec. as the posting periods were already closed iam doing asset transfer in 2009. first i wr

  • Hide refresh from UWL tray menu

    How can I hide the "Refresh" link from the UWL inbox tray menu?  The refresh link that I'm referring to is along with other links like "manage substitution rules, personalize view, Display connection status". Thanks Praveen