FlowHeater - The Data Import / Export Specialist
Welcome, Guest
Username: Password: Remember me
See also the general examples available, which may answer your question: Hello World 1 / 2 / 3 , format numbers as character strings , simple If-Then-Else , complex If-Then-ElseIf , filtering and grouping data , consolidate grouped values
  • Page:
  • 1


Generating Random Strings 9 years 4 months ago #2281

  • Herbert Berkley
  • Herbert Berkley's Avatar Topic Author
  • Offline
  • Posts: 15
I need to be able to generate some series of numbers that must always be greater than the last ones created. They must always be unique and no one number must exist in more than one instance when being generated.

Ideally the output would be used to name the file.

Such as..


And so forth.



Please Log in or Create an account to join the conversation.

Re:Generating Random Strings 9 years 4 months ago #2282

Hi Herbert,

Sorry for my misunderstanding but for me isn’t clear why you need a random number?

I’ve made a short example for you. Here I used a text file (lastnumber.txt) where you can store a start number. Per each run the .NET Script Heater read this file, increment the number and generates a new unique filename based on this number. Last but not least the .NET Script Heater stores the last used number to the text file for the next run.

The result form this script is passed to the Set Parameter Heater to set the FlowHeater Parameter $FILENAME$. This parameter $FILENAME$ is used as a placeholder in the TextFile Adapter on the WRITE side for the file name.

Please have a look to the attached example.

C# script code to generate unique file names
string filename = null;

public object DoWork()
  if (filename == null)
    // Read last number from file lastnumber.txt, the file have to be exist!
    string number = File.ReadAllText("lastnumber.txt");

    // add 1 to lastnumber
    int i = Convert.ToInt32(number) + 1;
    number = i.ToString("0");

    // store the new number to lastnumber.txt
    File.WriteAllText("lastnumber.txt", number);

    // build new file name
    filename = number + "WorkOrder.csv";

  // return new file name
  return filename;

Attachment filename_sequence.zip not found

Best wishes
Robert Stark

Did this answer your question? We would be grateful if you provide a brief comment as feedback. It may also help others who may have encountered a similar problem.

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.109 seconds

other Languages


FlowHeater Home

de en


Privacy Statement

Copyright © 2009-2022 by FlowHeater GmbH.
All rights reserved.

Follow us on

twitter  facebook


 de en