jaberwacky Posted April 10, 2011 Posted April 10, 2011 Let's assume that you have a switch statement with an expression:Global $dummy_var = 300 Global $four_hundred = 401 Switch $dummy_var + $four_hundred Case 300 MsgBox( 0 , "Message" , "Ok" ) Case 400 MsgBox( 0 , "Indicator", "Yes" ) Case 701 MsgBox( 0 , "Noticia" , "El valor es correcto: " & @expression ) ; instead of: MsgBox( 0 , "Noticia" , "El valor es correcto: " & $dummy_var + $four_hundred ) EndSwitchWould it be useful to have a macro that allows you to access the expression without having to type "$dummy_var + $four_hundred" everytime? Helpful Posts and Websites: AutoIt Wiki | Can't find what you're looking for on the Forum? My scripts: Guiscape | Baroque AU3 Code Formatter | MouseHoverCalltips | SciTe Customization GUI | ActiveWindowTrack Toy | Monitor Configuration UDF
JScript Posted April 10, 2011 Posted April 10, 2011 (edited) Global $dummy_var = 300 Global $four_hundred = 401 SetExtended($dummy_var + $four_hundred) Switch @extended Case 300 MsgBox( 0 , "Message" , "Ok" ) Case 400 MsgBox( 0 , "Indicator", "Yes" ) Case 701 MsgBox( 0 , "Noticia" , "El valor es correcto: " & @extended ) EndSwitch Edited April 10, 2011 by jscript http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere!
jaberwacky Posted April 10, 2011 Author Posted April 10, 2011 @extended doesn't work for me. Helpful Posts and Websites: AutoIt Wiki | Can't find what you're looking for on the Forum? My scripts: Guiscape | Baroque AU3 Code Formatter | MouseHoverCalltips | SciTe Customization GUI | ActiveWindowTrack Toy | Monitor Configuration UDF
JScript Posted April 10, 2011 Posted April 10, 2011 (edited) @extended doesn't work for me.Why do not you use a variable to store the value?In the example you passed Yes it works Edited April 10, 2011 by jscript http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere!
JScript Posted April 10, 2011 Posted April 10, 2011 (...)Would it be useful to have a macro that allows you to access the expression without having to type "$dummy_var + $four_hundred" everytime?For you and others with that same thought, a very special Valik phrase: "We will not add bad features to Facilitate lazy programming. Write your code well and the dangerous feature like this Will Not Be necessary." http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere!
jaberwacky Posted April 10, 2011 Author Posted April 10, 2011 (edited) Actually: Global $dummy_var = 300 Global $four_hundred = 401 Switch $dummy_var + $four_hundred Case 300 MsgBox( 0 , "Message" , "Ok" ) Case 400 MsgBox( 0 , "Indicator", "Yes" ) Case 701 ConsoleWrite( "El valor es correcto: " & @extended & @CRLF) ; instead of: ConsoleWrite( "El valor es correcto: " & $dummy_var + $four_hundred & @CRLF) EndSwitch El valor es correcto: 0 El valor es correcto: 701 What if I wanted to do this: Switch StringMid( $paragraph , $i , 1 ) Case ' ' ; do something Case '.' ; do something Case StringIsAlNum( @expression ) ; do something EndSwitch --------------------------------------------------------------------------------------------------------------------------------------------------------------------- Ok, I'm beginning to see that there is no point to all of this now! Edited April 10, 2011 by LaCastiglione Helpful Posts and Websites: AutoIt Wiki | Can't find what you're looking for on the Forum? My scripts: Guiscape | Baroque AU3 Code Formatter | MouseHoverCalltips | SciTe Customization GUI | ActiveWindowTrack Toy | Monitor Configuration UDF
JScript Posted April 11, 2011 Posted April 11, 2011 (edited) Actually: Global $dummy_var = 300 Global $four_hundred = 401 Switch $dummy_var + $four_hundred Case 300 MsgBox( 0 , "Message" , "Ok" ) Case 400 MsgBox( 0 , "Indicator", "Yes" ) Case 701 ConsoleWrite( "El valor es correcto: " & @extended & @CRLF) ; instead of: ConsoleWrite( "El valor es correcto: " & $dummy_var + $four_hundred & @CRLF) EndSwitchEl valor es correcto: 0 El valor es correcto: 701 How do you expect this line to work if you have not set @extended ? ConsoleWrite( "El valor es correcto: " & @extended & @CRLF) This code that I posted works! Global $dummy_var = 300 Global $four_hundred = 401 SetExtended($dummy_var + $four_hundred) Switch @extended Case 300 MsgBox( 0 , "Message" , "Ok" ) Case 400 MsgBox( 0 , "Indicator", "Yes" ) Case 701 MsgBox( 0 , "Noticia" , "El valor es correcto: " & @extended ) EndSwitch Now you're showing what you really want... What if I wanted to do this: Switch StringMid( $paragraph , $i , 1 ) Case ' ' ; do something Case '.' ; do something Case StringIsAlNum( @expression ) ; do something EndSwitchEdit: I believe that only this part are still too vague for someone help you... Show a larger snippet to facilitating. Edited April 11, 2011 by jscript http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere!
AdmiralAlkex Posted April 11, 2011 Posted April 11, 2011 (edited) Use a variable? $sExtracted = StringMid( $paragraph , $i , 1 ) Switch $sExtracted Case ' ' ; do something Case '.' ; do something Case StringIsAlNum($sExtracted) ; do something EndSwitch Edited April 11, 2011 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
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