FlowHeater Demo Video
 
FlowHeater - The Data Import / Export Specialist
 
Welcome, Guest
Username: Password: Remember me
Take a look at the available general examples, your question may already be answered here: 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

TOPIC: Net Script LIKE

Net Script LIKE 6 months 3 weeks ago #3486

I know the problem is 'if (tag.contains(swholesale))', what can I do to make this work
//////////////////////////////////////////////////////////////////////////////////////////
public object DoWork()
{
//string value something like 'DANE, Supply Company, wholesale'
//i'm looking for the tag 'wholesale'

string tag = (string)InValues[0].GetString();
string swholesale = "wholesale";
int icid = 0;

if (tag.contains(swholesale))
{
icid = 205;
}
else
{
icid = 207;
}
return icid;
}

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

Net Script LIKE 6 months 3 weeks ago #3487

Hi JD,

you need the IndexOf method. Attached you´ll find a short example.

C# script example
public object DoWork()
{
  string tag = (string)InValues[0].GetString();
  string swholesale = "wholesale";
  int icid = 0;

  // StringComparison.OrdinalIgnoreCase = ignore Upper/Lower case
  if (tag.IndexOf(swholesale, StringComparison.OrdinalIgnoreCase) >= 0)
  {
    icid = 205;
  }
  else
  {
    icid = 207;
  }

  return icid;
}


File Attachment:

File Name: dotnet-indexof.zip
File Size:2 KB

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.
Attachments:

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

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.
Last edit: by FlowHeater-Team.

Net Script LIKE 6 months 3 weeks ago #3488

As always, Robert, thank you.
It works great, and thanks for adding in the ignore case.
They only have three tags for now that I manage with a stack of IfThenElses.
This is much easier to manage and cleaner.
Thanks, JD

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

  • Page:
  • 1

other Languages

de

FlowHeater Home

de en

Imprint/Contact

Privacy Statement

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

Follow us on

twitter  facebook

YouTube

 de en