Results 1 to 6 of 6

Thread: co2 hellowin1 compiles but...

  1. #1

    co2 hellowin1 compiles but...

    Hi,
    I've copied hellowin1.tbasic to hellowin1.bas and deleted all tbasic stuff in order to get a pure oxygen source file.

    It compiles fine with co2 but the compiled application has a cpu load of 50% on a intel cpu with hyperthreading.

    The only way I could get the program to operate normally was to change the message loop to:

      ;MESSAGE LOOP
      ;
      do while GetMessage (&wm, 0, 0, 0) > 0
        TranslateMessage (&wm)
        DispatchMessage (&wm)
    
        sleep(1)
      wend
    
    As it can be seen I've added a sleep command.
    Sleep (Win32 API) takes int numbers as milliseconds; so putting the application to sleep for 1 millisecond did the trick.

    My question though is:
    I've never had to add a delay in a windows application message loop in order to bring the cpu load down. (with different compilers and languages...)

    This doesn't happen if I compile hellowin1.tbasic (the thinbasic interpreter is invoked) but happens if hellowin1.bas is directly compiled as:

    co2 hellowin1

    Did I miss something?


    Bye
    efgee

  2. #2

    Re: co2 hellowin1 compiles but...


    Hi efgee,

    I don't know what is causing that. Could it be another process thread? My compiled HelloWin1 runs as impassive as a rock. (My PC has an Intel quad core running Vista 64).

    In a few days time I will have the bare bones standalone Oxygen with an IDE (Scintilla based) with a linked in Help file. I think this will be easier for you to experiment with. You will be able to compile programs on a single keystroke (F7) or run then directly from script like thinBasic (F5).

    Scintilla is new territory for me. The config system is quite complex but I am gradually gaining its cooperation.

    Charles

  3. #3

    Re: co2 hellowin1 compiles but...

    Quote Originally Posted by Charles Pegge
    I don't know what is causing that. Could it be another process thread?
    Well, I'm looking at the cpu resources with ProcessExplorer, and it tells me it's the hellowin1 application, not another thread.

    Quote Originally Posted by Charles Pegge
    My compiled HelloWin1 runs as impassive as a rock. (My PC has an Intel quad core running Vista 64).
    I run it on WinXP-SP3, maybe there is a difference.

    So you did not observe the cpu load of hellowin1 when thinbasic is not invoked?

    [quote=Charles Pegge]
    In a few days time I will have the bare bones standalone Oxygen with an IDE (Scintilla based) with a ]

    Wow, didn't expect this one... looking forward to it.

    Take care
    efgee

  4. #4

    Re: co2 hellowin1 compiles but...

    So after looking more in depth I found a clear explanation what's happening here:

    http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx

    According to this Microsoft document things like:

      do while GetMessage (&wm, 0, 0, 0)
      ....
    
    should be avoided because the return value can be nonzero, zero, or -1.

    So I changed the loop to:

      ;
      ; bRet needs to be defined before use...
      ;
      ;MESSAGE LOOP
      ;
      do while (bRet = GetMessage (&wm, 0, 0, 0) != 0)
    
        if bRet == -1 then
          'do something after the error occurred and show an error message
        else
          TranslateMessage (&wm)
          DispatchMessage (&wm)
        end if
    
      wend
      ;
    
    and this works perfectly.

    Maybe the examples that incorporate a gui should get the message loop changed accordingly.

    Thanks
    efgee

    BTW I like the fact that oxygen understands C to some a degree; this way I can use stuff like "==" and "!=" and it works!

  5. #5

    Re: co2 hellowin1 compiles but...



    In Oxygen, the assign and compare operator is ':='

    See if this works on your PC:

    [code=thinbasic]
    sys bRet
    '
    do while bRet := GetMessage (&wm, 0, 0, 0)
    if bRet == -1 then
    'do something after the error occurred and show an error message
    else
    TranslateMessage &wm
    DispatchMessage &wm
    end if
    wend
    [/code]

    Charles

  6. #6

    Re: co2 hellowin1 compiles but...

    Works, thank you.

    efgee

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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