- Posts: 109
Net Script LIKE
- JD Cox
- Topic Author
- Offline
- User
Less
More
5 years 5 months ago #3486
by JD Cox
Net Script LIKE was created by JD Cox
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;
}
//////////////////////////////////////////////////////////////////////////////////////////
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 to join the conversation.
- FlowHeater-Team
- Offline
- Admin
5 years 5 months ago - 5 years 5 months ago #3487
by FlowHeater-Team
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.
Replied by FlowHeater-Team on topic Net Script LIKE
Hi JD,
you need the IndexOf method. Attached you´ll find a short example.
C# script example
you need the IndexOf method. Attached you´ll find a short example.
C# script example
Code:
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;
}
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: 5 years 5 months ago by FlowHeater-Team.
Please Log in to join the conversation.
- JD Cox
- Topic Author
- Offline
- User
Less
More
- Posts: 109
5 years 5 months ago #3488
by JD Cox
Replied by JD Cox on topic Net Script LIKE
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
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 to join the conversation.
Time to create page: 0.265 seconds