Sign in to follow this  
Followers 0
gamepin126

Help reading/parsing a document

10 posts in this topic

#1 ·  Posted (edited)

I'm making a custom shoutbox and I'm trying to compile the biggest list of colors I can, but I'm having trouble writing something that will grab both the name and the hex code off a list I copied somewhere.

Example:

Grey    N   84;84;84    545454      ### SAMPLE ###
Grey, Silver    V   192;192;192 C0C0C0      ### SAMPLE ###
grey    X   190;190;190 BEBEBE      ### SAMPLE ###
LightGray   X   211;211;211 D3D3D3      ### SAMPLE ###
LightSlateGrey  X   119;136;153 778899  789 ### SAMPLE ###
SlateGray   X   112;128;144 708090      ### SAMPLE ###
SlateGray1  X   198;226;255 C6E2FF      ### SAMPLE ###
SlateGray2  X   185;211;238 B9D3EE      ### SAMPLE ###
SlateGray3  X   159;182;205 9FB6CD      ### SAMPLE ###
SlateGray4  X   108;123;139 6C7B8B      ### SAMPLE ###
black   N,V,X   0;0;0   000000  000 ### SAMPLE ###
grey0   X   0;0;0   000000  000 ### SAMPLE ###
grey1   X   3;3;3   030303      ### SAMPLE ###
grey2   X   5;5;5   050505      ### SAMPLE ###
grey3   X   8;8;8   080808      ### SAMPLE ###
grey4   X   10;10;10    0A0A0A      ### SAMPLE ###
grey5   X   13;13;13    0D0D0D      ### SAMPLE ###
grey6   X   15;15;15    0F0F0F      ### SAMPLE ###
grey7   X   18;18;18    121212      ### SAMPLE ###
grey8   X   20;20;20    141414      ### SAMPLE ###
grey9   X   23;23;23    171717      ### SAMPLE ###
grey10  X   26;26;26    1A1A1A      ### SAMPLE ###
grey11  X   28;28;28    1C1C1C      ### SAMPLE ###
grey12  X   31;31;31    1F1F1F      ### SAMPLE ###
grey13  X   33;33;33    212121      ### SAMPLE ###

Anyone know how I could grab all the hex codes out of this?

Edited by gamepin126

Share this post


Link to post
Share on other sites



Hi,

try this:

$s = "Grey  N   84;84;84    545454       ### SAMPLE ### "
$s_Array = StringSplit(StringStripWS($s,4), " ")
For $i = 1 To $s_Array[0]-1
MsgBox(64, $i & " HexCode", $s_Array[4])
Next

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Cool, never used those functions before. Did the job.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I'm making a custom shoutbox and I'm trying to compile the biggest list of colors I can, but I'm having trouble writing something that will grab both the name and the hex code off a list I copied somewhere.

Example:

Grey N 84;84;84 545454 ### SAMPLE ###

Grey, Silver V 192;192;192 C0C0C0 ### SAMPLE ###

grey X 190;190;190 BEBEBE ### SAMPLE ###

Could someone show how to do this with regexp's? Thank you. Edited by jefhal

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

Could someone show how to do this with regexp's? Thank you.

What's a regexp?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Oh, here's what I did with th.meger's code.

255 250 250 fffafa snow

248 248 255 f8f8ff ghost white

248 248 255 f8f8ff GhostWhite

245 245 245 f5f5f5 white smoke

245 245 245 f5f5f5 WhiteSmoke

220 220 220 dcdcdc gainsboro

255 250 240 fffaf0 floral white

255 250 240 fffaf0 FloralWhite

253 245 230 fdf5e6 old lace

253 245 230 fdf5e6 OldLace

250 240 230 faf0e6 linen

250 235 215 faebd7 antique white

250 235 215 faebd7 AntiqueWhite

255 239 213 ffefd5 papaya whip

255 239 213 ffefd5 PapayaWhip

255 235 205 ffebcd blanched almond

$file = FileOpen("ListOfColors.txt", 0)

Run("Notepad.exe")

If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

While 1
WinWaitActive(" * new file - metapad")
$string = FileReadLine($file)
$string_Array = StringSplit(StringStripWS($string,4), " ")
;For $i = 1 To $string_Array[0]-1
Send($string_Array[4])
Send("{ENTER}")
;Next
WEnd
Edited by gamepin126

Share this post


Link to post
Share on other sites

HI,

glad I could help. :D

SRE - :"> Learning still goes on and on and on ...

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Could someone show how to do this with regexp's? Thank you.

Here is a way with regexp.

#include <array.au3>
$s_FilePath = FileOpenDialog("Select file to be parsed.", @ScriptDir, "All (*.*)")
$s_FileData = FileRead($s_FilePath, FileGetSize($s_FilePath))
$a_Result = StringRegExp($s_FileData, '\s([:xdigit:]{6})\s',3)
If IsArray($a_Result) Then
    _ArrayDisplay($a_Result, "Hex Codes")
Else
    MsgBox(0, "Error", "No hex codes found!")
EndIf

AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)

Share this post


Link to post
Share on other sites

Here is a way with regexp.

#include <array.au3>
$s_FilePath = FileOpenDialog("Select file to be parsed.", @ScriptDir, "All (*.*)")
$s_FileData = FileRead($s_FilePath, FileGetSize($s_FilePath))
$a_Result = StringRegExp($s_FileData, '\s([:xdigit:]{6})\s',3)
If IsArray($a_Result) Then
    _ArrayDisplay($a_Result, "Hex Codes")
Else
    MsgBox(0, "Error", "No hex codes found!")
EndIf
Nice one Simucal :D

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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