Announcement

Collapse
No announcement yet.

Please help with I/O problem

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

  • Paul Dixon
    replied
    Tory,

    10 get input a$
    20 print a$
    Code:
    FUNCTION PBMAIN
    a$=INPUTBOX$("What's your input?","Box title")
    MSGBOX(a$)
    
    END FUNCTION

    Leave a comment:


  • Tory Remrey
    replied
    Thank you all for your help! It is greatly appreciated. And special thanks to Mr. John Gleason.

    Leave a comment:


  • Tory Remrey
    replied
    Thank you everyone for your help! It is greatly appreciated.

    Leave a comment:


  • John Gleason
    replied
    Tory, here's a tiny example.
    Like Knuth said, there lots of others to look at in SAMPLES.

    Code:
    #PBFORMS Created
    '--------------------------------------------------------------------------------
    ' The first line in this file is a PBForms metastatement.
    ' It should ALWAYS be the first line of the file. Other
    ' PBForms metastatements are placed at the beginning and
    ' ending of blocks of code that should be edited using
    ' PBForms only. Do not edit or delete these
    ' metastatements or PBForms will not be able to reread
    ' the file correctly. See the PBForms documentation for
    ' more information.
    ' Beginning blocks begin like this: #PBForms Begin ...
    ' Ending blocks begin like this:    #PBForms End ...
    ' Other PBForms metastatements such as:
    '     #PBForms Declarations
    ' are used to tell PBForms where to insert additional
    ' code. Feel free to make changes anywhere else in the file.
    '--------------------------------------------------------------------------------
    
    #COMPILE EXE
    #DIM ALL
    
    '--------------------------------------------------------------------------------
    '   ** Includes **
    '--------------------------------------------------------------------------------
    
    #PBFORMS Begin Includes 
    #IF NOT %DEF(%WINAPI)
        #INCLUDE "WIN32API.INC"
    #ENDIF
    #PBFORMS End Includes
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    '   ** Constants **
    '--------------------------------------------------------------------------------
    #PBFORMS Begin Constants 
    %IDD_DIALOG1    = 101
    %IDC_TEXTBOX1   = 1001
    %IDC_TEXTBOX2   = 1002
    %IDC_BUTTON1    = 1003
    %IDC_BUTTON2    = 1004
    #PBFORMS End Constants
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    '   ** Declarations **
    '--------------------------------------------------------------------------------
    DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
    DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
    #PBFORMS Declarations
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    FUNCTION PBMAIN()
        ShowDIALOG1 %HWND_DESKTOP
    END FUNCTION
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    '   ** CallBacks **
    '--------------------------------------------------------------------------------
    CALLBACK FUNCTION ShowDIALOG1Proc()
    LOCAL inputText AS STRING
    
        SELECT CASE CBMSG
            CASE %WM_COMMAND
                SELECT CASE CBCTL
                    CASE %IDC_TEXTBOX1
                    CASE %IDC_TEXTBOX2
                    CASE %IDC_BUTTON2
                       DIALOG END CBHNDL
                    CASE %IDC_BUTTON1
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                           CONTROL GET TEXT CBHNDL, %IDC_TEXTBOX1 TO inputText
                           CONTROL SET TEXT CBHNDL, %IDC_TEXTBOX2, inputText
                        END IF
    
                END SELECT
        END SELECT
    
    END FUNCTION
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    '   ** Dialogs **
    '--------------------------------------------------------------------------------
    FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
        LOCAL lRslt AS LONG
    #PBFORMS Begin Dialog %IDD_DIALOG1->->
        LOCAL hDlg AS DWORD
    
        DIALOG NEW hParent, "Dialog1", 248, 175, 215, 106, TO hDlg
        CONTROL ADD TEXTBOX, hDlg, %IDC_TEXTBOX1, "Type text here, then click the " + _
            "Enter button", 25, 15, 150, 20, %WS_CHILD OR %WS_VISIBLE OR _
            %WS_TABSTOP OR %ES_CENTER OR %ES_AUTOHSCROLL, %WS_EX_CLIENTEDGE OR _
            %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR
        CONTROL ADD TEXTBOX, hDlg, %IDC_TEXTBOX2, "", 25, 50, 150, 20
        CONTROL ADD BUTTON, hDlg, %IDC_BUTTON1, "Enter", 180, 15, 30, 15
        CONTROL ADD BUTTON, hDlg, %IDC_BUTTON2, "Exit", 85, 80, 50, 15
    
    #PBFORMS End Dialog
    
        DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
    
        FUNCTION = lRslt
    END FUNCTION
    '--------------------------------------------------------------------------------

    Leave a comment:


  • Michael Mattias
    replied
    In the windows GUI enviroment, you will want to provide a button so the user can tell you when his input is ready for you.

    In your old MS-DOS BASIC code, the <Enter> key did that by completing execution of the INPUT statement, but there's no such thing as an <Enter> key when entering text into a text control*.

    You need to rethink your user interface.. the MS-DOS "linear" model simply does not apply to the Windows GUI ennvironment.

    MCM
    *Yes, I know, but don't you think subclassing is getting a little too far a little too fast?

    Leave a comment:


  • Knuth Konrad
    replied
    Tory,

    study the provided help file, for this case, look under CONTROL GET ... (retrieve values from controls) and CONTROL SET ... (set values for controls)

    You might also want to look at the example source code files that come with the compiler, located in the SAMPLES folder of your installation.

    Leave a comment:


  • Tory Remrey
    started a topic Please help with I/O problem

    Please help with I/O problem

    Greetings all,

    This may be an elementary question for those of you who are more familiar than I with PB Win 8.0 & PB Forms1.51 and the solution is probably quite simple, but I just can’t seem to figure it out. Back in the day a BASIC program to get a data string from a user and output (i.e. print) that data to the screen was simple and would look something like this:

    10 get input a$
    20 print a$

    Problem is under Windows nothing can be that simple. If I understand correctly, once a program is coded it must be wrapped in a GUI (i.e. run within a window). So, we must create a new dialog (%IDD_DIALOG1). Then we add two textbox controls (%IDC_TEXTBOX1 and %IDC_TEXTBOX2). This much is easy enough, but how do I instruct the GUI to get UserInput$ from TEXTBOX1 then output (i.e. PRINT) UserInput$ to TEXTBOX2 ?

    For example, think of a simple Instant Messenger program, chat program, or even a telnet/MUD client. All of these types of programs need to get UserInput$ from one textbox then display UserInput$ to a secondary textbox. At least, I assume this is typically done within two textboxes. Perhaps I am wrong, or maybe there is a better way of achieving the same effect.

    An actual example of code is preferable to an explanation of how this can be achieved. If I have the code, the explanation should be self-evident. However, I appreciate any help you may be able to provide.
    Last edited by Tory Remrey; 5 Feb 2008, 02:13 AM.
Working...
X