What am I doing wrong? I don’t receive any error message but it doesn’t work properly –
the part of code:
int n = Convert.ToInt32(args.Content);
if (n >= 10000)
n = (int) (n - (n * 0.85));
return n.ToString();
works only when I comment the previous part of code:
Match match = Regex.Match(args.Content, "ca.*?2013", RegexOptions.IgnoreCase);
if (match.Success)
args.Content = match.Groups[1].Value + "Aktl.";
return args.Content;
Bellow is the full script:
using System;
using System.Text.RegularExpressions;
using VisualWebRipper.Internal.SimpleHtmlParser;
using VisualWebRipper;
public class Script
{
//See help for a definition of WrContentTransformationArguments.
public static string TransformContent(WrContentTransformationArguments args)
{
try
{
//Place your transformation code here.
//This example just returns the input data
Match match = Regex.Match(args.Content, "ca.*?2013", RegexOptions.IgnoreCase);
if (match.Success)
args.Content = match.Groups[1].Value + "Aktl.";
return args.Content;
int n = Convert.ToInt32(args.Content);
if (n >= 10000)
n = (int) (n - (n * 0.85));
return n.ToString();
}
catch(Exception exp)
{
//Place error handling here
args.WriteDebug("Custom script error: " + exp.Message);
return "Custom script error";
}
}
}
I think you need:
In:
returnstatement is always executed and makes rest of the code unreachable. Conditional expression –if(...)– without brackets only includes next statement following theifcheck, that’s wayreturnis always executed.