- Posts: 3
Use part of READ filename as parameter
- Tim
- Topic Author
- Offline
- User
Less
More
13 years 1 month ago #2189
by Tim
Use part of READ filename as parameter - Post(2189) was created by Tim
Hi,
Is it possible to use part of the READ filename as a parameter?
EG the READ file name is 123456FFTT.txt and I need to use the 123456FFTT as a value for a GET parameter.
Hope that makes sense.
thanks
Is it possible to use part of the READ filename as a parameter?
EG the READ file name is 123456FFTT.txt and I need to use the 123456FFTT as a value for a GET parameter.
Hope that makes sense.
thanks
Please Log in or Create an account to join the conversation.
- FlowHeater-Team
- Offline
- Admin
13 years 1 month ago #2190
by FlowHeater-Team
Best wishes
Robert Stark
Replied by FlowHeater-Team on topic Re:Use part of READ filename as parameter - Post(2190)
Hi Tim,
You need the .NET Script Heater and one of the following Scripts below. What script you need depends on the Adapter you use ( Excel or TextFile ).
Move one .NET Script Heater on the Designer . Put the desired script into and connect the output to the Parameter Heater , that’s all.
Script for the TextFile Adapter
Script for the Excel Adapter
You need the .NET Script Heater and one of the following Scripts below. What script you need depends on the Adapter you use ( Excel or TextFile ).
Move one .NET Script Heater on the Designer . Put the desired script into and connect the output to the Parameter Heater , that’s all.
Script for the TextFile Adapter
Code:
public object DoWork()
{
// Get the Textfile Adapter on the READ side
TextFileAdapter adapter = (TextFileAdapter)AdapterRead;
// return only file name without path and extension
return Path.GetFileNameWithoutExtension(adapter.Filename);
}
Script for the Excel Adapter
Code:
public object DoWork()
{
// Get the Excel Adapter on the READ side
ExcelAdapter adapter = (ExcelAdapter)AdapterRead;
// return only Excel workbook file name without path and extension
return Path.GetFileNameWithoutExtension(adapter.Workbook);
}
Best wishes
Robert Stark
Please Log in or Create an account to join the conversation.
- Tim
- Topic Author
- Offline
- User
Less
More
- Posts: 3
13 years 1 month ago #2191
by Tim
Replied by Tim on topic Re:Use part of READ filename as parameter - Post(2191)
Perfect !!
Exactly what I was after.
I've got to say what an excellent bit of software this is.. this has saved me literally a week of work !
If only our ERP system was the same value for money
Exactly what I was after.
I've got to say what an excellent bit of software this is.. this has saved me literally a week of work !
If only our ERP system was the same value for money
Please Log in or Create an account to join the conversation.
- Tim
- Topic Author
- Offline
- User
Less
More
- Posts: 3
13 years 1 month ago #2192
by Tim
Replied by Tim on topic Re:Use part of READ filename as parameter - Post(2192)
Hi Robert,
One more question.. I'm using the TextFileAdapter and this is working perfectly, however there is a couple of lines at the end of the file that I don't want to process. ( i.e. it's footer information I don't need )
The first line in the footer section always begins with the letter T and I want to drop every line after that. I tried adding this to the .Net heater to filter out but it stopped the first bit working.
I then tried IfThenElse and this sort of worked but only for the line starting with T not the following lines
Is there a way to do this
thanks
Tim
One more question.. I'm using the TextFileAdapter and this is working perfectly, however there is a couple of lines at the end of the file that I don't want to process. ( i.e. it's footer information I don't need )
The first line in the footer section always begins with the letter T and I want to drop every line after that. I tried adding this to the .Net heater to filter out but it stopped the first bit working.
I then tried IfThenElse and this sort of worked but only for the line starting with T not the following lines
Is there a way to do this
thanks
Tim
Please Log in or Create an account to join the conversation.
- FlowHeater-Team
- Offline
- Admin
13 years 1 month ago #2195
by FlowHeater-Team
Best wishes
Robert Stark
Replied by FlowHeater-Team on topic Re:Use part of READ filename as parameter - Post(2195)
Hi Tim,
This you can do with the Filter Heater together with the .NET Script Heater and the following script below.
Connect your first filed with the .NET Script Heater. The output you have to connect to the Filter Heater. The Script check if the first character is T or t and this an all following line will be filtered.
In one of a next version I'll implement a new Stop Heater. With this Heater/Function you can stop the import/Export process with the help of the IF-THEN-ELSE Heater and a simple condition.
This you can do with the Filter Heater together with the .NET Script Heater and the following script below.
Connect your first filed with the .NET Script Heater. The output you have to connect to the Filter Heater. The Script check if the first character is T or t and this an all following line will be filtered.
Code:
bool bFilter = false;
public object DoWork()
{
if (bFilter == true)
return bFilter;
if (InValues.Length != 1)
throw new ArgumentException(".NET Script Heater: one input parameter expected!");
// Get the first input parameter
string sValue = (String)InValues[0].GetString();
if (sValue != null && sValue.Length > 0)
{
if (sValue[0] == 'T' || sValue[0] == 't')
{
// if the first letter equal to T or t this line an all following lines will filtered
bFilter = true;
}
}
return bFilter;
}
In one of a next version I'll implement a new Stop Heater. With this Heater/Function you can stop the import/Export process with the help of the IF-THEN-ELSE Heater and a simple condition.
Best wishes
Robert Stark
Please Log in or Create an account to join the conversation.
Time to create page: 0.284 seconds