Jump to content

Map value ? (0, $n to 0,500)


burners
 Share

Recommended Posts

  • Moderators

burners,

Could you please explain a little more clearly what exactly you are trying to achieve? ;)

At the moment I am afraid I have no idea of the context in which you wish to use this "MAP" command. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I asked about this a few days ago. Apparently autoit doesn't have a native associative array, but since you're just dealing with ints you can use ordinary arrays to map one value to another.

This would theoretically map anything between 0 & $n to 5 - 1134

My best guess at what you mean by this is "map ints from 0 to n to a corresponding value between 5 and 1134". This would require the cardinality of "0 to $n" to be 1129 so that doesn't make sense. If what you're really asking about is the "map" function of Scheme, Haskell, Javascript, Python, etc - Autoit can do neither anonymous functions nor any real first-class function, so a higher-order map would be very limited if it existed. About the only thing I've found autoit can do with function objects is the "for...in ..." keyword. (though I haven't used autoit in years so there could be others I haven't found yet)

Link to comment
Share on other sites

burners,

Could you please explain a little more clearly what exactly you are trying to achieve? ;)

At the moment I am afraid I have no idea of the context in which you wish to use this "MAP" command. :)

M23

This is the best way I can explain it and where I got the idea

http://www.arduino.cc/en/Reference/Map

~~--Feel Free to Steal my Sigs --~~FLAT LOOK____________________________________ROUNDED LOOK

Link to comment
Share on other sites

OK I have some simple math to do the max, working on getting the min into the equation, hopefully without created an array

;Desired min max 0 - 360
;Actual min max 0 - 1024
;Example 0=0, 512=180 ,1024=360

$exampleinput = 512

$actualmin = 0
$actualmax = 1024

$adjustedmin = 0
$adjustedmax = 360

$difference = $actualmax / $adjustedmax

$adjustedinput = $exampleinput / $difference

$adjustedinput = Round($adjustedinput, 1)

MsgBox(4096, "Adjusted Difference", $adjustedinput , 10)

~~--Feel Free to Steal my Sigs --~~FLAT LOOK____________________________________ROUNDED LOOK

Link to comment
Share on other sites

OK I worked on the min and the problem is that simple math wont do, the math would need to change on a sliding scale as the input changes.

Example would be if you have 20-380 as your input and the desired output is 0-360 then we know 20 = 0 and 380 = 360. I can do the math to get either but anything inbetween is hopeless.

The issue also comes in when there is a 0, this kills the math dead in its tracks, the last thing I know wouldnt be easy is if the values are swapped and now the input is 0-360 and the output is 20-380.

The problems go on and on, the only other thing I can think of is somehow creating an array maybe with the Enum function and use something like

for blah blah

$actualmax = 1024

$adjustedmax = 360

$n = $actualmax / $adjustedmax

Enum Step $n $valueforarray

write variable

got me

~~--Feel Free to Steal my Sigs --~~FLAT LOOK____________________________________ROUNDED LOOK

Link to comment
Share on other sites

Map value?

Func Map($iValue, $iFromLow, $iFromHigh, $iToLow, $iToHigh)
    Return ($iValue - $iFromLow) * ($iToHigh - $iToLow) / ($iFromHigh - $iFromLow) + $iTolow
EndFunc

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

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