1. [WIN] completely stumped in win32lib.

--------------2AFBA2886B708C16D4B875B7
Content-Transfer-Encoding: 8bit

Hi, all..

I'm learning Win32lib and Windows programming, and have run into a brick wall in
my understanding of how Win32lib
works.  I've studied the Win32lib Faq as  well as the Win32Lib docs, and several
example programs, etc. over the last
five days, but I'm still completely stumped.

The program (attached) has a routine (onClick_AnalyzeButton) which loads default
entries from a file, and presents them
in (5) EditText fields of a window (ChildWin).

The user is then presented with the oppotunity to override the entries, after
which the user presses an Accept Button,
which triggers a validatation procedure (onClick_AcceptButton), which is
essentially a loop, with an exit procedure if
no errors are found.

If an error is found, that fact is displayed in a msgbox(),  and then the
program gets stuck in the onClick_AcceptButton
loop,  and requires ctrl-alt-del to terminate it. So, clearly, I'm
misunderstanding how getText and setText work, and
probably other things. I've attached the entire program  (since I'm not really
sure where, in the program, the problem
is triggered), along with the  text file it requires to run (pkzipped).

Any suggestions will be much appreciated.

Jerry

--------------2AFBA2886B708C16D4B875B7
 name="Candles.zip"

new topic     » topic index » view message » categorize

2. Re: [WIN] completely stumped in win32lib.

On Monday 04 December 2000 17:38, you wrote:

> > Hi, all..
>
> I'm learning Win32lib and Windows programming, and have run into a brick
> wall in my understanding of how Win32lib works.  I've studied the Win32lib
> Faq as  well as the Win32Lib docs, and several example programs, etc. over
> the last five days, but I'm still completely stumped.
>
> The program (attached) has a routine (onClick_AnalyzeButton) which loads
> default entries from a file, and presents them in (5) EditText fields of a
> window (ChildWin).
>
> The user is then presented with the oppotunity to override the entries,
> after which the user presses an Accept Button, which triggers a
> validatation procedure (onClick_AcceptButton), which is essentially a loop,
> with an exit procedure if no errors are found.
>
> If an error is found, that fact is displayed in a msgbox(),  and then the
> program gets stuck in the onClick_AcceptButton loop,  and requires
> ctrl-alt-del to terminate it. So, clearly, I'm misunderstanding how getText
> and setText work, and probably other things. I've attached the entire
> program  (since I'm not really sure where, in the program, the problem is
> triggered), along with the  text file it requires to run (pkzipped).
>
> Any suggestions will be much appreciated.
>
> Jerry

I haven't tested it, but I think the problem is that you loop while there's
an error, giving the user no chance to fix the errors.

If you instead returned from the procedure as soon as an error was detected
and a message box displayed, then the user could fix the error and click OK
again. I've included an example below.

Jeff Fielding

procedure onClick_AcceptButton()
          -- validate and accept user input.
          -- build DateRecord by concatenating user input fields, then save
that DateRecord to a file (CANDATES.TXT).

          setFocus(StartYear)
          entry1 = getText( StartYear )
          entry2 = getText( StartMonth )
          entry3 = getText( EndYear )
          entry4 = getText( EndMonth )
          entry5 = getText( CutOff )

          entry1 = entry1[1..2]    -- next 5 in case user's keyboard is in
{insert} mode.
          entry2 = entry2[1..2]
          entry3 = entry3[1..2]
          entry4 = entry4[1..2]
          entry5 = entry5[1..10]
                                   -- validate correctness of input data
          if is_numeric( entry1 ) = 0 then          -- must be two numeric
digits -- no alpha
                result = message_box( "Invalid Start Year .. please
re-enter", "ERROR!", {} )
                setFocus( StartYear )
                return
          end if

          if is_numeric( entry2 ) = 0 then          -- must be two numeric
digits -- no alpha
                result = message_box( "Invalid Start Month .. please
re-enter", "ERROR!", {} )
                setFocus( StartMonth )
                return
          end if

          if compare( entry2,"00" ) = 0  or compare(  entry2, "12"  ) = 1
then        -- month < 1 or > 12 ?
                result = message_box( "Invalid Start Month .. please
re-enter", "ERROR!", {} )
                setFocus( StartMonth )
                return
          end if

          if is_numeric( entry3 ) = 0 then          -- must be two numeric
digits -- no alpha
                result = message_box( "Invalid Ending Year .. please
re-enter", "ERROR!", {} )
                setFocus( EndYear )
                return
          end if

          if is_numeric( entry4 ) = 0 then          -- must be two numeric
digits -- no alpha
                result = message_box( "Invalid Ending Month .. please
re-enter", "ERROR!", {} )
                setFocus( EndMonth )
                return
          end if

          if compare( entry4,"00" ) = 0  or compare( entry4, "12" ) = 1 then
      -- month < 1 or > 12  ?
             result = message_box( "Invalid End Month .. please re-enter",
"ERROR!", {} )
             setFocus( EndMonth )
             return
          end if

          if is_numeric( entry5[1..2] ) = 0 or is_numeric( entry5[4..5] ) = 0
or is_numeric( entry5[7..10] ) = 0  then  -- no alpha
             result = message_box( "Invalid Cut Off Date.. please re-enter",
"ERROR!", {} )
             setFocus( CutOff )
             return
          end if

          if compare( entry5[1..2], "00" ) = 0 or compare( entry5[1..2], "12"
) = 1 then   -- month < 1 or > 12  ?
             result = message_box( "Invalid Cut Off Date .. please re-enter",
"ERROR!", {} )
             return
          end if

          if compare( entry5[4..5], "00" ) = 0 or compare( entry5[4..5], "31"
) = 1 then   -- day < 1 or > 31  ?
             result = message_box( "Invalid Cut Off Date .. please re-enter",
"ERROR!", {} )
             return
          end if
        -- if there is an error, it should return before this

    DateRecord = entry1&entry2&entry3&entry4&entry5&"\n"
    fn = open( "CANDATES.TXT", "w" )
    if fn = -1  then wPuts(  1,"Open CANDATES.TXT FAILED. Aborting. Press
Enter." )   wait = wait_key()
       abort(1)   --  ShutDown()
    end if
    UserDates = fn

    puts( UserDates, DateRecord )
    close( UserDates )

    closeWindow( ChildWin )
end procedure

new topic     » goto parent     » topic index » view message » categorize

3. Re: [WIN] completely stumped in win32lib.

Did we not learn anything from Y2K?

>>> JJProg at CYBERBURY.NET 12/04/00 06:12PM >>>
          setFocus(StartYear)
          entry1 = getText( StartYear )
          entry2 = getText( StartMonth )
          entry3 = getText( EndYear )
          entry4 = getText( EndMonth )
          entry5 = getText( CutOff )

          entry1 = entry1[1..2]    -- next 5 in case user's keyboard is in
{insert} mode.

new topic     » goto parent     » topic index » view message » categorize

4. Re: [WIN] completely stumped in win32lib.

> -----Original Message-----
> From: Jerry C. Cummings

> I'm learning Win32lib and Windows programming, and have run
> into a brick wall in my understanding of how Win32lib
> works.  I've studied the Win32lib Faq as  well as the
> Win32Lib docs, and several example programs, etc. over the last
> five days, but I'm still completely stumped.

Welcome to the wonderful world of Win32!

> The program (attached) has a routine (onClick_AnalyzeButton)
> which loads default entries from a file, and presents them
> in (5) EditText fields of a window (ChildWin).
>
> The user is then presented with the oppotunity to override
> the entries, after which the user presses an Accept Button,
> which triggers a validatation procedure
> (onClick_AcceptButton), which is essentially a loop, with an
> exit procedure if
> no errors are found.
>
> If an error is found, that fact is displayed in a msgbox(),
> and then the program gets stuck in the onClick_AcceptButton
> loop,  and requires ctrl-alt-del to terminate it. So,
> clearly, I'm misunderstanding how getText and setText work, and
> probably other things. I've attached the entire program
> (since I'm not really sure where, in the program, the problem
> is triggered), along with the  text file it requires to run
> (pkzipped).

This is something you'll have to get used to with windows.  When you call
setFocus(), you are setting the focus, but then your routine goes right
along without waiting for input from the user.    After you've found an
error, notified the user, and set the focus on the offending control, you
want to exit the procedure entirely with a 'return' statement.

If no errors are found, the processing will go on as you want it to.

Matt Lewis

new topic     » goto parent     » topic index » view message » categorize

5. Re: [WIN] completely stumped in win32lib.

Hello Jerry,


>The program (attached) has a routine (onClick_AnalyzeButton) which loads
>default entries from a file, and presents them
>in (5) EditText fields of a window (ChildWin).
>
>The user is then presented with the oppotunity to override the entries,
>after which the user presses an Accept Button,
>which triggers a validatation procedure (onClick_AcceptButton), which is
>essentially a loop, with an exit procedure if
>no errors are found.
>
>If an error is found, that fact is displayed in a msgbox(),  and then the
>program gets stuck in the onClick_AcceptButton
>loop,  and requires ctrl-alt-del to terminate it. So, clearly, I'm
>misunderstanding how getText and setText work, and
>probably other things. I've attached the entire program  (since I'm not
>really sure where, in the program, the problem
>is triggered), along with the  text file it requires to run (pkzipped).


I think the problem is that you are only "exit"ing the loop
when there is NO error. That means that you will be stuck in the
loop if there is. I would suggest putting an exit statement right
after the message box statement.

hope this helps,

Lewis Townsend
_____________________________________________________________________________________
Get more from the Web.  FREE MSN Explorer download : http://explorer.msn.com

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu