News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

mysleep proc

Started by clamicun, January 28, 2017, 02:38:02 AM

Previous topic - Next topic

clamicun

mysleep proc
Is this an ideia ?

;mysqlinit:
;INVOKE mysql_init,NULL
;mov db_connect,eax
;INVOKE   mysql_real_connect,db_connect,offset hostname,offset u_root,offset pw_buffer,0,0,0,0
;INVOKE mysql_errno,db_connect

;.if eax == 2003    ;errno mysql 'Server does not run'
;INVOKE MessageBox,NULL,offset Error_connect,offset AppName,MB_ICONERROR  ;Msg 'Server does not run'
;INVOKE ShellExecute,main_hwnd,offset fOpen,offset mysql_startfile,NULL,NULL,SW_HIDE
;mysql_startfile   db "mysql_start.exe",0

;Here I need 3 seconds before trying again - the server needs it

;call mysleep
;jmp mysqlinit
;==========

mysleep proc

;two_ints db "%u%u",0
;goodforall dd ?
;buffer_tmp 10 up(?),0

;====Aktuelle Sekunde Millisekunde
INVOKE GetLocalTime,offset systemTime
movsx eax,systemTime.wSecond
movsx ecx,systemTime.wMilliseconds

add eax,3
INVOKE wsprintf,offset buffer_tmp,offset two_ints,eax,ecx
INVOKE crt_atoi,offset buffer_tmp
mov goodforall,eax          ;Endvalue to check

chkthesec:

INVOKE GetLocalTime,offset systemTime
movsx eax,systemTime.wSecond
movsx ecx,systemTime.wMilliseconds

INVOKE wsprintf,offset buffer_tmp,offset two_ints,eax,ecx
INVOKE crt_atoi,offset buffer_tmp

.if eax >= goodforall      ;Cmp ends
jmp outchk
.else
jmp chkthesec
.endif

outchk:

ret
mysleep endp

jj2007

What's wrong with invoke Sleep, 3000??

clamicun

Obviously the sleep function stops the whole program for a defined time.
I only want some seconds between  start_mysql (takes 2,3 seconds) and trying to check the password again

hutch--


clamicun

Yes hutch,
I do that.
But this will not change much.
Perhaps it is more "standard".
Thanks

fearless

Sounds like you should be looking at threads and signalling back to the main program thread when the connection status has changed and to what status (disconnected, no internet, connected, incorrect login details etc etc)

coder

Excuse my noobish question, but this statement puzzles me;

.if eax == 2003
INVOKE something


but where's the .else and / or the .endif part? I see some serious logical flaw here that leads to infinite loop... but maybe I am wrong. I know nothing about mysql.

jj2007

Quote from: coder on January 29, 2017, 12:04:34 PMbut where's the .else and / or the .endif part?

The .if is commented out. If it wasn't, the assembler would confirm your doubts with a fat error message 8)

coder

jj2007

ok then. I hope it's just a pseudo. But even if it is, it still scares me to see multiple instances of the database are loaded in an infinite loop (if it is even possible at all with mysql).

clamicun

To all you guys,
I resolved it . Everything runs perfectly...

clamicun

The only problem I am still having ...

Does someone know how to translate this goasm syntax

;Start the button IDs at one so we don't use 0 (we'll have to dec in order to get the right menu)
TbBtns TBBUTTON <0,1,TBSTATE_ENABLED,TBSTYLE_AUTOSIZE | TBSTYLE_DROPDOWN,0,0,0>
      TBBUTTON <1,2,TBSTATE_ENABLED,TBSTYLE_AUTOSIZE | BSTYLE_DROPDOWN,0,0,1>
      TBBUTTON <3,3,TBSTATE_ENABLED,TBSTYLE_AUTOSIZE | BSTYLE_DROPDOWN,0,0,2>
       TBBUTTON <4,4,TBSTATE_ENABLED,TBSTYLE_AUTOSIZE | BSTYLE_DROPDOWN,0,0,3>

into something which might work ?

HSE

It's an array of structures, almost the same in all languajes.
Equations in Assembly: SmplMath

jj2007

BSTYLE_DROPDOWN is undefined 8)

TWell

TbBtns TBBUTTON <0,1,TBSTATE_ENABLED,TBSTYLE_AUTOSIZE OR TBSTYLE_DROPDOWN,0,0,0>
       TBBUTTON <1,2,TBSTATE_ENABLED,TBSTYLE_AUTOSIZE OR TBSTYLE_DROPDOWN,0,0,1>
       TBBUTTON <3,3,TBSTATE_ENABLED,TBSTYLE_AUTOSIZE OR TBSTYLE_DROPDOWN,0,0,2>
       TBBUTTON <4,4,TBSTATE_ENABLED,TBSTYLE_AUTOSIZE OR TBSTYLE_DROPDOWN,0,0,3>

clamicun

Twell ???
Exactely what I wrote.
Does not compile