View Single Post
Old 30th July 2017, 18:39   #5
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 269
Problem Solved

my problem solved
i just need Find the first word available
this code have some bugs but my problem solved.


HTML Code:
!include "x64.nsh"
!include "StrCount.nsh"

Var String
Var LineReaded
Var FindWord




Section

StrCpy $FindWord "Rose" #Searching String In Variable
StrCpy $String "1--------------$\r$\n2-Which is the invocation best CPU scheduling algorithm?$\r$\n3-CPU Scheduler$\r$\n4-I/O request or invocation$\r$\n5--------------$\r$\nRose"


;------------------------------------------------------------
StrCpy $1 0
StrCpy $5 0
StrCpy $6 0
;------
loop:
IntOp $6 $6 + 1
StrCpy $2 $String 1 $1
;-------------------
/*
${If} $2 == "$\r$\n"
IntOp $6 $6 - 2
${ElseIf} $2 == "$\n"
${OrIf} $2 == "$\r"
IntOp $6 $6 - 1
${EndIf}
*/
;-------------------
IntOp $1 $1 + 1
StrCmp $2 '$\n' found
StrCmp $2 '' found loop
IntOp $5 $5 + 1
;------
found:
IntOp $3 $3 + 1
StrCpy $LineReaded $String $6 $5
StrCpy $5 ""
StrCpy $6 ""
;------------------------------------------------------------
${StrCount} "$LineReaded" "$FindWord" "i"
Pop $0
;--------
${If} $0 != "0"
StrCpy $4 "$LineReaded" 1
${else}
StrCpy $5 $1
Goto loop #read Next Line
${endIf}
;------------------------------------------------------------



;---------------------------------
MessageBox MB_OK "You Searched For: $FindWord \
$\r$\nFind [$0] Time \
$\r$\nFind At Line [$3] \
$\r$\nLine $3 String IS: [$LineReaded] \
$\r$\nLine $3 First Char IS: [$4]"
;---------------------------------




SectionEnd
r2du-soft is offline   Reply With Quote