Page 1 of 1

Leading Zero and Incremented Variables

Posted: Thu Jun 21, 2007 11:39 am
by wcottingame
What I am working on is pretty simple, I just can't seem to figure out how to make it work.  I'm trying to create a file rename task that will rename all the files in a folder with the same name, with an incremented number at the end.  The problem comes with the zeroes.  I need to have leading zeroes so that all the file names are the same number of digits (i.e. 0001, 0002,...0010).  I'm sure I'm just missing something.  I add the variable, then I set up a file loop, then after the file rename, I add the variable increment, I just can't seem to get it to give leading zeroes.  Any help would be appreciated. 
Thank you.

Leading Zero and Incremented Variables

Posted: Fri Jun 22, 2007 4:14 am
by Oleg
Increment variable action just only increments a value and doesn't format the string.
In order to format the resulted string use BASIC script. See an example:

Sub Main
   Dim s As String

   s = RoboTaskApp.ExpandText("{To_format}")
   If Len(s) < 4 Then
      s = String(4-Len(s),"0") + s
   End If

   RoboTaskApp.SetUserVariable("To_format",s)

End Sub

This script addes leading zeros into TO_FORMAT user variables if needed. Maximal length is 4 symbols.

Leading Zero and Incremented Variables

Posted: Fri Jun 22, 2007 11:02 am
by wcottingame
That worked like a charm.  I have however come across another problem.  I need an Alpha (e.i. A, B, C....) variable.  Is this also something that must be done with a basic script?

Leading Zero and Incremented Variables

Posted: Fri Jun 22, 2007 1:07 pm
by wcottingame
Alright, realistically, I have any number of problems with setting variables for different rename processes.  Does anyone have a good source of information about using basic to modify or set variables?

Leading Zero and Incremented Variables

Posted: Sun Jun 24, 2007 10:12 am
by Oleg
Sorry, I'm afraid that I don't understood what you tell about? Describe in more detail please.
You can freely get variables from RoboTask and set or create any user variables

In order to get variable value use ExpandText method
RoboTaskApp.ExpandText("{variable_name}")

In order to set or create user variable use SetUserVariable metod
RoboTaskApp.SetUserVariable("variable_name","any_string")

Also read RoboTask help file (Actions -> Basic). Also, there is a link to help of BASIC language.