It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to eval() and run this javascript code from my C# program, but it won't even debug.
How can I do this?
string jsFunc = "eval(function(p,a,c,k,e,d){while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+c+'\\b','g'),k[c])}}return p}('8 4=\'6/13!)!6/12))6/19))))2!,!18*!16!15*!,!:14*-!17:9*!,!26***<\';8 5=\"\";20(3=0;3<4.24;3++){10(4.7(3)==25){5+=\'\\&\'}11 10(4.7(3)==23){5+=\'\\!\'}11{5+=21.22(4.7(3)-1)}};5;',10,27,'|||i|s|m|Nbui|charCodeAt|var||if|else|bct|spvoe|521|8477|_|73|2689|njo|for|String|fromCharCode||l{�ength|28|4451'.split('|')))";
JSEval.JSEval eval = new JSEval.JSEval();
string expression, result;
Console.Write("Выражение: ");
expression = jsFunc;
try
{
result = eval.Eval(expression).ToString();
}
catch
{
result = "!!!";
}
One potential problem, if I am permitted to hazard a guess based on the slim details available, is the odd character sequence found in the string:
...||l{�ength|28|4451'.split('|')))";
Perhaps you should remove the {� and re-run the code.
To elaborate on other meanings of the phrase "code don't debug":
Ensure the project is configured to build in Debug mode.
If your expectation is that you can step through the JavaScript, this will not be possible. You should instead debug the JavaScript using something like Firebug.
If you cannot mentally debug the JavaScript, because it has been minified, you should look at a tool to unpack the JavaScript into something more human readable.
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I want to know what would be the equivalent C# code for the perl system() function, see below code
$flac = `/usr/bin/which flac`;
($fh, $tmpname) = tempfile("stt_XXXXXX", DIR => "/tmp", UNLINK => 1);
/// Some code for recording
$endian = (unpack("h*", pack("s", 1)) =~ /01/) ? "big" : "little";
$samplerate = 8000;
$format = sln;
if(system($flac, $comp_level, "--totally-silent", "--channels=1", "--endian=$endian", "--sign=signed", "--bps=16", "--force-raw-format", "--sample-rate=$samplerate", "$tmpname.$format") != 0)
{
if (open($fh, "<", "$tmpname.flac"))
{
$audio = do { local $/; <$fh> };
close($fh);
}
}
Please help me solve my problem, digging on internet won't help me. Thanks
The system call in perl most likely calls the command line processor of the operating system with the given string.
In C#, you would use System.Diagnostics.Process.Start to start a new process. The MSDN has examples to start from.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
When I use the code below, it compiles but the rest of the code doesn't seem to work. When I take out the Substring part of it, it does.
-Steps
String theDate, theWeekDay;
if (ToTime(Time[0]) == ToTime(0, 0, 0))
{
theDate=ToDay(Time[0]).ToString().Substring(0,3);
theWeekDay=Time[0].DayOfWeek.ToString().Substring(4,8);
DrawTextFixed("day",theWeekDay, TextPosition.BottomRight);
DrawText("day"+Convert.ToString(ToDay(Time[0])),
theWeekDay+" "+theDate,0, Low[0]-TickSize*20, Color.Blue);
}
You haven't given enough information to solve your problem, but if you're just trying to get the day of the week name in the abbreviated format, use this instead:
theWeekDay = Time[0].ToString("ddd");
You're going to have to provide more than just this snippet of code. What is the Time object you're accessing via an indexer? Have you debugged this to see if Time[0] actually has a value? My guess here would be that Time[0] doesn't return a value that DayOfWeek can work with hence Substring(0,3) is being running against either an empty string or a null value
Unless you have omitted part of the code, your assignment does not take place within a class definition or a method.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I need to find the mentioned lambda statement and remove it from my code. My project is so big, and I noticed in the find and replace box of Visual Studio, there is an argument that can use regular expressions to find and replace codes. Is there a regular expression that can find this statement completely (contains line break and white space also)?
() =>
{
CallMethod()
},
I'm afraid that VS IDE is using the regular expressions in single line mode (which is actually strange considering that it offers \n in the suggestion menu). I think you will be a lot better creating a new project, which will load the file, read all text from it, and replace whatever regex you specify, and then save the file back.
Basically the regex you need is this:
(\(\ *\)\ *=\>[\r\n\s\{\}]*CallMethod\ *\(\ *\)[\r\n\s\{\}]*,)
In C# code, you can do it like this:
System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(#"(\(\ *\)\ *=\>[\r\n\s\{\}]*CallMethod\ *\(\ *\)[\r\n\s\{\}]*,)", System.Text.RegularExpressions.RegexOptions.Multiline);
regex.Replace(document, string.Empty);
Hope this will be of help to you.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Has been solved. Was trying to create a do statement that would not do anything until the while was checked. Was solved by simply putting an if statement before the do statement.
Using a do statement and anything else you might need, write the equivalent of:
while (b) {
s;
}
I think you might be looking for
if(b)
{
do
{
s;
}
while(b);
}
Is a standard part of the language:
do
{
s;
} while (b);
If I understood your question correctly you have a code that uses do..while loop and you want to replace it with a "regular" while loop.
That is not so simple as you say in your example. The difference is that do..while will always run at least once, and check the condition after it's completed. While loop may not run at all.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I need to write a simple parser that will convert the tokens to parser tree.
I've already wrote LexicalAnalyzer that returns the tokens. Now, I want
to write rules for "if and while" statements(for the beginning), so I could pass this rules to parser and it will create a tree.
So i need to write the parser in the way, so I could write new rules.
Can you advise me how I can implement it in C#? Can you give me some example?
In a recursive descent parser it's easy to implement these statements if you have the normal block and expression parsers. In pseudo-code, they are basically:
void ParseIf()
{
Match("if");
Match("(");
ParseExpression();
Match(")");
ParseBlock();
}
and
void ParseWhile()
{
Parse("while");
Parse("(");
ParseExpression();
Parse(")");
ParseBlock();
}