Jump to content

Repeating Function


Recommended Posts

Hi, Ive had a look around but can't find this anywhere.

On pressing a button, I am using AdLibRegester to run the following function every 10 sec:

GUICtrlSetData($progress, 9)
GUICtrlSetState($upload, $GUI_DISABLE)
GUICtrlSetData($progress, 18)
GUICtrlSetData($upload, "Uploading")
GUICtrlSetData($progress, 27)
$read = FileRead("C:/now_playing.txt")
GUICtrlSetData($progress, 36)
_FileCreate(@MyDocumentsDir & "/song.html")
GUICtrlSetData($progress, 45)
_FileWriteToLine(@MyDocumentsDir & "/song.html", 1, "<b>On Air:</b> " & $dj & "<b>Now Playing:</b> " & $read & "</p></body></html>)
GUICtrlSetData($progress, 54)
$Open = _FTP_Open('MyFTP Control')
GUICtrlSetData($progress, 63)
$Conn = _FTP_Connect($Open, $server, $username, $pass)
GUICtrlSetData($progress, 72)
_FTP_FilePut($Conn, @MyDocumentsDir & "/song.html", "/public_html/song.html")
GUICtrlSetData($progress, 81)
_FTP_Close($Open)
GUICtrlSetData($progress, 90)
GUICtrlSetData($upload, "Upload")
GUICtrlSetData($progress, 100)
GUICtrlSetState($upload, $GUI_ENABLE)
GUICtrlSetData($progress, 0)

For some reason, the function just doesn't seem to want to run.

Also, would it be possible for the user to interact with the rest of the GUI whilst this function is running?

Almost like a background function that is always running.

Any help will be appreciated,

Curtis

Link to comment
Share on other sites

What function? That's not a function. There's a lot of code missing from that, can you post a script that demonstrates the problem and not just a piece of it? Because recreating your script would be impossible, and the script is important to figuring out what you did wrong.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Sorry.

Here is the code.

#include <GUIConstants.au3>
#include <FTPEx.au3>
#include <File.au3>

GUICreate("GUI", 200, 200)
GUISetState()

$dj = 'Someone'
$server = 'myserver.com'
$username = 'myuser'
$pass = 'mypass'

$button1 = GUICtrlCreateButton("Press Me", 1, 1, 99, 150)
$button2 = GUICtrlCreateButton("Don't Press Me", 101, 1, 101, 150)
$progress = GUICtrlCreateProgress(1, 151, 198, 48)

While 1
Switch GUIGetMsg()

Case $GUI_EVENT_CLOSE
Exit

Case $button1
AdlibRegister("_Upload()", 10000)

Case $button2
MsgBox(0, "Hello", "Hello World!")

EndSwitch
WEnd

Func _Upload()
GUICtrlSetData($progress, 10)
GUICtrlSetState($button1, $GUI_DISABLE)
GUICtrlSetData($progress, 20)
GUICtrlSetData($button1, "Uploading")
GUICtrlSetData($progress, 30)
$read = FileRead("C:/now_playing.txt")
GUICtrlSetData($progress, 40)
_FileCreate(@MyDocumentsDir & "/song.html")
GUICtrlSetData($progress, 50)
_FileWriteToLine(@MyDocumentsDir & "/song.html", 1, "<!DOCTYPE html><head></head><body><p><b>On Air:</b> " & $dj & "</p><br><p><b>Now Playing:</b> " & $read & "</p></body></html>")
GUICtrlSetData($progress, 60)
$Open = _FTP_Open('MyFTP Control')
GUICtrlSetData($progress, 70)
$Conn = _FTP_Connect($Open, $server, $username, $pass)
GUICtrlSetData($progress, 80)
_FTP_FilePut($Conn, @MyDocumentsDir & "/song.html", "/public_html/song.html")
GUICtrlSetData($progress, 90)
_FTP_Close($Open)
GUICtrlSetData($progress, 100)
GUICtrlSetData($progress, 0)
EndFunc
Edited by CurtisWhitby
Link to comment
Share on other sites

Change this line:

; From this
AdlibRegister("_Upload()", 10000)
; To this
AdlibRegister("_Upload", 10000)

See if that works.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...