Jump to content

A suggestion for a new macro?


Recommended Posts

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 )
EndSwitch

Would it be useful to have a macro that allows you to access the expression without having to type "$dummy_var + $four_hundred" everytime?

Link to comment
Share on other sites

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 by jscript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Link to comment
Share on other sites

@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 by jscript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Link to comment
Share on other sites

(...)

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

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Link to comment
Share on other sites

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

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

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
EndSwitch
Edit: I believe that only this part are still too vague for someone help you...

Show a larger snippet to facilitating.

Edited by jscript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Link to comment
Share on other sites

Use a variable?

$sExtracted = StringMid( $paragraph , $i , 1 )

Switch $sExtracted
    Case ' '
        ; do something
    Case '.'
        ; do something
    Case StringIsAlNum($sExtracted)
        ; do something
EndSwitch
Edited by AdmiralAlkex
Link to comment
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
 Share

  • Recently Browsing   0 members

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