The worst programmer ever to grace this forum - ME!


Results 1 to 40 of 50

Threaded View

  1. #37
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    ok, I've kludged it...but there's *got* to be an easier way than this...


    'set up some variables....

    turns_required VAR BYTE[3] ; the main input
    UNITS VAR BYTE ' will use this to extract units from above
    TENS VAR BYTE ' will use this to extract tens from above
    HUNDREDS VAR word ' ' will use this to extract hundreds from above
    TURNS_INPUT VAR WORD ' this will be used for the final goal - a useable number!!

    pause 200 ' let things settle down a bit

    HSEROUT ["Enter Number of turns required (3 digits + leading 0)>>>", 13,10] 'prompt for input.

    Main
    HSERIN 5000,finish,[WAIT("0"),STR turns_required \3] 'read in a 3 character string preceded by a '0'
    UNITS = turns_required(2) - 48 'extract the last character (units) & revert it down to a true decimal
    TENS = (turns_required(1) - 48) * 10 'extract the middle character (tens) & revert it down to a true decimal
    HUNDREDS = (turns_required(0) - 48) * 100 ''extract the first character (tens) & revert it down to a true decimal

    TURNS_INPUT = UNITS + TENS + HUNDREDS ' add them all together.



    Using the above, I've turned my keyed in '3 character ASCII code' based string into its numeric equivalent, (that I can use later in the PIC program) ...but like I say, there's got to be an easier way?
    Last edited by HankMcSpank; - 21st May 2009 at 22:32.

Similar Threads

  1. Melabs U2 Programmer Command Line Options
    By Robert Wells in forum General
    Replies: 5
    Last Post: - 3rd July 2009, 02:11
  2. problems with USB programmer
    By malc-c in forum General
    Replies: 7
    Last Post: - 10th May 2007, 20:14
  3. USB programmer problems
    By uiucee2003 in forum USB
    Replies: 2
    Last Post: - 15th August 2006, 23:47
  4. General Programmer Questions
    By mslaney in forum General
    Replies: 1
    Last Post: - 17th December 2004, 18:16

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts