java - Need to input four numbers and output a formatted list

07
2014-07
  • Chris

    I've got a handwritten list of about 500 coordinates for sprites on a sprite map in the form X1 Y1 Width Height

    I need them outputted into a table with format {X1, Y1, X1+Width, Y1+Height}

    I would like to make a VBA macro or something similar to input these numbers with just spaces between and the macro does the math and places them into a table with the above format for me - squiggly brackets included. Also, the table needs to be five coordinate sets wide before it drops down to a new row.

    I started out trying to input the four numbers into a VBA input box, but apparently input boxes can only take one variable at a time. Having four separate input boxes pop up every time would drive me crazy and not save much time in the long run, so I need a new solution.

  • Answers
  • Brad Patton

    How about entering them into a spreadsheet? You could have the x values in one column, the y in another, etc. Then in another column write a formula to combine them and output the format you want.

    For example if you had a table like:

    X   Y   Width   Height  Co-ords
    3   4   21      13      {3, 4, 24, 17} 
    2   6   78      45      {2, 6, 80, 51}
    

    You could generate the Co-ords column with the following formula:

    =CONCATENATE("{", A2, ", ", B2, ", ", (A2 +C2), ", ", (B2+D2), "}")
    

    You can enter this in E2 and then fill down to apply to all cells in that column.


  • Related Question

    What type of barcode scanner do I need to access scanner output in Java app?
  • sala_7

    For my project I need to scan barcodes and save them in a database.

    I thought about doing this by running a Java app in the background that listens to the port used by the scanner and saves the output of the scanner to the database.

    My resources are very limited and I would like to know if I need a special type of scanner for this task. This is the cheapest scanner I found in ebay. Is it valid for this task? Otherwise, what type of scanner should I look for?

    Please guide me


  • Related Answers
  • gbroiles

    Most barcode scanners meant to be used with PC's will plug in and act like keyboards. They provide the scanned information as if it had been typed at a keyboard by a user.

    So, chances are there's no special "port used by the scanner" and it won't make a difference for this purpose what scanner you choose - you can write a simple app that accepts input from the user and stores it in the database.

    You'll want to make sure that the barcode scanner can read the barcodes you're working with, and make sure that the distance from the barcode and scanning speed are appropriate for your application.