While I am use this analysis to find SYSname string line and display the whole line, but the result is
What’s the prblem? Thx
if exists file (“C:\home\Test\ABC.reg”) then following texts of firsts ““SYSname”” of lines whose (it contains ““SYSname””) of file(“C:\home\Test\ABC.reg”) else “N/A”
q: if exists file (“C:\test.txt”) then following texts of firsts “SYSname%22=” of lines whose (it contains “SYSname”) of file(“C:\test.txt”) else “N/A”
A: “ComputerName”
T: 0.411 ms
I: plural string
In version 8.0 and up you can get around the “if exists” annoyance by doing this:
q: following text of firsts “SYSname%22=” of lines whose (it contains “SYSname”) of file(“C:\test.txt”) | “N/A”
I’m keen on regular expressions, and similar to Noah’s solution:
if exists file (“C:\temp\ABC.reg”) then if (exists matches (regex “^%22SYSname%22=(.)$") of (lines of file “C:\temp\ABC.reg” as string)) then (parenthesized part 1 of (matches (regex "^%22SYSname%22=(.)$”) of (lines of file “C:\temp\ABC.reg” as string))) else (“No Entry”) else “No File”
I do know there are some strange differences between 7.2.x and 8.1.x, as I have numerous pieces of code that no longer work. However, I no longer have access to 7.2.
This is the file I used, having borrowed it from your post above. Please note, I am running Cygwin on a Windows laptop, as I am by nature and training a Unix SA.
$ cat /cygdrive/c/temp/ABC.reg
Windows Registry Editor Version 5.00
HKEY_LOCAL_MACHINE\SOFTWARE\Test\AB
HKEY_LOCAL_MACHINE\SOFTWARE\Test\AB\TEMP
“SYSname”=“ComputerName”
$
So, when I run my code in the Windows QnA GUI, I get the following: