Sign in to follow this  
Followers 0
iceberg

Rephrase IF statements

6 posts in this topic

hi,

can somepls kindly assist me to "rephrase" this code?

$var1 = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device")
        $var2 = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device")
        $var3 = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device")
        
        If $var1 = ("Lexmark Optra T614 (MS),winspool,LPT1:") Or $var2 = ("Lexmark Optra T612 (MS),winspool,LPT1:") Or $var3 = ("Lexmark  T632,winspool,LPT1:") Then

thanks.


mouse not found....scroll any mouse to continue.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

many ways to do this, guess it's what the users preference is, here's a couple:

$var1 = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device")
If $var1 = ("Lexmark Optra T614 (MS),winspool,LPT1:") Or _
    $var1 = ("Lexmark Optra T612 (MS),winspool,LPT1:") Or _
    $var1 = ("Lexmark  T632,winspool,LPT1:") Then
oÝ÷ Û
.ÙÞyÖÞµ§è®Øb²Þjëh×6
Global $a_printers[3] = ["Lexmark Optra T614 (MS),winspool,LPT1:","Lexmark Optra T612 (MS),winspool,LPT1:","Lexmark  T632,winspool,LPT1:"]
$device = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device")
For $x = 0 To UBound($a_printers) - 1
    If $a_printers[$x] = $device Then
        ; do something here
        ExitLoop
    EndIf
Next
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

thanks for the reply gafrost.

jus wondering what does the number 3 stands for in Global $a_printers[3]?

is it the number of printers?


mouse not found....scroll any mouse to continue.

Share this post


Link to post
Share on other sites

He created an array, that's the number of elements that are in the array... for more information.... You can look at the help file for array or take a look here: http://en.wikipedia.org/wiki/Array


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

This will work with the stable release:

$a_printers = "|Lexmark Optra T614 (MS),winspool,LPT1:|Lexmark Optra T612 (MS),winspool,LPT1:|Lexmark  T632,winspool,LPT1:|"
$device = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device")
If StringInStr($a_printers, "|" & $device & "|") Then
    _DoSomething()
EndIf

BlueBearrOddly enough, this is what I do for fun.

Share this post


Link to post
Share on other sites

thanks guys, works perfectly.


mouse not found....scroll any mouse to continue.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0