HELP!!!!!!! PLZ!!! HELP ME!

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by XuMuk.

If OpenWindow(0, 300, 100, 195, 260, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "PureBasic Window")
CreateGadgetList(WindowID())
Time$ = FormatDate("%hh:%ii:%ss", Date())
TextGadget(1, 10, 8, 200, 20, Time$)
Repeat
EventID.l = WaitWindowEvent()
If EventID = #PB_Event_CloseWindow
Quit = 1
EndIf
Until Quit = 1
EndIf
End
This was my program... I just wanted to erite SIMPLE clocks, but i can't! Can someone help me? Please!!! Whats Wrong?
Plz send working proggy to [url]mailto:mail.to@rambler.ru[/url] or leave it here.... Thank U beforehand!
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by OlliB.

Sorry for my bad English...
My way to show a clock:

A Procedure Refresh, to check the time and give it to Gadget 1.

And WindowEvent, because WaitWIndowEvent waits for an event... and the clock doesn't refresh.

Code: Select all

Global time.s
Global oldtime.s

Procedure Refresh()
Time = FormatDate("%hh:%ii:%ss", Date())
If timeoldtime
  SetGadgetText(1,time)
  oldtime=time
EndIf
EndProcedure

If OpenWindow(0, 300, 100, 195, 260, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "PureBasic Window")
If CreateGadgetList(WindowID())
  TextGadget(1, 10, 8, 200, 20, "")
EndIf

Repeat
Refresh()
  EventID.l = WindowEvent()
    If EventID = #PB_Event_CloseWindow
      Quit = 1
    EndIf
Until Quit = 1
EndIf
End 
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by XuMuk.

THX!!!! Thank u very much... and one question: ehat does it mean: "GLOBAL" ???
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by XuMuk.

why oldtime=tile?? ahh... I'm just a ugly lamer... Really i undeerstood your idea partly...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tranquil.

this part of code:

Repeat
Refresh()
EventID.l = WindowEvent()
If EventID = #PB_Event_CloseWindow
Quit = 1
EndIf
Until Quit = 1
EndIf

Need 100% of your CPU Time!! Why not use a windows timer to fire an event gadget?

Mike

Tranquilizer/ Secretly!
http://www.secretly.de
Registred PureBasic User
System: Windows 2000 Server, 512 MB Ram, GeForce4200 TI 128 MB DDR, Hercules Theater 6.1 DTS Sound
System 2: Mobile Pentium 4 2.4GHz 512 MB DDR GeForce4 420-32, Windows XP Home
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.

Here's another version using a timer to update the clock... The timer is set to update every 1000 millisecond i.e. every second.. Code is perhaps a bit advanced if you're just starting out. If you're using the demo version of PureBasic this code may perhaps not work because of the Win API calls (i.e. SetTimer_() and KillTimer_()), don't know how restricted the demo really is.

Code: Select all

Global hWindow.l, hTimer.l

Procedure.l MyCallback(WindowID.l, Message.l, wParam.l, lParam.l)
  Result.l = #PB_ProcessPureBasicEvents
  If WindowID = hWindow And Message = #WM_TIMER
    Result = 0
    SetGadgetText(1,FormatDate("%hh:%ii:%ss", Date()))
  EndIf
  ProcedureReturn Result
EndProcedure


hWindow.l = OpenWindow(0, 300, 100, 195, 260, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "PureBasic Window")
If hWindow = 0
  End
EndIf

If CreateGadgetList(WindowID())
  TextGadget(1, 10, 8, 200, 20, FormatDate("%hh:%ii:%ss", Date()))
EndIf

SetWindowCallback(@MyCallBack())
hTimer.l = SetTimer_(hWindow, 1, 1000, 0) 
If hTimer = 0
  End
EndIf

Repeat
  EventID.l = WaitWindowEvent()
Until EventID = #PB_Event_CloseWindow
KillTimer_(hWindow, hTimer)
End 
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by XuMuk.

.... I am usin` a registered version (3.50) ( for future ) :)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Umrof.
Need 100% of your CPU Time!! Why not use a windows timer to fire an event gadget?
That's right, but I want to use XuMuk's Code, to show what the Problem in His own Code is.:)
Pupils way is more elegant...

@Xumuk
"oldtime" memorize the time. When the time is changed, (if oldtimetime) refresh the time. So the time is only refreshed, when the time really changed.

From PB Help:
Global allows the variables to be used as global, ie: they can be accessed inside a procedure.
:)

Olli
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by OlliB.

Sorry. I logged in with the PC of my friend Umrof with his identity. The message above is not from UMROF (before you wondering).
He will hit me, when I give such answers under his name...:)

Olli
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by XuMuk.

cool... I begin to understand what functions and variables are... Than u all... very much... reallly this forum is the only place where i managed to ask questions about PBasic... What i like in PBasic is that it supports tcp/ip... and I need this function very much.. thank u dor help once more
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by geoff.
Repeat
EventID.l = WaitWindowEvent()
Until EventID = #PB_Event_CloseWindow
KillTimer_(hWindow, hTimer)
End
This bit of code from Pupil raises a question for me. Is the KillTimer needed here of does PureBasic clean up all the Windows stuff at program exit?

Do I have to free up memory and bitmaps etc before exit?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Kale.

XuMuk i would just spend a little time reading through the manual that comes with PureBasic, it would provide a good background, and maybe answer some of your questions. If you are still stuck by all means post here :) There are also many good examples of code here:

http://www.reelmediaproductions.com/pb/

--Kale

Getting used to PureBasic and falling in Love! :)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.
Originally posted by geoff
This bit of code from Pupil raises a question for me. Is the KillTimer needed here of does PureBasic clean up all the Windows stuff at program exit?

Do I have to free up memory and bitmaps etc before exit?
All is cleaned by PureBasic at end. You can assume that. All free functions are here to dynamically free the objects at runtime (needed of course).

Fred - AlphaSND
Post Reply