Jump to content

Some help & advise


Saitoh183
 Share

Recommended Posts

Hi,

I just started to merge my 2 GUIs (main + options menu) after reading the MultipleGUI wiki. I decided to use the hybrid method describe there. What would like is for someone to have a look at my script and tell me if there are areas i could reduce because there is a lot of code, lots of repetitions and as im new to autoit, im sure i added useless code. Also the script works partially..once i open up the second GUI (options menu) none of the stuff i coded work as they should. I assumed its because the second GUI is in a function and the Events for the items are in another function. I was thinking that i would have to either use a ByRef or just pass all the variables from one function to the other but with as many variables as there is that just didnt seems like the proper way of doing it. I thought maybe an Array would be helpful but i dont know how to create it in the proper way with the proper code so its usable in my _Actions(). Here is my code sinces its very long, i will attach the file.

Thanks in advance :graduated:

Final.au3

Link to comment
Share on other sites

  • Moderators

Saitoh183,

That was fun - I think it is working properly now! ;)

I have stripped your script down to the essentials so that you can see what I have done - and I hope also see why I have done it! :graduated:

;---------------Libraries to include------------------
#include <Date.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ProgressConstants.au3>
;#include <Progress.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <Misc.au3>
#include <TabConstants.au3>
#include <EditConstants.au3>

Opt("GUIOnEventMode", 1)

Global $pausef = False
Global $Runf = True

; You need to declare placeholders for all GUIs and controls that you will create or you will get "undeclared" errors <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Global $TRH_opt_Gui = 9999, $OK = 9999, $Cancel = 9999, $Saveset = 9999

;GUI interface---------------------------
$TR_GUI = GUICreate("TRHelper", 413, 300, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
$Progress1 = GUICtrlCreateProgress(47, 64, 225, 25, $PBS_SMOOTH)
$start = GUICtrlCreateButton("Start", 120, 208, 49, 57)
$stop = GUICtrlCreateButton("Stop", 120, 128, 49, 57)
$extrab = GUICtrlCreateButton("Extra Log", 15, 120, 97, 25)
$tvb = GUICtrlCreateButton("Tv Log", 15, 152, 97, 25)
$animeb = GUICtrlCreateButton("Anime Log", 15, 184, 97, 25)
$movieb = GUICtrlCreateButton("Movie Log", 15, 217, 97, 25)
$exit = GUICtrlCreateButton("Exit", 15, 248, 97, 25)
$pauseme = GUICtrlCreateButton("Pause", 176, 128, 49, 57)
$options = GUICtrlCreateButton("Options", 176, 208, 49, 57)
$Label1 = GUICtrlCreateLabel("", 48, 24, 220, 25, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$Label2 = GUICtrlCreateLabel("0%", 288, 64, 76, 25, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUISetState(@SW_SHOW)

;-----------End of GUI Creation----------------

;----------GUI Event buttons---------------------------

GUICtrlSetOnEvent($start, "_actions")
GUICtrlSetOnEvent($stop, "_actions")
GUICtrlSetOnEvent($pauseme, "_actions")
GUICtrlSetOnEvent($tvb, "_actions")
GUICtrlSetOnEvent($animeb, "_actions")
GUICtrlSetOnEvent($movieb, "_actions")
GUICtrlSetOnEvent($extrab, "_actions") ; You forgot this one! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
GUICtrlSetOnEvent($exit, "_exit")
GUICtrlSetOnEvent($options, "_opt")

;------------------------------------------------------

While 1

    Sleep(10)
    ; Check if the flag has been set by the OnEvent function
    If $Runf Then
        ConsoleWrite("Running" & @CRLF)
        ; Now start the "real" function from within the main code
        _Monitor()
    EndIf

WEnd

;##################Functions#####################################
Func _Monitor()

    Do
        Sleep(1000)
        ; Look to see if the pause flag is set
        If $pausef Then
            ConsoleWrite("Paused" & @CRLF)
            ; And wait until it is not
            Do
                Sleep(10)
            Until Not $pausef
            ConsoleWrite("Resumed" & @CRLF)
        EndIf
    Until $Runf = False
    ConsoleWrite("Ending" & @CRLF)

EndFunc   ;==>_Monitor

;~ ;---exit from program------------------------
Func _exit()
    Switch @GUI_WinHandle ; See which GUI sent the CLOSE message
        Case $TR_GUI
            Exit
        Case $TRH_opt_Gui
            ; Reset the main GUI
            GUISetState(@SW_ENABLE, $TR_GUI)
            WinActivate($TR_GUI)
            ; Before you delete this one
            GUIDelete($TRH_opt_Gui)
    EndSwitch
EndFunc   ;==>_exit

Func _opt()

    GUISetState(@SW_DISABLE, $TR_GUI)

    ;Global Options Menu ######################################
    $TRH_opt_Gui = GUICreate("TRHelper Options", 615, 438, 1044, 160)

    GUICtrlCreateTab(32, 8, 553, 385)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
    $OK = GUICtrlCreateButton("OK", 104, 392, 81, 25)
    $Cancel = GUICtrlCreateButton("Cancel", 408, 392, 81, 25)
    $Saveset = GUICtrlCreateButton("Save", 256, 392, 81, 25)

    GUISetState(@SW_SHOW)
    ;----------GUI Event buttons---------------------------
    GUICtrlSetOnEvent($OK, "_actions")
    GUICtrlSetOnEvent($Cancel, "_actions")
    GUICtrlSetOnEvent($Saveset, "_actions")

EndFunc   ;==>_opt

Func _actions()
    Switch @GUI_CtrlId
        ;Main GUI----------
        Case $start
            $Runf = True
        Case $stop
            $Runf = False
        Case $pauseme
            If $Runf Then
                $pausef = Not $pausef ; only allow action if running
            EndIf
        Case $tvb
            ConsoleWrite("$tvlog" & @CRLF)
            ;ShellExecute($tvlog)
        Case $movieb
            ConsoleWrite("$movielog" & @CRLF)
            ;ShellExecute($movielog)
        Case $animeb
            ConsoleWrite("$animelog" & @CRLF)
            ;ShellExecute($animelog)
        Case $extrab
            ConsoleWrite("$extralog" & @CRLF)
            ;ShellExecute($extralog)
            ;End of Main GUI------------

        Case $OK
            ConsoleWrite("OK" & @CRLF)
        Case $Cancel
            _exit()
        Case $Saveset
            ConsoleWrite("Save" & @CRLF)
            ;End Option Menu button actions--------------
    EndSwitch
EndFunc   ;==>_actions

Might I suggest that you try and develop your scripts like this - get the main GUI stuff sorted before you start on the intricate details. If you do not do it this way then it is often difficult to see the wood for the trees and find out why it is not working as you think it should. :)

Please ask if you have any questions on what I have done. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thanks :graduated:,

Well i did sort out both GUIs before i merged them...on there own each worked perfectly as intended. My plan was was to enable or disable sections of the Main GUI based on my ini file settings. The hard part came when i tried to merge...,as you can see...i had to rewrite bits and pieces to get stuff to work.

Ok so for first question,

; You need to declare placeholders for all GUIs and controls that you will create or you will get "undeclared" errors <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Global $TRH_opt_Gui = 9999, $OK = 9999, $Cancel = 9999, $Saveset = 9999

Does this mean i have to declare every single variable in my $TRH_opt_GUI as global?...also why a value of 9999 if they are buttons?

Link to comment
Share on other sites

Question 2

Func _Monitor()
    Do
        Sleep(1000)
        ; Look to see if the pause flag is set
        If $pausef Then
            ConsoleWrite("Paused" & @CRLF)
            ; And wait until it is not
            Do
                Sleep(10)
            Until Not $pausef
            ConsoleWrite("Resumed" & @CRLF)
        EndIf
    Until $Runf = False
    ConsoleWrite("Ending" & @CRLF)
EndFunc   ;==>_Monitor

I dont understand the why behind this modification compared to what was in place already :graduated:

Link to comment
Share on other sites

  • Moderators

Saitoh183,

I was not suggesting that you had not correctly coded the GUIs, but you can see how complex it gets when you try to combine them! Best to strip back the code as I did so you can see exactly what is going on - or indeed not as the case might be. :)

As to the variables, the answer is yes. You are referring to them in the _actions function and if they are not defined AutoIt will either throw an error or fire the first available Case - depending on exactly how you run the code. :graduated:

I always use 9999 as a placeholder because I have yet to come across a script with 10000 controls - but you can use any number that is unlikely to cause an inadvertant firing of a Case. And of course if you are constantly opening and closing different GUIs you need to reset the placeholders when you close a GUI as a new GUI will use the same ControlIDs for its controls and you could get the wrong Case firing. ;)

As I mentioned in the tutorial, simultaneous multiple GUIs are not easy! ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I was not suggesting that you had not correctly coded the GUIs, but you can see how complex it gets when you try to combine them! Best to strip back the code as I did so you can see exactly what is going on - or indeed not as the case might be. :)

Ah...ic...hence why you added all those console write :graduated:, Yes it does become complex when trying to merge both into 1 ;) I built them each apart coding section by section and told myself...yeah merging this will be cake...boy was i wrong..lol. Well from what i could see in when using the checkAu3, is that i was losing my variables because of functions. I had searched around t see if there was an alternative to declaring them at the start of script as global since there was so many but i think its the only solution.
Link to comment
Share on other sites

  • Moderators

Saitoh183,

As you are creating all those variables within a function and then referencing them within another, you have little choice other than to declare them Global at the top of the script! ;)

Personally I find it a lot easier to combine multiple GUIs in MessageLoop mode - however I rarely code in OnEvent mode and so I am less used to it. But the ability to use individual GUIGetMsg loops for each child GUI does ease the task - and as everything can be contined within the one function you need fewer Global variables. :graduated:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I dont know if it would have been better going down the Messageloop mode...it just seemed more complex and i forget why i had went down the Onevent road. Initially did the entire Options GUI in ML mode and the Main GUI in OE mode. then i transform Option GUI to OE to ease the merge. I didnt see how i could reduce the number of variables and repetitions coding in ML mode nor how to make a pause button that will be able to pause the script at any point and allow me to still use the other buttons on the Main GUI.

Link to comment
Share on other sites

Another small quesiton...,

In my script i would like it to delete a certain string of text for a log file before it appends the text to another log file...i had tried make that part of the script in the past and was never able to get it to work

Here is the snippet that doesnt the append:

$file1 = FileRead($renamerlog)
  $file2 = FileOpen($extralog,1)
  $file3 = FileRead($historylog)
;erase of string needs to happen here
  FileWriteLine($file2, "############ " & @MDAY & "/" & @MON & "/" & @YEAR & "############ " & @CRLF)
  FileWriteLine($file2, "############ " & @HOUR & "h:" & @MIN & "############ " & @CRLF)
  FileWriteLine($file2,$file3)
  FileWriteLine($file2,$file1)
  FileClose($file2)
  Filedelete($historylog)

Here are the variables

$searchString = "######################## END Session" ; String to search for
$historylog ="C:\Users\Administrator\Documents\theRenamer\History\" & _DateToMonth(@mon,1) & "." & @MDAY & ".log" ; <=== files to search in
Link to comment
Share on other sites

  • Moderators

Saitoh183,

I would suggest one of the following:

- 1. Read in the content of the file using FileRead, use StringReplace to delete that line, and then rewrite the file with FileWrite.

- 2a. Read the file into an array with _FileReadToArray, use _ArraySearch and _ArrayDelete to remove that element, and then rewrite the file using _FileWriteFromArray.

- 2b As above except loop through the array and add each remaining lines directly to $extralog rather than rewriting the array as $historylog.

Diffilcult to say which is the better - none are particularly elegant. :graduated:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thanks :graduated:

i will give one of those a try...i dont know if it makes a difference in possibilities of scripting, but the string im looking for is always going to be the last line in the log regardless of how many lines are between it and the beginning of the log. file

Link to comment
Share on other sites

That makes it easier

$sStr = FileRead("HistoryLog.txt")
$sRtn = StringRegExpReplace($sStr, "(?s).+(?m:^)(.+)(?:\s)$", "$1")
ConsoleWrite("Return: " & $sRtn & @CRLF)

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

That makes it easier

$sStr = FileRead("HistoryLog.txt")
$sRtn = StringRegExpReplace($sStr, "(?s).+(?m:^)(.+)(?:\s)$", "$1")
ConsoleWrite("Return: " & $sRtn & @CRLF)

Could you explain your regExp in more detail or if you have a reference page i could use to decipher ...i havent used Regexp in a long time...bit rusty :graduated:

Link to comment
Share on other sites

StringRegExp in the help file

(?s) = . matches anything including newline.

.+ = Match anything

(?m:^) = begin matching at the beginning of a new line

(.+) = Match and capture anything after the beginning of the line

(?:\s) Don't match whitespace up to the $

$ = Match at the end of the string

The last two prevent it from matching an empty line after the last line containing text

So in essence all it can possibly match is the last line of the string.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

StringRegExp in the help file

(?s) = . matches anything including newline.

.+ = Match anything

(?m:^) = begin matching at the beginning of a new line

(.+) = Match and capture anything after the beginning of the line

(?:\s) Don't match whitespace up to the $

$ = Match at the end of the string

The last two prevent it from matching an empty line after the last line containing text

So in essence all it can possibly match is the last line of the string.

I will have a look at that , thank you :graduated:

So my script is working pretty well but still have a issue with Ini file.

here is what i got so far:

Global  $TR_GUI, _
  $TRH_opt_GUI=9999, $Ok, $Cancel, $saveset, $y, _ ; <=== Option GUI
  $x86, $x64, $custom, $custompath, $win, $win64cus, $win86cus, _ ; <=== TheRenamer Tab
  $Anime, $ani_fetch, $Ani_arch, $extra, $ext_fetch, $ext_Arch, $TV_fet, $Mov_fet, _
  $changeMovpath, $changeTVpath,$chn_tv_text, $chn_mov_text, _ ; <=== Fetching Extra Tab
  $TVlog_chk, $TVlogname, $TVlogpath, $Movlog_chk, $Movlogname, $Movlogpath, _
  $Anilog_chk, $Anilogname, $Anilogpath, $extlog_chk, $extlogname, $extlogpath, _  ; <=== Log Tab
  $iniTRpathinfo, $s_inianime, $s_iniextra, $allfet, $s_initv, $s_iniMov, $s_iniAni, $s_iniext ; <=== Save function
;#############Verify if ini file exist already#######################
If not FileExists("TRH_settings.ini") then
_save()
_inisave()
MSGbox(16,"First Step", "Please fill out the Options before pressing the Start button ")
Elseif FileExists("TRH_settings.ini") Then
$_Down = IniReadSection("TRH_settings.ini","TV_Movie_Download")
if $_Down[1][1] = "" and $_Down[2][1] = "" then
   MSGbox(48,"Warning", "mandatory options are missing. Please open options. ")
EndIf
EndIf
;####################################################################
Global $TRpath = IniRead("TRH_settings.ini", "therenamer", "Path", "none"), _
      $_anifet = IniReadSection("TRH_settings.ini","anime"), $_extfet = IniReadSection("TRH_settings.ini","extra"), _
   $_active = IniReadSection("TRH_settings.ini","Active_Sections"), $_logs = IniReadSection("TRH_settings.ini","logs"), _
   $_Down = IniReadSection("TRH_settings.ini","TV_Movie_Download")

This basically checks if inifile exist before starting the initial program. If it does but a certain parameter isnt set, it asked you to open the options and set it. If the file exist and the mandatory parameter is set, it will read the the inifile and populate my variables.

My problem is that if we going into the options GUI and change values, it saves it to the inifiles but in the main GUI the values are not updated. I dont know what code or where i should put thats said code in my script to insure that all of this:

Global $TRpath = IniRead("TRH_settings.ini", "therenamer", "Path", "none"), _
      $_anifet = IniReadSection("TRH_settings.ini","anime"), $_extfet = IniReadSection("TRH_settings.ini","extra"), _
   $_active = IniReadSection("TRH_settings.ini","Active_Sections"), $_logs = IniReadSection("TRH_settings.ini","logs"), _
   $_Down = IniReadSection("TRH_settings.ini","TV_Movie_Download")

Gets updated. Is there a way to always make the script start at the line where i declared my ini variables after i close the option GUI? I hope my request is clear ;) . Forgot to add that the goal is to use each of the ini variables to activate or disactivate sections of my script using " IF " statements

Edited by Saitoh183
Link to comment
Share on other sites

Well i added

$TRpath = IniRead("TRH_settings.ini", "therenamer", "Path", "none"), _
      $_anifet = IniReadSection("TRH_settings.ini","anime"), $_extfet = IniReadSection("TRH_settings.ini","extra"), _
   $_active = IniReadSection("TRH_settings.ini","Active_Sections"), $_logs = IniReadSection("TRH_settings.ini","logs"), _
   $_Down = IniReadSection("TRH_settings.ini","TV_Movie_Download")

to my _inisave function and so settings are sent back to main GUI (unless there is a better way of doing it)

But now i have another problem that i can figure out why its happening.

So each section of my main script is wrapped in a if statement like this:

if $_active[1][1] = "True" Then
$Hasfiles = DirGetSize($tv_down)
ConsoleWrite($hasfiles & " TV" & @CRLF)
if $hasfiles > 0 then
  GuiCtrlSetData($progress1, Round (1/9*100,0))
  GUICtrlSetData($Label1, "Running TheRenamer TV")
  GUICtrlSetData($Label2, Round (1/9*100,0) & '%')
  RunWait($fetchTV)
  GuiCtrlSetData($progress1, Round (2/9*100,0))
  GUICtrlSetData($Label1, "Finish TheRenamer TV")
  GUICtrlSetData($Label2, Round (2/9*100,0) & '%')
  sleep(1000)
  if $Runf = False Then ExitLoop
  If $pausef = True Then _pause ()
  GuiCtrlSetData($progress1, Round (2/9*100,0))
  GUICtrlSetData($Label1, "Updating TV Logs")
  GUICtrlSetData($Label2, Round (2/9*100,0) & '%')
  Sleep(300)
  $file1 = FileRead($renamerlog)
  $file2 = FileOpen($tvlog,1)
  $file3 = FileRead($historylog)
  ;URL for following expression: http://www.autoitscript.com/forum/topic/133363-remove-blank-lines-in-a-file/
  $sRtn = stringreplace(StringRegExpReplace(StringRegExpReplace($file3, "(\v)+", @CRLF), "(^\v*)|(\v*\Z)", ""), "######################## END Session", "")
  FileWriteLine($file2, "############ " & @MDAY & "/" & @MON & "/" & @YEAR & "############ " & @CRLF)
  FileWriteLine($file2, "############ " & @HOUR & "h:" & @MIN & "############ " & @CRLF)
  FileWriteLine($file2,$sRtn)
  FileWriteLine($file2,$file1)
  FileClose($file2)
  Filedelete($historylog)
  GuiCtrlSetData($progress1, Round (3/9*100,0))
  GUICtrlSetData($Label1, "Finish Updating TV Logs")
  GUICtrlSetData($Label2, Round (3/9*100,0) & '%')
  Sleep(1000)
  if $Runf = False Then ExitLoop
  If $pausef = True Then _pause ()
Else
  GuiCtrlSetData($progress1, Round (3/9*100,0))
  GUICtrlSetData($Label1, "No TV Shows Added")
  GUICtrlSetData($Label2, Round (3/9*100,0) & '%')
  sleep(1000)
  if $Runf = False Then ExitLoop
  If $pausef = True Then _pause ()
Endif
ConsoleWrite($hasfiles & " TV2" & @CRLF)
Else
GuiCtrlSetData($progress1, Round (3/9*100,0))
GUICtrlSetData($Label2, Round (3/9*100,0) & '%')
sleep(1000)
Endif

Lets say this section is deactivate when i start the script, then i go into the options, active the section, hit ok which runs _inisave and goes back to main GUI. The line $Hasfiles = DirGetSize($tv_down) will equal some weird number (even if the directory is empty) instead of 0 until i restart the entire script. I hope is clear... :graduated: I will attach my entire script if it can help.

I would like to thank everyone for all there help that they have been giving me in advance ;)

Final.au3

Link to comment
Share on other sites

  • Moderators

Saitoh183,

Are you sure you have the cotrect value set for $tv_down when you call DirGetSize? :graduated:

You initially set $tv_down to be $_down[1][1]. But then in your _inisave function you alter $_down like this:

;[...]
IniWrite("TRH_settings.ini", "TV_Movie_Download", "TVPath", $tv_fet_input)
IniWrite("TRH_settings.ini", "TV_Movie_Download", "MoviePath", $mov_fet_input)
;[...]
$_Down = IniReadSection("TRH_settings.ini", "TV_Movie_Download")
;[...]

but you do not reset $tv_down. ;)

So I wonder if you still have the original value in the variable - you could easily add a ConsoleWrite to check. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Saitoh183,

Are you sure you have the cotrect value set for $tv_down when you call DirGetSize? :graduated:

You initially set $tv_down to be $_down[1][1]. But then in your _inisave function you alter $_down like this:

;[...]
IniWrite("TRH_settings.ini", "TV_Movie_Download", "TVPath", $tv_fet_input)
IniWrite("TRH_settings.ini", "TV_Movie_Download", "MoviePath", $mov_fet_input)
;[...]
$_Down = IniReadSection("TRH_settings.ini", "TV_Movie_Download")
;[...]

but you do not reset $tv_down. :)

So I wonder if you still have the original value in the variable - you could easily add a ConsoleWrite to check. ;)

M23

Thank you for that...figured it out :D ConsoleWrite is a big help. MY program is also finish...now i just have to add a bit of color to the GUI and maybe some color to the buttons ;) and figure out how to make the progress bar stop resetting to its original position on the screen everytime it appears

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...