Jump to content

Rephrase IF statements


Recommended Posts

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

  • Moderators

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

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.

Link to comment
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.
Link to comment
Share on other sites

  • 3 weeks later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...