joshiieeii Posted August 2, 2006 Share Posted August 2, 2006 (edited) So I have this printer monitoring tool I am working on and I am needing to translate the numerical values for the object values to their meanings. Some of the objects have 10+ values and meanings. I have been doing them like this: If $printerstate = 1 Then $printerstate = "Paused" Else If $printerstate = 2 Then $printerstate = "Error" Else If $printerstate = 3 Then $printerstate = "Pending Deletion" Else If $printerstate = 4 Then $printerstate = "Paper Jam" Else If $printerstate = 5 Then $printerstate = "Paper Out" Else These are the values / meanings I needs to translate before displaying on the GUI: Value Meaning 1 Paused 2 Error 3 Pending Deletion 4 Paper Jam 5 Paper Out 6 Manual Feed 7 Paper Problem 8 Offline 9 IO Active 10 Busy 11 Printing 12 Output Bin Full 13 Not Available 14 Waiting 15 Processing 16 Initialization 17 Warming Up 18 Toner Low 19 No Toner 20 Page Punt 21 User Intervention Required 22 Out of Memory 23 Door Open 24 Server_Unknown 25 Power Save Does anyone know a better way of doing this? Thanks a ton! Edited August 2, 2006 by joshiieeii Projects:Vista Gui ImageX Deployment Tool - CompletedActive Directory Helper - CompletedGlobalized Outlook and OWA Signature Project - Completed Link to comment Share on other sites More sharing options...
/dev/null Posted August 2, 2006 Share Posted August 2, 2006 That's what arrays are for. DIM $errMsgs[26] $errMsgs[1] = "Paused" $errMsgs[2] = "Error" ... msgbox(0,"ERROR",$errMsgs[$printerstate]) Cheers Kurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
joshiieeii Posted August 2, 2006 Author Share Posted August 2, 2006 (edited) That's what arrays are for. DIM $errMsgs[26] $errMsgs[1] = "Paused" $errMsgs[2] = "Error" ... msgbox(0,"ERROR",$errMsgs[$printerstate]) Cheers KurtThanks Kurt! I am still not on the Array bandwagon yet, still learning... so like this?:Dim $errMsgs[25] $errMsgs[1] = "Paused" $errMsgs[2] = "Error" $errMsgs[3] = "Pending Deletion" $errMsgs[4] = "Paper Jam" $errMsgs[5] = "Paper Out" $errMsgs[6] = "Manual Feed" $errMsgs[7] = "Paper Problem" $errMsgs[8] = "Offline" $errMsgs[9] = "IO Active" $errMsgs[10] = "Busy" $errMsgs[11] = "Printing" $errMsgs[12] = "Output Bin Full" $errMsgs[13] = "Not Available" $errMsgs[14] = "Waiting" $errMsgs[15] = "Processing" $errMsgs[16] = "Initialization" $errMsgs[17] = "Warming Up" $errMsgs[18] = "Toner Low" $errMsgs[19] = "No Toner" $errMsgs[20] = "Page Punt" $errMsgs[21] = "User Intervention Required" $errMsgs[22] = "Out of Memory" $errMsgs[23] = "Door Open" $errMsgs[24] = "Server_Unknown" $errMsgs[25] = "Power Save" Edit: it just dawned on me....... $errMsgs[$printerstate] Edited August 2, 2006 by joshiieeii Projects:Vista Gui ImageX Deployment Tool - CompletedActive Directory Helper - CompletedGlobalized Outlook and OWA Signature Project - Completed Link to comment Share on other sites More sharing options...
MHz Posted August 3, 2006 Share Posted August 3, 2006 Another method is to use Switch...EndSwitch expandcollapse popup$printerstate = 21 ; test MsgBox(0, 'Printer error', _PrinterError($printerstate)) Func _PrinterError($error) Switch $error Case 1 Return "Paused" Case 2 Return "Error" Case 3 Return "Pending Deletion" Case 4 Return "Paper Jam" Case 5 Return "Paper Out" Case 6 Return "Manual Feed" Case 7 Return "Paper Problem" Case 8 Return "Offline" Case 9 Return "IO Active" Case 10 Return "Busy" Case 11 Return "Printing" Case 12 Return "Output Bin Full" Case 13 Return "Not Available" Case 14 Return "Waiting" Case 15 Return "Processing" Case 16 Return "Initialization" Case 17 Return "Warming Up" Case 18 Return "Toner Low" Case 19 Return "No Toner" Case 20 Return "Page Punt" Case 21 Return "User Intervention Required" Case 22 Return "Out of Memory" Case 23 Return "Door Open" Case 24 Return "Server_Unknown" Case 25 Return "Power Save" Case Else Return "" EndSwitch EndFunc Link to comment Share on other sites More sharing options...
bluebearr Posted August 3, 2006 Share Posted August 3, 2006 I like filling arrays this way: $errs = 'Paused|Error|Pending Deletion|Paper Jam|Paper Out' _ & '|Manual Feed|Paper Problem|Offline|IO Active|Busy' _ & '|Printing|Output Bin Full|Not Available|Waiting|Processing' _ & '|Initialization|Warming Up|Toner Low|No Toner|Page Punt' _ & '|User Intervention Required|Out of Memory|Door Open|Server_Unknown|Power Save' $errMsgs = StringSplit($errs, '|') Saves typing and keeps the data compact. BlueBearrOddly enough, this is what I do for fun. Link to comment Share on other sites More sharing options...
joshiieeii Posted August 3, 2006 Author Share Posted August 3, 2006 Thank you for replying with different ways of doing this. I really appreciate it! This is what makes the AutoIT community so great!! Projects:Vista Gui ImageX Deployment Tool - CompletedActive Directory Helper - CompletedGlobalized Outlook and OWA Signature Project - Completed Link to comment Share on other sites More sharing options...
JSThePatriot Posted August 3, 2006 Share Posted August 3, 2006 Thank you for replying with different ways of doing this. I really appreciate it! This is what makes the AutoIT community so great!! I am fixing to have to do this with an entire set of UDF's. See the Computer Info UDF's in my signature. Some of them may be of interest to you.JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now