Archive: 2 in 1


2 in 1
I like to save in a variable the state of the LAN
Ive this sample code and ive 2 problems, first i dont know how compare with LOGICALLY OR like this
var1 = 18 OR var1 = 86

And second, why Strcpy ${LANDETECTED} 'no' 2 shows me an error when compiling?


Code :
--------------------------------------------------
!define LANDETECTED 'yes'

outfile IsLAN.exe
showinstdetails show

Section
Call IsLanDetected

StrCmp $1 '1' ildConectado
Strcpy ${LANDETECTED} 'no' 2
Goto ildFin
ildConectado:
Strcpy ${LANDETECTED} 'yes' 2
StrCmp $0 '18' ildFin
;86 compare
Strcpy ${LANDETECTED} 'no' 2
ildFin:
Messagebox mb_ok 'Cconnected (1) : $1 / Plugged (18/86) : $0 / LANDETECTED ${LANDETECTED}"

sectionend

Function IsLanDetected
System::Call 'wininet.dll::InternetGetConnectedState(*i .r0, i 0) i.r1'
; Detailprint '$$1==$1 (connected state)'
; When plugged at this point $1 = 1
; When plugged+proxy at this point $1 = 1
; When unplugged at this point $1 = 0

;Detailprint '$$0==$0 (connection)'
; When plugged at this point $0 = 18
; When plugged+proxy at this point $0 = 86
; When unplugged at this point $0 = 16

FunctionEnd
--------------------------------------------------


var CONNECT_STATE
var LAN_STATE

outfile IsLAN.exe
showinstdetails show

Section
Call IsLanDetected

StrCmp $1 '1' ildConectado
Strcpy $CONNECT_STATE 'no'
Strcpy $LAN_STATE 'no'
Goto ildFin
ildConectado:
Strcpy $CONNECT_STATE 'yes'
StrCmp $0 '18' 0 +3
Strcpy $LAN_STATE 'yes'
goto ildFin
StrCmp $0 '86' 0 +3
Strcpy $LAN_STATE 'yes'
goto ildFin
Strcpy $LAN_STATE 'no'
ildFin:
Messagebox mb_ok "Connected (1) : $1 $CONNECT_STATE$\r$\n\
LAN State (18/86) : $0 $LAN_STATE"

sectionend

Function IsLanDetected
System::Call 'wininet.dll::InternetGetConnectedState(*i .r0, i 0) i.r1'
; Detailprint '$$1==$1 (connected state)'
; When plugged at this point $1 = 1
; When plugged+proxy at this point $1 = 1
; When unplugged at this point $1 = 0

;Detailprint '$$0==$0 (connection)'
; When plugged at this point $0 = 18
; When plugged+proxy at this point $0 = 86
; When unplugged at this point $0 = 16

FunctionEnd

Thanks RW, but for i saw in your code i ask you again, it is no way to perform a Logical OR betwen 2 expressions??

Bye


Definitely it is possible, see included LogicLib.nsh.


Ok Thanks again
By the way ive modify the code using Logiclib
Wich is best??

It looks like this
-------------------------------------------
var CONNECT_STATE
var LAN_STATE
#Include LogicLib
!include "LogicLib.nsh"

outfile IsLAN.exe
showinstdetails show

Section
Call IsLanDetected
Strcpy $CONNECT_STATE 'no'
Strcpy $LAN_STATE 'no'
StrCmp $1 '0' ildEnd 0
Strcpy $LAN_STATE 'yes'
${Select} $0
${Case} '18'
Strcpy $CONNECT_STATE 'yes'
${Case} '86'
Strcpy $CONNECT_STATE 'yes'
${CaseElse}
Strcpy $CONNECT_STATE 'no'
${EndSelect}
ildEnd:
Messagebox mb_ok "Connected (1) : $1 $CONNECT_STATE$\r$\n\LAN State (18/86) : $0 $LAN_STATE"


sectionend

Function IsLanDetected
System::Call 'wininet.dll::InternetGetConnectedState(*i .r0, i 0) i.r1'
; Detailprint '$$1==$1 (connected state)'
; When plugged at this point $1 = 1
; When plugged+proxy at this point $1 = 1
; When unplugged at this point $1 = 0

;Detailprint '$$0==$0 (connection)'
; When plugged at this point $0 = 18
; When plugged+proxy at this point $0 = 86
; When unplugged at this point $0 = 16

IntFmt $R1 "0x%X" "$0"
;Detailprint '$$R1==$R1 (connection in hex)'
; When plugged at this point $R1 = 0x12
; When plugged+proxy at this point $R1 = 0x56
; When unplugged at this point $R1 = 0x10

IntOp $R0 $0 & 1
;Detailprint '$$R0==$R0 (modem bit)'
; When plugged at this point $R0 = 0
; When plugged+proxy at this point $R0 = 0
; When unplugged at this point $R0 = 0
FunctionEnd
-------------------------------------------


LogicLib is always a better way cause it saves a lot of typing :)


Thanks
See you in my next post :-D