Jump to content
Search In
  • More options...
Find results that contain...
Find results in...


  • Content count

  • Joined

  • Last visited


About C30N9

  • Rank
    Senior Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Single Status Update

See all updates by C30N9

  1. ... And this is crazy
    But here's the code
    So give suggestions, ideas, feedback, thoughts, maybe?

    Anyways, I need help in several things:
    - How do I put limits for inputs to one kind of variables?
    - How do I convert variables? (Integers to Strings and vice-versa)

    1. Show previous comments  3 more
    2. C30N9


      Thanks fraggle, was looking forward to show it to you.

      I will go with the goto advice, that is when I find a way using a loop instead.

      BTW, could you please answer the first question?

    3. Maes


      C30N9 said:

      BTW, could you please answer the first question?

      Either you create do...while loops for each variable that you are trying to input (quite honestly, a PITA) or you create a specific function for filtering numeric input, which handles the looping and user messaging. Parameter to include are the acceptable value range, customized entering/error messages, and you simply call that function whenever you need a filtered numerical user input with some specific message, rather than writing ad-hoc code all the time.

      Other less interactive solutions are automatically assuming some "default" value upon a wrong input, or exiting the problem.

    4. fraggle


      C30N9 said:

      - How do I put limits for inputs to one kind of variables?

      Inputs just give you a string; it's up to you to interpret what's in that string. If the user enters something that isn't in the form you want (eg. a number) then you need to prompt them to enter it again until they get it right. So what Maes says is correct: you need a loop that keeps reading input until it gets what it wants.

      This is a great example of how you can split up your code into smaller functions: think about how you'd write and use a function like this: