Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Deal or no deal ........

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-14-2007, 08:28 PM
taximania's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire. UK
Posts: 592
Awards Showcase
Beta Tester 
Total Awards: 1
Default Deal or no deal ........

2 weeks now and no written reply from Endemol

Question:
If I don't add the red code on the desktop version, my laptop goes into 'fans on, 100% CPU usage'

Code:
Sub buttok
    button34.Visible=
true
    
Do Until butok = 1
    
DoEvents
    <font color=
"Red">Sleep(50)</font>
    
Loop
    butok=
0
    button34.Visible=
false
        label76.Text=
""
End Sub
Would this be a problem on the Device version ?? (the lack of the Sleep command) ?
ie Max CPU usage.

Is a statement like needed,

If PPC=? then sleep????
bla bla bla
End if

Just wondered
__________________
.
.
.
Don't ask, I'm fine, honest. !!
.
.
.
Just a little crazy at times



O2 XDA, GW Evo 2.1 UC WWE Rom, WM6.1
Radio Ver 03.34.90
With Basic4ppc V6.80


http://www.taximania.co.uk
Reply With Quote
  #2 (permalink)  
Old 09-14-2007, 09:18 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

I don't get it, why use Sleep after DoEvents?

How many processes do you have running on your laptop for it to go turbo fan mode?
Are you sure about spyware?

The DoEvents enables your device to "pay attention" to others processes instead of "locking" to you app...so why Sleep?

Have you tried the code in a device?
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #3 (permalink)  
Old 09-15-2007, 04:20 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

I would expect this as you are effectively running an endless loop and so using 100% of the CPU, it's getting warm and the fans are quite correctly coming on. Both of these waste battery energy. There will also be the same problem on the device

If you are having to do this then I am afraid that your program structure is not good. You really should be exitting Sub buttok and using whatever event triggers the variable butok to be set to 1 to take the next step.
Reply With Quote
  #4 (permalink)  
Old 09-15-2007, 04:44 PM
taximania's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire. UK
Posts: 592
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by agraham View Post
I would expect this as you are effectively running an endless loop and so using 100% of the CPU, it's getting warm and the fans are quite correctly coming on. Both of these waste battery energy. There will also be the same problem on the device
That's what I thought.

Quote:
If you are having to do this then I am afraid that your program structure is not good. You really should be exitting Sub buttok and using whatever event triggers the variable butok to be set to 1 to take the next step.
Button34_Click sets butok to 1
buttok halts the program till button34 is clicked.

What other method is there to halt the program till a particular button is pressed, my heads puddled
__________________
.
.
.
Don't ask, I'm fine, honest. !!
.
.
.
Just a little crazy at times



O2 XDA, GW Evo 2.1 UC WWE Rom, WM6.1
Radio Ver 03.34.90
With Basic4ppc V6.80


http://www.taximania.co.uk
Reply With Quote
  #5 (permalink)  
Old 09-15-2007, 06:25 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by taximania View Post
What other method is there to halt the program till a particular button is pressed, my heads puddled
To effectively and efficiently code in Windows requires you to use event-based programming. In such programming you don't need to "halt" the program, you respond to an event occuring by running some code and then exiting from the Sub that the event invoked. Your code is then automatically "halted" by the Operating System until another event occurs for which you have written an event handler Sub.

Quote:
Button34_Click sets butok to 1
buttok halts the program till button34 is clicked.
I am not entirely clear what you want but how about the following?

Code:
' invoked by some event somewhere
'
make Button34 visible and exit so waiting for another event
Sub buttok
    button34.Visible=
true
End Sub

' Button34 clicked so hide it
Sub Button34_Click
    button34.Visible=
false
    label76.Text=
""
    butok = 
1
    
' do anything else needed here
End Sub
Reply With Quote
  #6 (permalink)  
Old 09-15-2007, 07:20 PM
taximania's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire. UK
Posts: 592
Awards Showcase
Beta Tester 
Total Awards: 1
Default



22 buttons (right side)
When an offer is made, 'Yes' and 'No' buttons are made visible at the bottom of the playing area.

It's instead of using a MsgBox which obscures the playing area but used to be my halt and return the values I needed.
Come on, this is version 99 by now. It needed a little player friendly bits added

If I don't disable all of the unused 22 buttons and wait for a 'Yes' or 'No' button_click, the user can still click any of the available 22 buttons, thus, ruining the game.

Once a 'Yes' button has been clicked, (offer taken), an 'OK' button (34) is displayed at the bottom instead, and the value the offer would have been. Again, if I don't wait for the, 'OK' click 'and' disable the other buttons until i've had the button34_click the user can still click the unused 22 buttons and spoil the game.

Sorry for rambling, it is saturday night, cheers agraham
http://myweb.tiscali.co.uk/taximania/mygame/mygame.html
__________________
.
.
.
Don't ask, I'm fine, honest. !!
.
.
.
Just a little crazy at times



O2 XDA, GW Evo 2.1 UC WWE Rom, WM6.1
Radio Ver 03.34.90
With Basic4ppc V6.80


http://www.taximania.co.uk

Last edited by taximania : 09-15-2007 at 08:05 PM.
Reply With Quote
  #7 (permalink)  
Old 09-15-2007, 08:31 PM
RandomCoder's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire, UK
Posts: 623
Awards Showcase
Beta Tester 
Total Awards: 1
Default

You could set what I would refer to as a flag which if true allows play to continue.

When either the 'yes', 'no' or 'OK' buttons are made visible the flag is made false. Following one of the buttons being clicked the flag is made true again if play is allowed to continue. Presumably each 'box' has its own click event which would first check if the flag was true else exit the sub.

That's how I would approach the problem anyway.

Regards,
RandomCoder
__________________
"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #8 (permalink)  
Old 09-15-2007, 08:35 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by taximania View Post
If I don't disable all of the unused 22 buttons and wait for a 'Yes' or 'No' button_click, the user can still click any of the available 22 buttons, thus, ruining the game.
I'm glad you spotted this for yourself. I had thought of mentioning this in my previous post but decided not to to keep it short(ish).

One downside of event-based programming is that you can't predict what events a user may cause so you have to be prepared for anything to happen. This can mean a lot of enabling or disabling or hiding controls, or may mean a lot of conditional testing within event Subs to see if an event should be ignored or not. As ever experience (and occasional (or frequent!) failure) are the best teachers to efficient program design together with (maybe) a bit of help from the elders of the tribe. I can count on over 42 years of coding and I'm still learning (more slowly each year regrettably as the faculties dim!)

Off for a drink or two myself 'cos there's bog all on the telly tonight (maybe that's what's doing in the faculties (the drink not the telly - but maybe ...)).

Don't you just love all these nested parentheses.

Cheers!
Reply With Quote
  #9 (permalink)  
Old 09-16-2007, 09:02 AM
taximania's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire. UK
Posts: 592
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by RandomCoder View Post
You could set what I would refer to as a flag which if true allows play to continue.

Regards,
RandomCoder
You mean like
Code:
do until flag = 1
doevents
loop


Code:
Sub buttok
    button34.Visible=
true
    
Do Until butok = 1
    
DoEvents
    Sleep(
50)
    
Loop
    butok=
0
    button34.Visible=
false
        label76.Text=
""
End Sub
Quote:
When either the 'yes', 'no' or 'OK' buttons are made visible the flag is made false. Following one of the buttons being clicked the flag is made true again if play is allowed to continue. Presumably each 'box' has its own click event which would first check if the flag was true else exit the sub.
The subs to enable/disable the unused 22 buttons is already in place.

Code:
Sub enbuts
For a = 1 To 22
If box(a).used = 1 Then
    Control(
"Button" & a).Enabled = true
End If
Next a
End Sub

Sub dibuts
For a = 1 To 22
If box(a).used = 1 Then
    Control(
"Button" & a).Enabled = false
End If
Next a
End Sub
Question: Is there another other method , (not an endless loop), to halt the program till a particular button (or action) has taken place
__________________
.
.
.
Don't ask, I'm fine, honest. !!
.
.
.
Just a little crazy at times



O2 XDA, GW Evo 2.1 UC WWE Rom, WM6.1
Radio Ver 03.34.90
With Basic4ppc V6.80


http://www.taximania.co.uk
Reply With Quote
  #10 (permalink)  
Old 09-16-2007, 09:39 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by taximania View Post
Question: Is there another other method , (not an endless loop), to halt the program till a particular button (or action) has taken place
I think that you have missed the point of my earlier reply. There is no need to ever halt your program yourself, it is halted automatically when you have finished processing an event until the next event occurs. Just let the event Sub exit and your program is halted. When the button you are waiting for is pressed then its' event sub will be called and you can do what is necessary then.

A problem that you might have is that other buttons may be pressed or other events occur that that you might want to ignore. You have to allow for this by either disabling other controls or including appropriate code in their event procedures.

Last edited by agraham : 09-16-2007 at 09:42 AM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
OCX Libraries- Can B4ppc deal with them? Cableguy Questions (Windows Mobile) 1 10-30-2007 04:36 AM


All times are GMT. The time now is 11:11 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0