Jump to content

Using IniRead and Select Case


damon
 Share

Recommended Posts

@JLogan3o13 I apologize, I did not think of it that way.  I have attached all the code and the Ini File information.  Please let me know if I need to add anything else to help understand what is happening.  thank you.

 

 

 

Guys, I apologize in advance as I did not search for my answer before posting.  I just could not figure out a way to search that made since so I decided to go ahead and post my question.

 

Getting to it.

Background: this is being used to validate file names before moving to a new location.  though i have not included all the code, below is what i am having a problem with.

 I have an ini file that i am reading values from. Func ConfigDefineVars() -- I read the value of $ValidationRDA and everything is good then I set 

$CaseRDALocationCheck = '$SplitFile[$ValidationRDALocation]' <> $ValidationRDA

the code that will be used in the select case in Func FileSplitCount().  The problem i have is that even though the numbers = each other they are not recognizing as =.  

This is what i am getting in my log file i create.

2017-12-04 14:09:53 : RDA was 2403 should have been 2403:

If I move $SplitFile[$ValidationRDALocation] <> $ValidationRDA to the Case line under the function it works correctly.

 

I think this has to do with my use of ' ' around the '$SplitFile[$ValidationRDALocation]' but  i don't know what option i have in Func ConfigDefineVars I am not ready to define $SplitFile.  I have tried adding it to my Global Vars at the top of my script but that did not seem to help.

There will be more fail this is just the first one in the select case.

 

Any help or ideas would be greatly appreciated.

 

thanks,

Damon

Example of a filename used.

DWRSSD-37087-95-026.%-064.00-Tatum Family %-%-1230 Academy Rd-%-PERM-TRUE-2403.pdf

This file will fail on the 95, it should be 095.  The problem i am getting is with the 2403 it fails even though the ini file value ValidationRDA = 2403 

 

 

Ini File:

[SSD_FolderPaths]
pendingFolder=C:\Users\bg01152\Desktop\SSD Test\pending
reviewFolder=C:\Users\bg01152\Desktop\SSD Test\review
completedFolder=C:\Users\bg01152\Desktop\SSD Test\Completed
FileNetProperties=DocumentTitle,ZipCode,County,MapAndGroupID,ParcelID,PropertyOwner,Subdivision,StreetAddress,LotNumber,DocumentType,Approved,RDANumber
ValidationDocumentTitle=DWRSSD
ValidationDocumentTitleLocation=1
ValidationCountyCodeLocation=3
ValidationRDA=2403
ValidationRDALocation=12
Validation3=TRUE
Validation3Location=11
Validation4=PERM
Validation4Location=10

 

 

#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>

;------------Global Vars ---------------------
Global $SplitFile, $aFileList, $FileLog, $dFolder, $sFolder, $cFolder, $ConfigFile, $t
Global $ValidationDocumentTitle, $ValidationDocumentTitleLocation, $ValidationCountyCodeLocation, $ValidationRDA
Global $ValidationRDALocation, $Validation3, $Validation3Location, $Validation4, $Validation4Location, $FileNetPropertiesSplit
Global $CaseCountyCheck, $CaseRDALocationCheck, $CaseValidation3LocationCheck, $CaseValidation4LocationCheck, $SplitFile


;;--------------------------------Check and Read Config files--------------------------------
        $SysConfigFile = @ScriptDir & "\SysConfig.ini"
            ;----------------PreCheck for Config File--------------
                If FileExists ($SysConfigFile) <> 1 Then
                    Exit
                EndIf
            ;----------------End PreCheck--------------------------
    $FileNetEXE = @ScriptDir & "\" & IniRead ($SysConfigFile, "FileNetUploader","FileName","")
    $delimiter = IniRead ($SysConfigFile, "FileInformation", "Delimiter","")
    $Filter = IniRead ($SysConfigFile, "FileInformation", "Filter", "")
        $ConfigFile = @ScriptDir & "\Config.ini"
            ;----------------PreCheck for Config File--------------
                If FileExists ($ConfigFile) <> 1 Then
                    Exit
                EndIf
            ;----------------End PreCheck--------------------------
;;--------------------------------------------------------------------------------------------
$Sections = IniReadSectionNames ($ConfigFile)
;MsgBox (0,"test", $Sections[0] & @CRLF & $Sections[1] & @CRLF & $Sections[2] & @CRLF & $Sections[3] & @CRLF & $Sections[4]);TESTING ONLY - DELETE WHEN DONE
$p = 0
Do
    $t = 0 ;used for precheck
    $p = $p + 1
    ConfigDefineVars($Sections[$p])

    ;MsgBox(0,"ConfigDefineVars", $sFolder & @CRLF & $dFolder & @CRLF & $cFolder);TESTING ONLY - DELETE WHEN DONE
    PreCheck($dFolder, $sFolder, $cFolder) ;Runs a Pre-check to make sure folder structure exists before running the program
    If $t = 0 Then
        ;MsgBox(0,"PreCheck Run", "Running next functions");TESTING ONLY - DELETE WHEN DONE
        ListArray($sFolder, $Filter) ;Puts File Names in String Array
        ;_ArrayDisplay ($aFileList, $Sections[$p])
        If $t = 0 Then

            FileSplitCount($dFolder, $aFileList) ;Takes filename String Array and splits by $delimiter
            ;MsgBox(0,"PreCheck Run2", "Running split function");TESTING ONLY - DELETE WHEN DONE
        Else
            ;MsgBox(0,"PreCheck Run2", "Skipping split function");TESTING ONLY - DELETE WHEN DONE
        EndIf
    Else
        ;MsgBox(0,"PreCheck Run", "Skipping next functions");TESTING ONLY - DELETE WHEN DONE
    EndIf
Until $p = $Sections[0]


ExitScript() ;Exit script Function



Func ConfigDefineVars($SectionsNum);Defines Variables from config file Sections
    $sFolder = IniRead ($ConfigFile, $SectionsNum, "pendingFolder","") ;Pending Folder, Folder that is awaiting the process
    $dFolder = IniRead ($ConfigFile, $SectionsNum, "reviewFolder","") ;Review Folder, Files that did not pass validation check and division needs to review
    $cFolder = IniRead ($ConfigFile, $SectionsNum, "completedFolder","") ;Completed Folder, Once process is completed this would be location files get moved to
    $FileNetProperties = IniRead ($ConfigFile, $SectionsNum, "FileNetProperties","")
    $FileNetPropertiesSplit = StringSplit ($FileNetProperties,",")
    $ValidationDocumentTitle = IniRead ($ConfigFile, $SectionsNum, "ValidationDocumentTitle","")
    $ValidationDocumentTitleLocation = IniRead ($ConfigFile, $SectionsNum, "ValidationDocumentTitleLocation","")
    $ValidationCountyCodeLocation = IniRead ($ConfigFile, $SectionsNum, "ValidationCountyCodeLocation","")
    $ValidationRDA = IniRead ($ConfigFile, $SectionsNum, "ValidationRDA","")
    $ValidationRDALocation = IniRead ($ConfigFile, $SectionsNum, "ValidationRDALocation","")
    $Validation3 = IniRead ($ConfigFile, $SectionsNum, "Validation3","")
    $Validation3Location = IniRead ($ConfigFile, $SectionsNum, "Validation3Location","")
    $Validation4 = IniRead ($ConfigFile, $SectionsNum, "Validation4","")
    $Validation4Location = IniRead ($ConfigFile, $SectionsNum, "Validation4Location","")


                If $ValidationCountyCodeLocation = 999 Then
                    $CaseCountyCheck = 1 <> 1
                Else
                    ;MsgBox (0,"test of county code", "location = " &$ValidationCountyCodeLocation)
                    $CaseCountyCheck = StringLen('$SplitFile[$ValidationCountyCodeLocation]') <> 3 ; Checks for 3 digit County Code
                EndIf

                If $ValidationRDALocation = 999 Then
                    $CaseRDALocationCheck = 1 <> 1
                Else
                    $CaseRDALocationCheck = '$SplitFile[$ValidationRDALocation]' <> $ValidationRDA ; Checks for 4 Digit RDA
                EndIf

                If $Validation3Location = 999 Then
                    $CaseValidation3LocationCheck = 1 <> 1
                Else
                    $CaseValidation3LocationCheck = '$SplitFile[$Validation3Location]' <> $Validation3 ; Checks that Approved = True
                EndIf

                If $Validation4Location = 999 Then
                    $CaseValidation4LocationCheck = 1 <> 1
                Else
                    $CaseValidation3LocationCheck = '$SplitFile[$Validation4Location]' <> $Validation4 ; Checks that Document Type = PERM
                EndIf


EndFunc
Func ValidationCheck ($check1)
    $blank = StringLen ($check1)
    If $check1 Then
        EndIf
EndFunc
Func PreCheck($dFolder, $sFolder, $cFolder)
    ;----------------PreCheck for Destination Folder--------------
        If FileExists ($dFolder) <> 1 Then
            $t = 1
            Return
        Else
            $FileLog = FileOpen($dFolder & "\FileLog.log", 1)
        EndIf
    ;----------------End PreCheck--------------------------
    ;----------------PreCheck for Source Folder--------------
        If FileExists ($sFolder) <> 1 Then
            _FileWriteLog($FileLog, "Path to Pending Folder -- " & $sFolder & " -- does not exist")
            $t = 1
            Return
        EndIf
    ;----------------End PreCheck--------------------------
    ;----------------PreCheck for Completed Folder---------
        If FileExists ($cFolder) <> 1 Then
            _FileWriteLog($FileLog, "Path to Completed Folder -- " & $cFolder & " -- does not exist")
            $t = 1
            Return
        EndIf
    ;----------------End PreCheck--------------------------
EndFunc
Func ListArray($sFolder, $Filter)
    $aFileList = _FileListToArray($sFolder, $Filter, 1) ;Create an array of files from the source folder filtering by filetype
                                                        ;in the config.ini files for the specified section
    If @error = 1 Then
        ;MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.")
        _FileWriteLog($FileLog, "Path to File(s) is Invalid")
        $t = 1
        Return
    EndIf
    If @error = 4 Then
        ;MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.")
        _FileWriteLog($FileLog, "No File(s) were found, exiting.")
        $t = 1
        Return
    EndIf
EndFunc   ;==>ListArray

 

 

 

 

Edited by damon
Needed to Add more information to get support.

It always amazes me how one little thing can cause so much havoc

Link to comment
Share on other sites

  • Moderators

@damon I will offer that you are asking a lot when requesting support on a script where you don't post any runnable code, the format of your INI files, content of associated files, etc. and instead leave everyone to guess at what you're doing exactly. Even a small reproducer that shows the issue, if you are unable to post all of the code, is preferable to having to guess our way through non-running functions with mystery variables.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Still not runnable code. Upload an ini, and code that runs and jams on the issue you have.

What is this line supposed to do?

$CaseRDALocationCheck = '$SplitFile[$ValidationRDALocation]' <> $ValidationRDA

 

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

@careca I thought i had copied all the code, may fault.  the problem section is what did not even copy.  sorry.  

I did forget i divided the ini file into two different files so that I have a system ini and a user ini. 

This line you referred to above and these others is the problem i am having.  I realize i am trying to call $SplitFile array before it has been defined.  not trying to call the code but i need it set to a var so i can call it in the Select/Case in Func FileSplitCount().

$CaseCountyCheck = 'StringLen($SplitFile[$ValidationCountyCodeLocation]) <> 3' ; Checks for 3 digit County Code
                    $CaseRDALocationCheck = '$SplitFile[$ValidationRDALocation] <> $ValidationRDA' ; Checks for 4 Digit RDA
                    $CaseValidation3LocationCheck = '$SplitFile[$Validation3Location] <> $Validation3' 
                    $CaseValidation3LocationCheck = '$SplitFile[$Validation4Location] <> $Validation4'

Another thing to note.

In the Config.ini there are 3 directories.  you will need to have 3 folders created for the script to run and be pointed to.  Using just a blank text file and name it 

DWRSSD-37087-95-026.%-064.00-Tatum Family %-%-1230 Academy Rd-%-PERM-TRUE-2403.pdf

Make sure this file is in the Pending folder.  The script should move it to the review folder when ran and the error log file should say it was moved because the file failed from not being a 3 digit county code.  This file will fail on the 95, it should be 095.  The problem i am getting is with the 2403 it fails even though the ini file value ValidationRDA = 2403 

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=C:\Users\bg01152\Desktop\Split Program\Split no Upload\Split-NoUpload.Exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------

    AutoIt Version: 3.3.14.2
    Author:         Damon Pence

    Script Function:
    Files is used for File Pickup process.  This file has (2) ini files used for configurations.
    SysConfig - used for primary functions of program
    Config - Used to configure path and other options for each division

#ce ----------------------------------------------------------------------------
#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>

;------------Global Vars ---------------------
Global $SplitFile, $aFileList, $FileLog, $dFolder, $sFolder, $cFolder, $ConfigFile, $t
Global $ValidationDocumentTitle, $ValidationDocumentTitleLocation, $ValidationCountyCodeLocation, $ValidationRDA
Global $ValidationRDALocation, $Validation3, $Validation3Location, $Validation4, $Validation4Location, $FileNetPropertiesSplit
Global $CaseCountyCheck, $CaseRDALocationCheck, $CaseValidation3LocationCheck, $CaseValidation4LocationCheck, $SplitFile


;;--------------------------------Check and Read Config files--------------------------------
        $SysConfigFile = @ScriptDir & "\SysConfig.ini"
            ;----------------PreCheck for Config File--------------
                If FileExists ($SysConfigFile) <> 1 Then
                    Exit
                EndIf
            ;----------------End PreCheck--------------------------
    $FileNetEXE = @ScriptDir & "\" & IniRead ($SysConfigFile, "FileNetUploader","FileName","")
    $delimiter = IniRead ($SysConfigFile, "FileInformation", "Delimiter","")
    $Filter = IniRead ($SysConfigFile, "FileInformation", "Filter", "")
        $ConfigFile = @ScriptDir & "\Config.ini"
            ;----------------PreCheck for Config File--------------
                If FileExists ($ConfigFile) <> 1 Then
                    Exit
                EndIf
            ;----------------End PreCheck--------------------------
;;--------------------------------------------------------------------------------------------
$Sections = IniReadSectionNames ($ConfigFile)
;MsgBox (0,"test", $Sections[0] & @CRLF & $Sections[1] & @CRLF & $Sections[2] & @CRLF & $Sections[3] & @CRLF & $Sections[4]);TESTING ONLY - DELETE WHEN DONE
$p = 0
Do
    $t = 0 ;used for precheck
    $p = $p + 1
    ConfigDefineVars($Sections[$p])

    ;MsgBox(0,"ConfigDefineVars", $sFolder & @CRLF & $dFolder & @CRLF & $cFolder);TESTING ONLY - DELETE WHEN DONE
    PreCheck($dFolder, $sFolder, $cFolder) ;Runs a Pre-check to make sure folder structure exists before running the program
    If $t = 0 Then
        ;MsgBox(0,"PreCheck Run", "Running next functions");TESTING ONLY - DELETE WHEN DONE
        ListArray($sFolder, $Filter) ;Puts File Names in String Array
        ;_ArrayDisplay ($aFileList, $Sections[$p])
        If $t = 0 Then

            FileSplitCount($dFolder, $aFileList) ;Takes filename String Array and splits by $delimiter
            ;MsgBox(0,"PreCheck Run2", "Running split function");TESTING ONLY - DELETE WHEN DONE
        Else
            ;MsgBox(0,"PreCheck Run2", "Skipping split function");TESTING ONLY - DELETE WHEN DONE
        EndIf
    Else
        ;MsgBox(0,"PreCheck Run", "Skipping next functions");TESTING ONLY - DELETE WHEN DONE
    EndIf
Until $p = $Sections[0]


ExitScript() ;Exit script Function



Func ConfigDefineVars($SectionsNum);Defines Variables from config file Sections
    $sFolder = IniRead ($ConfigFile, $SectionsNum, "pendingFolder","") ;Pending Folder, Folder that is awaiting the process
    $dFolder = IniRead ($ConfigFile, $SectionsNum, "reviewFolder","") ;Review Folder, Files that did not pass validation check and division needs to review
    $cFolder = IniRead ($ConfigFile, $SectionsNum, "completedFolder","") ;Completed Folder, Once process is completed this would be location files get moved to
    $FileNetProperties = IniRead ($ConfigFile, $SectionsNum, "FileNetProperties","")
    $FileNetPropertiesSplit = StringSplit ($FileNetProperties,",")
    $ValidationDocumentTitle = IniRead ($ConfigFile, $SectionsNum, "ValidationDocumentTitle","")
    $ValidationDocumentTitleLocation = IniRead ($ConfigFile, $SectionsNum, "ValidationDocumentTitleLocation","")
    $ValidationCountyCodeLocation = IniRead ($ConfigFile, $SectionsNum, "ValidationCountyCodeLocation","")
    $ValidationRDA = IniRead ($ConfigFile, $SectionsNum, "ValidationRDA","")
    $ValidationRDALocation = IniRead ($ConfigFile, $SectionsNum, "ValidationRDALocation","")
    $Validation3 = IniRead ($ConfigFile, $SectionsNum, "Validation3","")
    $Validation3Location = IniRead ($ConfigFile, $SectionsNum, "Validation3Location","")
    $Validation4 = IniRead ($ConfigFile, $SectionsNum, "Validation4","")
    $Validation4Location = IniRead ($ConfigFile, $SectionsNum, "Validation4Location","")

                If $ValidationCountyCodeLocation = 999 Then
                    $CaseCountyCheck = 1 <> 1
                Else
                    ;MsgBox (0,"test of county code", "location = " &$ValidationCountyCodeLocation)
                    $CaseCountyCheck = 'StringLen($SplitFile[$ValidationCountyCodeLocation]) <> 3' ; Checks for 3 digit County Code
                EndIf

                If $ValidationRDALocation = 999 Then
                    $CaseRDALocationCheck = 1 <> 1
                Else
                    $CaseRDALocationCheck = '$SplitFile[$ValidationRDALocation] <> $ValidationRDA' ; Checks for 4 Digit RDA
                EndIf

                If $Validation3Location = 999 Then
                    $CaseValidation3LocationCheck = 1 <> 1
                Else
                    $CaseValidation3LocationCheck = '$SplitFile[$Validation3Location] <> $Validation3' ;Checks Validation3
                EndIf

                If $Validation4Location = 999 Then
                    $CaseValidation4LocationCheck = 1 <> 1
                Else
                    $CaseValidation3LocationCheck = '$SplitFile[$Validation4Location] <> $Validation4' ; Checks Validation4
                EndIf



EndFunc
Func ValidationCheck ($check1)
    $blank = StringLen ($check1)
    If $check1 Then
        EndIf
EndFunc
Func PreCheck($dFolder, $sFolder, $cFolder)
    ;----------------PreCheck for Destination Folder--------------
        If FileExists ($dFolder) <> 1 Then
            $t = 1
            Return
        Else
            $FileLog = FileOpen($dFolder & "\FileLog.log", 1)
        EndIf
    ;----------------End PreCheck--------------------------
    ;----------------PreCheck for Source Folder--------------
        If FileExists ($sFolder) <> 1 Then
            _FileWriteLog($FileLog, "Path to Pending Folder -- " & $sFolder & " -- does not exist")
            $t = 1
            Return
        EndIf
    ;----------------End PreCheck--------------------------
    ;----------------PreCheck for Completed Folder---------
        If FileExists ($cFolder) <> 1 Then
            _FileWriteLog($FileLog, "Path to Completed Folder -- " & $cFolder & " -- does not exist")
            $t = 1
            Return
        EndIf
    ;----------------End PreCheck--------------------------
EndFunc
Func ListArray($sFolder, $Filter)
    $aFileList = _FileListToArray($sFolder, $Filter, 1) ;Create an array of files from the source folder filtering by filetype
                                                        ;in the config.ini files for the specified section
    If @error = 1 Then
        ;MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.")
        _FileWriteLog($FileLog, "Path to File(s) is Invalid")
        $t = 1
        Return
    EndIf
    If @error = 4 Then
        ;MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.")
        _FileWriteLog($FileLog, "No File(s) were found, exiting.")
        $t = 1
        Return
    EndIf
EndFunc   ;==>ListArray
Func FileSplitCount($dFolder, $aFileList)

    ;$FileLog = FileOpen($dFolder & "\FileLog.log", 1)
    $i = 0
    $y = $aFileList[0]
    Do
        $i = $i + 1
        $SplitFilename = StringTrimRight ($aFileList[$i], 4);strips .pdf from file before creating array
        $SplitFile = StringSplit($SplitFilename, $delimiter);Splits the filename in to array in order to perform validation on each part

                



        Select;Conditions for FileName to match so that they will upload correctly into FileNet
            Case $SplitFile[0] <> $FileNetPropertiesSplit[0] ;$FileNetPropertiesSplit[0] will give the number of properties in the config file for FileNet, this is used for validation placement
                FileMove($sFolder & "\" & $aFileList[$i], $dFolder & "\")
                _FileWriteLog($FileLog, "File has " & $SplitFile[0] & " '-' Requirement is 12::" & $aFileList[$i])
            Case $SplitFile[$ValidationDocumentTitleLocation] <> $ValidationDocumentTitle ; Checks that Filename = DWRSSD
                FileMove($sFolder & "\" & $aFileList[$i], $dFolder & "\")
                _FileWriteLog($FileLog, "File is not Named Correctly with 'DWRSSD'::" & $aFileList[$i])
            Case $CaseRDALocationCheck
                FileMove($sFolder & "\" & $aFileList[$i], $dFolder & "\")
                _FileWriteLog($FileLog, "RDA was " & $SplitFile[$ValidationRDALocation] & " should have been " & $ValidationRDA & "::" & $aFileList[$i])
            Case $CaseCountyCheck
                FileMove($sFolder & "\" & $aFileList[$i], $dFolder & "\")
                _FileWriteLog($FileLog, "File county code must be 3 digits::" & $aFileList[$i])
            Case $CaseValidation3LocationCheck
                FileMove($sFolder & "\" & $aFileList[$i], $dFolder & "\")
                _FileWriteLog($FileLog, "Validation is set to '" & $SplitFile[$Validation3Location] & "' Validation should be set to " & $Validation3 & "::" & $aFileList[$i])
            Case $CaseValidation4LocationCheck
                FileMove($sFolder & "\" & $aFileList[$i], $dFolder & "\")
                _FileWriteLog($FileLog, "Validation is set to '" & $SplitFile[$Validation4Location] & "' Validation should be set to " & $Validation4 & "::" & $aFileList[$i])
        EndSelect
    Until $i = $y
EndFunc   ;==>FileSplitCount
Func CopyCompleted()
EndFunc
Func ExitScript()
    _FileWriteLog($FileLog, "Complete.")
    FileClose ($FileLog)
EndFunc   ;==>ExitScript

thanks,

Damon

SysConfig.ini

Config.ini

It always amazes me how one little thing can cause so much havoc

Link to comment
Share on other sites

Yeah, but i still dont understand lines like this:

$CaseRDALocationCheck = '$SplitFile[$ValidationRDALocation] <> $ValidationRDA'

Maybe im missing something, but i just never seen anything like it.

So $CaseRDALocationCheck Equals a  '$SplitFile[$ValidationRDALocation] different than $ValidationRDA

And all between quotes, so it's treated as a string...

Can you break it down to me?

I always use something like this:

$CaseCountyCheck = StringLen($SplitFile[$ValidationCountyCodeLocation]) ; Checks for 3 digit County Code
If $CaseCountyCheck <> 3 Then
    MsgBox(64, '$CaseCountyCheck', $CaseCountyCheck)
EndIf

 

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

The problem is that there may be times where the $validationCountyCodeLocation may be set to 999, so if it is I put an if statement in to set

$CaseCountyCheck = 1 <> 1

so that it would set the expression to FALSE in the case and it would proceed to the next case expression.

I am probably going about this structure all wrong.  What i am trying to accomplish is a filename validation that reads from a config file.  I want to add multiple sections to that config so that i can validate different files in different directories.  most all that is working, but there may come a time where $validation3 is not needed so i was going to use 999 as basically a NULL in the ini file and when this is read with iniread it would set to a False so the case would be skipped and the next case would be evaluated.  

What i am trying to do and not sure this is even possible is set the $CaseCountyCheck = expression 

$CaseCountyCheck = StringLen($SplitFile[$ValidationCountyCodeLocation]) <> 3
select
    Case $CaseCountyCheck
            MsgBox(64, "CaseCheck", "This case validated as county code not 3 digits")
Endselect

Depending on the Value of $ValidationCountyCodeLocation depends if i need the case to evaluate it. -- This is really my ultimate goal, if the value is blank when i read the ini file then i do not want it evaluated but if it has a value then i need it to be evaluated.

It always amazes me how one little thing can cause so much havoc

Link to comment
Share on other sites

Here's how i do this:

$CaseCountyCheck = Whatever, the iniread or something
If $CaseCountyCheck <> 3 Then
    MsgBox(64, 'Result', 'different than 3')
ElseIf $CaseCountyCheck = '' Then
    MsgBox(64, 'Result', 'empty')
ElseIf $CaseCountyCheck = 'meh' Then
    MsgBox(64, 'Result', 'meh')
ElseIf $CaseCountyCheck = 12314523562 Then
    MsgBox(64, 'Result', '12314523562')
EndIf

See what i mean? I dont use Select - Case all that much, so can't help on that, im used to "If's.

$CaseCountyCheck = 1 <> 1

to make it "false" seems "dirty" to me. But if it works hey.

They way i learned, i should first set the variable, then compare it to whatever i need, i wouldn't know how to do stuff if i used that method, seems more complicated.

I just remembered where i use select and case:

$iMsgBoxAnswer = MsgBox(8245, "Startup", "failed! " & @CRLF & "Error Returned: " & @error & @CRLF & "Do you want to retry?")
            Select
                Case $iMsgBoxAnswer = 4 ;Retry
                    Whatever()
                Case $iMsgBoxAnswer = 2 ;Cancel
                    Exit
            EndSelect

Something like this, else, i use other method.

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

@careca Thank you so much for your help.  I was over complicating the structure and you helped me to realize that.  thank you.  I got it going using your suggestion of replacing the Select/Case with If statements.  This gave me the ability to test for two expressions which is what i was needing to move through the code.

 

Here is what i did and it works great.

If $SplitFile[0] <> $FileNetPropertiesSplit[0] Then;$FileNetPropertiesSplit[0] will give the number of properties in the config file for FileNet, this is used for validation placement
                FileMove($sFolder & "\" & $aFileList[$i], $dFolder & "\")
                _FileWriteLog($FileLog, "File has " & $SplitFile[0] & " '-' Requirement is 12::" & $aFileList[$i])
        ElseIf $SplitFile[$ValidationDocumentTitleLocation] <> $ValidationDocumentTitle Then; Checks that Filename = DWRSSD
                FileMove($sFolder & "\" & $aFileList[$i], $dFolder & "\")
                _FileWriteLog($FileLog, "File is not Named Correctly with 'DWRSSD'::" & $aFileList[$i])
        ElseIf $ValidationRDALocation <> 999 And $SplitFile[$ValidationRDALocation] <> $ValidationRDA Then
                ;Checks Validation of RDA number
                    FileMove($sFolder & "\" & $aFileList[$i], $dFolder & "\")
                    _FileWriteLog($FileLog, "RDA was " & $SplitFile[$ValidationRDALocation] & " should have been " & $ValidationRDA & "::" & $aFileList[$i])
        ElseIf $ValidationCountyCodeLocation <> 999 And StringLen($SplitFile[$ValidationCountyCodeLocation]) <> 3 Then
                    FileMove($sFolder & "\" & $aFileList[$i], $dFolder & "\")
                    _FileWriteLog($FileLog, "File county code must be 3 digits::" & $aFileList[$i])
        ElseIf $Validation3Location <> 999 And $SplitFile[$Validation3Location] <> $Validation3 Then
                    FileMove($sFolder & "\" & $aFileList[$i], $dFolder & "\")
                    _FileWriteLog($FileLog, "Validation is set to '" & $SplitFile[$Validation3Location] & "' Validation should be set to " & $Validation3 & "::" & $aFileList[$i])
        ElseIf $Validation4Location <> 999 And $SplitFile[$Validation4Location] <> $Validation4 Then
                    FileMove($sFolder & "\" & $aFileList[$i], $dFolder & "\")
                    _FileWriteLog($FileLog, "Validation is set to '" & $SplitFile[$Validation4Location] & "' Validation should be set to " & $Validation4 & "::" & $aFileList[$i])

        EndIf

 

It always amazes me how one little thing can cause so much havoc

Link to comment
Share on other sites

Im glad i could help. ;)

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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

×
×
  • Create New...