Dynamic data import / export

datenbank

simply more productive
Up to 10,000 records can be processed with the freeware version!
Welcome, Guest
Username: Password: Remember me
Welcome to the FlowHeater support forum.

Questions about using FlowHeater are answered here.

TOPIC: Use part of READ filename as parameter

Use part of READ filename as parameter 5 years 1 week ago #2189

  • Tim
  • Tim's Avatar
  • Offline
  • New Member
  • Posts: 3
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
The administrator has disabled public write access.

Re:Use part of READ filename as parameter 5 years 1 week ago #2190

  • FlowHeater-Team
  • FlowHeater-Team's Avatar
  • Offline
  • Administrator
  • Posts: 240
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
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
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

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.
The administrator has disabled public write access.

Re:Use part of READ filename as parameter 5 years 1 week ago #2191

  • Tim
  • Tim's Avatar
  • Offline
  • New Member
  • Posts: 3
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
The administrator has disabled public write access.

Re:Use part of READ filename as parameter 5 years 6 days ago #2192

  • Tim
  • Tim's Avatar
  • Offline
  • New Member
  • Posts: 3
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
The administrator has disabled public write access.

Re:Use part of READ filename as parameter 5 years 5 days ago #2195

  • FlowHeater-Team
  • FlowHeater-Team's Avatar
  • Offline
  • Administrator
  • Posts: 240
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.
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

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.
The administrator has disabled public write access.
Moderators: FlowHeater-Team
Time to create page: 0.079 seconds