digitalmars.D.learn - "if sting in string"
- smadus (12/12) Sep 16 2015 Hello
- cym13 (7/19) Sep 16 2015 Turn it into either:
- Rikki Cattermole (5/16) Sep 16 2015 Highly inefficient design in code, but lets ignore that.
- smadus (3/3) Sep 16 2015 A lot of thanks... i choose the (line.canFind(term)).
- John Colvin (16/28) Sep 16 2015 line 17 should probably be:
- smadus (9/9) Sep 18 2015 Ok i have rewrite :)
- yawniek (6/15) Sep 18 2015 the question is if there is a way to handle inaccessible
- John Colvin (8/17) Sep 18 2015 There are two other points where an Exception could be thrown:
- John Colvin (2/24) Sep 18 2015 Sorry, correction: http://dpaste.dzfl.pl/75945e0d839a
- John Colvin (4/31) Sep 18 2015 This was so embarrassingly ugly to do that I posted in the main
Hello Searching after hours, i give up and here is the question. ;) I will make a programm, this searching all txt files on the system or the path from user and searching a user tiped term in this file. http://dpaste.dzfl.pl/dec09a0f849c The Problem is in the if() "line 17" i searching in std.algorithm, but i dont find a solution for my problem. i hope, someone can help me. I'm new on D and sorry for my bad english. Happy Greetings Shorty
Sep 16 2015
On Wednesday, 16 September 2015 at 12:55:13 UTC, smadus wrote:Hello Searching after hours, i give up and here is the question. ;) I will make a programm, this searching all txt files on the system or the path from user and searching a user tiped term in this file. http://dpaste.dzfl.pl/dec09a0f849c The Problem is in the if() "line 17" i searching in std.algorithm, but i dont find a solution for my problem. i hope, someone can help me. I'm new on D and sorry for my bad english. Happy Greetings ShortyTurn it into either: if (canFind(line, term)) {... or if (line.canFind(term)) {... (they are equivalent) This mistake seems odd, is D your first programming language?
Sep 16 2015
On 17/09/15 12:55 AM, smadus wrote:Hello Searching after hours, i give up and here is the question. ;) I will make a programm, this searching all txt files on the system or the path from user and searching a user tiped term in this file. http://dpaste.dzfl.pl/dec09a0f849c The Problem is in the if() "line 17" i searching in std.algorithm, but i dont find a solution for my problem. i hope, someone can help me. I'm new on D and sorry for my bad english. Happy Greetings ShortyHighly inefficient design in code, but lets ignore that. You want std.string : indexOf. if (line.indexOf(term) >= 0) { If I remember correctly.
Sep 16 2015
A lot of thanks... i choose the (line.canFind(term)). No is not my first language, Python was my first, but i dont coding a long time...
Sep 16 2015
On Wednesday, 16 September 2015 at 12:55:13 UTC, smadus wrote:Hello Searching after hours, i give up and here is the question. ;) I will make a programm, this searching all txt files on the system or the path from user and searching a user tiped term in this file. http://dpaste.dzfl.pl/dec09a0f849c The Problem is in the if() "line 17" i searching in std.algorithm, but i dont find a solution for my problem. i hope, someone can help me. I'm new on D and sorry for my bad english. Happy Greetings Shortyline 17 should probably be: if(canFind(line, term)){ you had your first closing bracket in the wrong place. Also, canFind looks for the second argument inside the first argument. Other notes: There is no need to pass the arguments by ref, the data is not copied. File has a member function called byLine that can be used like this: foreach(line; actually_file.byLine()) //do something with the line No need to chomp a line before using canFind on it. What are you trying to write on line 18? datei isn't defined anywhere
Sep 16 2015
Ok i have rewrite :) Now: http://dpaste.dzfl.pl/cf8bb54b1390 The Problem is: http://www.directupload.net/file/d/4114/9zryku49_png.htm but i dont understand this, because, the exception should be "Something wrong" ?!? But, thanks for the answers, realy good and the code has been smaller.
Sep 18 2015
On Friday, 18 September 2015 at 09:42:05 UTC, smadus wrote:Ok i have rewrite :) Now: http://dpaste.dzfl.pl/cf8bb54b1390 The Problem is: http://www.directupload.net/file/d/4114/9zryku49_png.htm but i dont understand this, because, the exception should be "Something wrong" ?!? But, thanks for the answers, realy good and the code has been smaller.the question is if there is a way to handle inaccessible directories with dirEntries. the problem is that if you have a directory with insufficent access rights it throws a FileException
Sep 18 2015
On Friday, 18 September 2015 at 09:42:05 UTC, smadus wrote:Ok i have rewrite :) Now: http://dpaste.dzfl.pl/cf8bb54b1390 The Problem is: http://www.directupload.net/file/d/4114/9zryku49_png.htm but i dont understand this, because, the exception should be "Something wrong" ?!? But, thanks for the answers, realy good and the code has been smaller.There are two other points where an Exception could be thrown: during the construction of dirEntries and on every iteration of it. See http://dpaste.dzfl.pl/d38307643f9b for a corrected version. It's not pretty I think this has shown up a design flaw in dirEntries, this should be much easier.
Sep 18 2015
On Friday, 18 September 2015 at 11:18:33 UTC, John Colvin wrote:On Friday, 18 September 2015 at 09:42:05 UTC, smadus wrote:Sorry, correction: http://dpaste.dzfl.pl/75945e0d839aOk i have rewrite :) Now: http://dpaste.dzfl.pl/cf8bb54b1390 The Problem is: http://www.directupload.net/file/d/4114/9zryku49_png.htm but i dont understand this, because, the exception should be "Something wrong" ?!? But, thanks for the answers, realy good and the code has been smaller.There are two other points where an Exception could be thrown: during the construction of dirEntries and on every iteration of it. See http://dpaste.dzfl.pl/d38307643f9b for a corrected version. It's not pretty I think this has shown up a design flaw in dirEntries, this should be much easier.
Sep 18 2015
On Friday, 18 September 2015 at 11:26:46 UTC, John Colvin wrote:On Friday, 18 September 2015 at 11:18:33 UTC, John Colvin wrote:This was so embarrassingly ugly to do that I posted in the main group to see if people have better ideas: http://forum.dlang.org/post/pdwndsdfjbogtbjcnkpc forum.dlang.orgOn Friday, 18 September 2015 at 09:42:05 UTC, smadus wrote:Sorry, correction: http://dpaste.dzfl.pl/75945e0d839aOk i have rewrite :) Now: http://dpaste.dzfl.pl/cf8bb54b1390 The Problem is: http://www.directupload.net/file/d/4114/9zryku49_png.htm but i dont understand this, because, the exception should be "Something wrong" ?!? But, thanks for the answers, realy good and the code has been smaller.There are two other points where an Exception could be thrown: during the construction of dirEntries and on every iteration of it. See http://dpaste.dzfl.pl/d38307643f9b for a corrected version. It's not pretty I think this has shown up a design flaw in dirEntries, this should be much easier.
Sep 18 2015