Sign in to follow this  
Followers 0
riceking

Concatinating?

5 posts in this topic

Hello, I have the user input three integers, I would then convert those integers into hex. I would like to concatenate them together and add a header string to it. Hope I didn't lose you.

$r = 124 
$g = 10  
$b = 234 

;Attempting to store values as strings.
$r = hex($r,2); Yields 7C
$g = hex($g,2); Yields 0A
$b = hex($b,2); Yields EA

;Now I'd like to combine the 3 strings to 7C0AEA. I'd like to also add a "0x" in front of that string but that would be simple as soon as I figure out how to "add" strings together.

Thank You

Regards


\

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

MsgBox(0, "", _Color_RGBtoHex(124, 10, 234))
MsgBox(0, "", _Color_RGBtoHex_Ex(124, 10, 234))

Func _Color_RGBtoHex($iR, $iG, $iB)
    Local $aArray[16] = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"]
    Return "0x" & $aArray[$iR / 16] & $aArray[Mod($iR, 16)] & $aArray[$iG / 16] & $aArray[Mod($iG, 16)] & $aArray[$iB / 16] & $aArray[Mod($iB, 16)]
EndFunc

Func _Color_RGBtoHex_Ex($iR, $iG, $iB)
    Return "0x" & Hex($iR, 2) & Hex($iG, 2) & Hex($iB, 2)
EndFunc

Something like this?

EDIT: Updated code.

Edited by AlmarM

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.

Share this post


Link to post
Share on other sites

$hexrgb = "0x" & $r & $g & $b ; <== the "&" is used to concantenate


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

There is also _ColorSetRGB(), see help file.

#include <Color.au3>

$r = 124
$g = 10
$b = 234

Dim $aColor[3] = [$r, $g, $b]

$nColor = _ColorSetRGB( $aColor )
MsgBox( 4096, "AutoIt", " Red=" & Hex($aColor[0],2) & " Blue=" & Hex($aColor[1],2) & " Green=" & Hex($aColor[2],2) & @CRLF & _
                "Color=" & Hex($nColor))

;)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thanks all of you guys ;)


\

Share this post


Link to post
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
Sign in to follow this  
Followers 0