Skip to main content
simply more productive

The Data Specialist

Thanks to our intuitive transformation designer, you can convert data effortlessly to a variety of formats without knowing how to program. It’s not only efficient, it’s also easy to use.
Up to 100,000 records can be processed with the freeware version!
Flowheater Chart

Generating Random Strings

  • Herbert Berkley
  • Topic Author
  • Offline
  • User
  • User
More
11 years 7 months ago #2281 by Herbert Berkley
Generating Random Strings - Post(2281) was created by Herbert Berkley
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..

12345Workorder.txt
12346Workorder.txt

And so forth.

Thanks,

Herb

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

More
11 years 7 months ago #2282 by FlowHeater-Team
Replied by FlowHeater-Team on topic Re:Generating Random Strings - Post(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
Code:
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

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

Time to create page: 0.252 seconds
FlowHeater Logo

FlowHeater - The Data Specialist

Efficient data integration and transformation with FlowHeater – the perfect solution for a seamless transfer of your data.

Legal information

Support & Contact

Contact

Phone:
0951 / 9933 9792

eMail:
This email address is being protected from spambots. You need JavaScript enabled to view it.


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