Announcement

Collapse
No announcement yet.

Input without prompt?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Input without prompt?

    I am oversimplifying this in interest of keeping this short, but
    I seem to recall a method of imputting wihtout prompts, at
    least in QB.

    If I had separate programs to add two numbers, multiply two
    number, subtract, two numbers, and divide two numbers, and a
    "Controller" program, can I make use of SHELL without displaying
    the prompt and still see the answer?

    I.e., for example
    ' Routine to ADD two numbers
    :'Get, Read, or input 2 numbers, called No1, and No2
    X = No1 + No2
    print "The result is "; X
    print "Press any key."
    End


    :'Control program
    Print "Give me a number: ";:input A
    Print "Give me another number: ";:input B
    Print "What do you want to do? Your choices are:"
    print "1> Add 2> Subtract 3> Multiply, 4> Divide"
    Input Optn
    select case Optn
    Case 1
    Filename$ = "C:\Math\Add.exe"
    DoThis$ = Filename$+" "+A+" "+B
    Shell Dothis$
    Case 2
    Filename$ = "C:\Math\Subtract.exe"
    DoThis$ = Filename$+" "+A+" "+B
    Shell Dothis$
    Case 3
    Filename$ = "C:\Math\Multiply.exe"
    DoThis$ = Filename$+" "+A+" "+B
    Shell Dothis$
    Case 4
    Filename$ = "C:\Math\Divide.exe"
    DoThis$ = Filename$+" "+A+" "+B
    Shell Dothis$
    Case else
    Print "Hmmm, something wrong happened."
    Print "Ask your teacher. I am patient,"
    Print "I will wait for you!!"
    End select

    Again, I oversimplified this, but that is ok. My inquiry is
    how do I pass that value to a SHELL command so the shelled
    program will accept it?

    Thank you.

    Robert

    ------------------

  • #2
    robert,

    if you want to pass multiple parameters to a shelled program use
    the command$ function.

    for instance, in your example, the program doing the actual calculations (the one you shelled to) would need to capture any
    arguments on the command line using command$. since you want to pass more than one argument, have a look at the post near the bottom of this link.
    http://www.powerbasic.com/support/pb...read.php?t=683

    it gives an example of parsing multiple arguments from the command line.

    then, in the calling program, you would just build the correct string to pass to shell. something like:

    Code:
    print "enter a number: ";
      lineinput, num1%
    print "enter a second number: ";
      lineinput, num2%
    
    filename$ = "c:\math\add.exe"
    
    shell filename$ + " num1%" + " num2%"
    the delimiters between your argument can be just about anything; a space, comma, or "+" sign as in your example. just study the parse$ routine in the link and make adjustments in your own code.

    hope this helps!

    -michael.

    ------------------




    [this message has been edited by michael k. dealey (edited may 01, 2003).]

    Comment


    • #3
      Robert,

      I cannot answer you question directly, as I do not have experience
      in that area, but, if you need something that will parse a string
      (break into individual strings, with one character being used
      as a delimiter), refer to my recent posting in the Source Code
      Forum concerning the function "32-bit Version Of QPP's ParseString".
      You cannot use that code directly because it is 32-bit, not 16-bit.
      However, my point is that I also have created for myself a 16-bit
      version that is in a self-contained OBJ file that can be $LINKed
      into your PB/DOS program. So, if you want to take it for a test
      drive, send me an e-mail to the adx, below and I'll attach it to
      a reply e-mail. Note that the attachment will be have a .ZIP
      extension, to make it less likely that any anti-virus software you might
      be running will refuse it.

      <e-mail address deleted - no longer needed>

      Note to PB, Inc. Staff: I do not write my own versions of the QPP
      procedures because of ANY dissatisfaction with that library - I do it
      because: (1) I prefer to roll my own (2) I detest having to rely
      on third party software if I do not have to (3) and, MAINLY, so I can
      LEARN. Also note that, when I write my own versions of what I used
      to use in the QPP library (I have not used QPP for a LONG time),
      that I do NOT steal code from the QPP ASM files - the ONLY reason
      I might reference a particular ASM file is to find out which DOS
      INT/service to use to accomplish a certain task - but all of my
      code that I then write is TOTALLY my own. I find the ASM files much
      faster to use than having to wade through Ralf Brown's Interrupt List
      to find my data.


      ------------------


      [This message has been edited by Clay Clear (edited May 02, 2003).]

      Comment

      Working...
      X