Leading Zero and Incremented Variables

Discuss RoboTask here
Post Reply
wcottingame
Posts: 4
Joined: Thu Jun 21, 2007 11:33 am

Leading Zero and Incremented Variables

Post 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.
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Leading Zero and Incremented Variables

Post 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.
wcottingame
Posts: 4
Joined: Thu Jun 21, 2007 11:33 am

Leading Zero and Incremented Variables

Post 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?
wcottingame
Posts: 4
Joined: Thu Jun 21, 2007 11:33 am

Leading Zero and Incremented Variables

Post 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?
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Leading Zero and Incremented Variables

Post 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.
Last edited by Oleg on Sun Jun 24, 2007 2:13 pm, edited 1 time in total.
Post Reply