Jump to content

Biggest noob questions of the day.. sorry


Go to solution Solved by MrBeatnik,

Recommended Posts

I'm trying to define the varible with 12 different outcomes (depending on user input)

The reason for this is that the actual user input is not part of the formula the input is used in, and the input number is 100x easier for the user to find than the number I use in the formula.

Var1 is the user input

Var2 is the decimal number I need in the formula

If $var1 = 1 Then $var2 =  0.03
If $var1 = 2 Then $var2 = 0.7
if $var1 = 3 Then $var2 = 1.2

etc etc,

up to 12 inputs.

The real question is what do I need to add in between the "if" statements? I tried "else" "ElseIf"

To sortof make it check them 1 after 1, and when it finds the correct userinput and the assigns the correct decimal to $var2.

I'm sorry guys I'm kinda new to coding, and really liking it.. Sorry if I waste your time, I really tried to read up on it.

Link to comment
Share on other sites

Is there only 1 user input (that can have 12 outcomes)?

If so you could use the CASE help documentation, but IF/ELSEIF/ELSE/ENDIF would work... assuming I understood your question correctly.

Please correct me if I am wrong in any of my posts. I like learning from my mistakes too.

Link to comment
Share on other sites

Is there only 1 user input (that can have 12 outcomes)?

If so you could use the CASE help documentation, but IF/ELSEIF/ELSE/ENDIF would work... assuming I understood your question correctly.

 

Yes the user is asked, and can answer the following:

1, 2, 3, 4, 5, 6, 7, 8, 9, 10 or 11

So I should read up on CASE and thatwould help me?

Sorry for being unclear

Link to comment
Share on other sites

Yes the user is asked, and can answer the following:

1, 2, 3, 4, 5, 6, 7, 8, 9, 10 or 11

So I should read up on CASE and thatwould help me?

Sorry for being unclear

 

Yep (Geir1983 posted an example of CASE too).

Please correct me if I am wrong in any of my posts. I like learning from my mistakes too.

Link to comment
Share on other sites

Alright I gave it my best shot, and it seems like it compiles and runs fine. However at this point I'm not able to check if the right value is being assigned to the variable

R54rIj4.png

Am I on the right track?

Also I am Thinking about throwing a Case else in, if the user should enter a value which is not smaller or greater than max/min but doesnt fit the required numbers either, like decimals so  something like:

Case Else
 MsgBox(16, "Error", "Something has gone wrong please check your Windows Sensitivity input number again")
Edited by Srex
Link to comment
Share on other sites

  • Solution

Alright I gave it my best shot, and it seems like it compiles and runs fine. However at this point I'm not able to check if the right value is being assigned to the variable

R54rIj4.png

 

Thinking about throwing a Case else in something like

Elseif
 MsgBox(16, "Error", "Something has gone wrong please check you Windows Sensitivity input number again")

Am I on the right track?

 

Not quite...

You don't need the IFs - the CASE does the IF work for you.

Switch $WindowSensInput
  Case 1                                                       ;Checks if $WindowSensInput = 1
    $ActualWindowSens = 0.031
  Case 2                                                       ;Checks if $WindowSensInput = 2
    $ActualWindowSens = 0.222
  Case 3                                                       ;Checks if $WindowSensInput = 3
    $ActualWindowSens = 0.333
; Case n                                                       ;Checks if $WindowSensInput = n
;   $ActualWindowSens = whatever
  Case Else                                                    ;Checks if $WindowSensInput = any other value not stated
    Msgbox(16,"Error","Your value is outside the range allowed")
EndSwitch

Please correct me if I am wrong in any of my posts. I like learning from my mistakes too.

Link to comment
Share on other sites

No, your $ActualWindowsSens is always 0, therefore you do not execute any of the Case.

I think you want to use Switch on $WindowsSensInput? The Switch Case then evaluates the value of that variable and executes the code below, all your following IF testing is then not needed..

Link to comment
Share on other sites

Or you could use an array...it depends on your comfortability level.

#include <MsgBoxConstants.au3>

Local $aOutcomes[10] = [1, 2, 100, 24, 8, 90, 76, 65, 7, 99], _
        $iOutcome = 9
If $iOutcome >= 0 And $iOutcome < UBound($aOutcomes) Then
    MsgBox($MB_SYSTEMMODAL, '', $aOutcomes[$iOutcome])
EndIf

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

 

Not quite...

You don't need the IFs - the CASE does the IF work for you.

Switch $WindowSensInput
  Case 1                                                       ;Checks if $WindowSensInput = 1
    $ActualWindowSens = 0.031
  Case 2                                                       ;Checks if $WindowSensInput = 2
    $ActualWindowSens = 0.222
  Case 3                                                       ;Checks if $WindowSensInput = 3
    $ActualWindowSens = 0.333
; Case n                                                       ;Checks if $WindowSensInput = n
;   $ActualWindowSens = whatever
  Case Else                                                    ;Checks if $WindowSensInput = any other value not stated
    Msgbox(16,"Error","Your value is outside the range allowed")
EndSwitch

Aaaah so n = the number it checks for? :) thanks alot!

 

 

Or you could use an array...it depends on your comfortability level.

#include <MsgBoxConstants.au3>

Local $aOutcomes[10] = [1, 2, 100, 24, 8, 90, 76, 65, 7, 99], _

        $iOutcome = 9

If $iOutcome >= 0 And $iOutcome < UBound($aOutcomes) Then

    MsgBox($MB_SYSTEMMODAL, '', $aOutcomes[$iOutcome])

EndIf

Yeah then I could feel we stepped it up a few levels ;).

Haha thanks for stopping by.. Maybe one day I'll be more comfortable :D

And thanks for your help guys really appreciate you being so nice :)!

Edited by Srex
Link to comment
Share on other sites

No problem.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

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...