Announcement

Collapse
No announcement yet.

Prb with Count Delimited Strings

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Prb with Count Delimited Strings

    Hello,

    I've a little problem with the Count Delimited Strings command...
    First, I do a search of files in a specific location...result stored in %files% variable.
    Then, I will count how many files are in this variable: I use a count delimited Stings command...the result is stored in %nbr% variable.

    If there is files in the directory, the correct number of files is diplayed --> no prb
    If there is NO file in the directory, my %nbr% variable is equal to "1"...

    Have I done something wrong ??

    Thank you.

    Arnaud

  • #2
    Re: Prb with Count Delimited Strings

    What you are going to want to do is:

    %Files% = File.Search(.......)
    IF (%Files% = "")
    %NumberOfFiles% = 0
    ELSE
    %NumberOfFiles% = String.CountDelimitedStrings(..)
    END IF

    This will account for a blank file search result. This is not a bug, rather it is just the way that the count delimited string action works.

    Comment


    • #3
      Re: Prb with Count Delimited Strings

      arnaud,

      From what I can tell you are doing things correctly. You may want to add a check to see if the %nbr% = 1 then check the %Files% string to see if the one item in the list is blank. If it is then you can let the user know that the directory was empty. Here is an example of that I mean.

      // Asks the user to select a directory
      %FullPath% = Dialog.FolderBrowse ("Folder Select", "%MyDocumentsDir%")
      // Perform a search on the selected directory
      %Files% = File.Search ("*.*", CustomPaths)
      //Count the files in the %Files% delimited string
      %nbr% = String.CountDelimitedStrings ("%Files%", ";;")
      // Now we will check to see if the string contains only a single entry
      IF (%nbr% = 1)
      %StrTest% = String.GetDelimitedString ("%Files%", ";;", 0)
      // If it contains only a single entry we will then check to see if it is blank
      // If blank we will give the user an error
      IF (%StrTest% = "")
      %Result% = Dialog.MessageBox ("Error", "There are no files in your dir...", Ok, Exclamation)
      END IF
      END IF
      // Debugging line to see what was entered
      %Result% = Dialog.MessageBox ("Title", "%FullPath% %Files% %nbr%", Ok, Question)

      -----------Cut and Paste version---------------
      <IR_ACTIONS_LIST>
      <Action name="Folder Browse">
      <Type>91</Type>
      <Function>0</Function>
      <DTIndentLevel>0</DTIndentLevel>
      <Enabled>1</Enabled>
      <ErrorHandling>
      <UserNotificationMode>2</UserNotificationMode>
      <CustomErrorMessage/>
      <OnErrorAction>0</OnErrorAction>
      <JumpToLabel/>
      </ErrorHandling>
      <DefaultDirectory>%MyDocumentsDir%</DefaultDirectory>
      <Variable>%FullPath%</Variable>
      <DialogTitle>Folder Select</DialogTitle>
      <DialogType>0</DialogType>
      </Action>
      <Action name="Search">
      <Type>18</Type>
      <Function>0</Function>
      <DTIndentLevel>0</DTIndentLevel>
      <Enabled>1</Enabled>
      <ErrorHandling>
      <UserNotificationMode>2</UserNotificationMode>
      <CustomErrorMessage/>
      <OnErrorAction>0</OnErrorAction>
      <JumpToLabel/>
      </ErrorHandling>
      <Variable>%Files%</Variable>
      <Delimiter>;;</Delimiter>
      <FileName>*.*</FileName>
      <LocalFixedDrives>0</LocalFixedDrives>
      <RemoteDrives>0</RemoteDrives>
      <RemovableDrives>0</RemovableDrives>
      <CDROMDrives>0</CDROMDrives>
      <SpecificDirectoriesDrives>1</SpecificDirectoriesDrives>
      <CustomDirectoriesDrives>%FullPath%</CustomDirectoriesDrives>
      <RecurseCustom>0</RecurseCustom>
      <DialogTitle>Searching for Files</DialogTitle>
      <DialogText>Searching for files. This may take a few moments.</DialogText>
      <ShowDialog>1</ShowDialog>
      </Action>
      <Action name="Count Delimited Strings">
      <Type>63</Type>
      <Function>0</Function>
      <DTIndentLevel>0</DTIndentLevel>
      <Enabled>1</Enabled>
      <ErrorHandling>
      <UserNotificationMode>2</UserNotificationMode>
      <CustomErrorMessage/>
      <OnErrorAction>0</OnErrorAction>
      <JumpToLabel/>
      </ErrorHandling>
      <Variable>%nbr%</Variable>
      <Source>%Files%</Source>
      <Delimiter>;;</Delimiter>
      </Action>
      <Action name="IF">
      <Type>200</Type>
      <Function>1</Function>
      <DTIndentLevel>0</DTIndentLevel>
      <Enabled>1</Enabled>
      <ErrorHandling>
      <UserNotificationMode>2</UserNotificationMode>
      <CustomErrorMessage/>
      <OnErrorAction>0</OnErrorAction>
      <JumpToLabel/>
      </ErrorHandling>
      <Condition>%nbr% = 1</Condition>
      </Action>
      <Action name="Get Delimited String">
      <Type>64</Type>
      <Function>0</Function>
      <DTIndentLevel>0</DTIndentLevel>
      <Enabled>1</Enabled>
      <ErrorHandling>
      <UserNotificationMode>2</UserNotificationMode>
      <CustomErrorMessage/>
      <OnErrorAction>0</OnErrorAction>
      <JumpToLabel/>
      </ErrorHandling>
      <Variable>%StrTest%</Variable>
      <Source>%Files%</Source>
      <Delimiter>;;</Delimiter>
      <ItemIndex>0</ItemIndex>
      </Action>
      <Action name="IF">
      <Type>200</Type>
      <Function>1</Function>
      <DTIndentLevel>0</DTIndentLevel>
      <Enabled>1</Enabled>
      <ErrorHandling>
      <UserNotificationMode>2</UserNotificationMode>
      <CustomErrorMessage/>
      <OnErrorAction>0</OnErrorAction>
      <JumpToLabel/>
      </ErrorHandling>
      <Condition>%StrTest% = ""</Condition>
      </Action>
      <Action name="Message Box">
      <Type>5</Type>
      <Function>0</Function>
      <DTIndentLevel>1</DTIndentLevel>
      <Enabled>1</Enabled>
      <ErrorHandling>
      <UserNotificationMode>2</UserNotificationMode>
      <CustomErrorMessage/>
      <OnErrorAction>0</OnErrorAction>
      <JumpToLabel/>
      </ErrorHandling>
      <DialogTitle>Error</DialogTitle>
      <DialogMessage>There are no files in your directory!</DialogMessage>
      <Icon>1</Icon>
      <Variable>%Result%</Variable>
      <DialogType>0</DialogType>
      <DefaultButton>0</DefaultButton>
      </Action>
      <Action name="END IF">
      <Type>201</Type>
      <Function>1</Function>
      <DTIndentLevel>0</DTIndentLevel>
      <Enabled>1</Enabled>
      <ErrorHandling>
      <UserNotificationMode>2</UserNotificationMode>
      <CustomErrorMessage/>
      <OnErrorAction>0</OnErrorAction>
      <JumpToLabel/>
      </ErrorHandling>
      </Action>
      <Action name="END IF">
      <Type>201</Type>
      <Function>1</Function>
      <DTIndentLevel>0</DTIndentLevel>
      <Enabled>1</Enabled>
      <ErrorHandling>
      <UserNotificationMode>2</UserNotificationMode>
      <CustomErrorMessage/>
      <OnErrorAction>0</OnErrorAction>
      <JumpToLabel/>
      </ErrorHandling>
      </Action>
      <Action name="Message Box">
      <Type>5</Type>
      <Function>0</Function>
      <DTIndentLevel>0</DTIndentLevel>
      <Enabled>1</Enabled>
      <ErrorHandling>
      <UserNotificationMode>2</UserNotificationMode>
      <CustomErrorMessage/>
      <OnErrorAction>0</OnErrorAction>
      <JumpToLabel/>
      </ErrorHandling>
      <DialogTitle>Title</DialogTitle>
      <DialogMessage>%FullPath%
      %Files%
      %nbr%</DialogMessage>
      <Icon>3</Icon>
      <Variable>%Result%</Variable>
      <DialogType>0</DialogType>
      <DefaultButton>0</DefaultButton>
      </Action>
      </IR_ACTIONS_LIST>
      TJ-Tigger
      "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
      "Draco dormiens nunquam titillandus."
      Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

      Comment


      • #4
        Re: Prb with Count Delimited Strings

        Adam beat me to it, even while washing his hair. There is my answer if you need it.
        TJ-Tigger
        "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
        "Draco dormiens nunquam titillandus."
        Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

        Comment


        • #5
          Thank You !

          Thank You Adam and TJ Tigger !!

          Your solution works fine for my project!
          I didn't understand the result "1", because no file were in the directory...It's not very logic but it's the way the command works ;o)

          Thank you very much for your help !

          Arnaud

          Comment

          Working...
          X