Jump to content

my brain..its gone..:P again need help pls^^


Recommended Posts

ok, i dont know why, but my brain wont think anymore today-.-...

only errors in my head xD

i wannt to draw some colors, but lol ?im to stupid to do it .... , heres the code :

$_ScreenColors = _ScanScreen( 10,10,20,20 )

$_DivDub = _Div_Math_Dub($_ScreenColors)
                        ;left;top;right;bottom
                        
_DrawPic($_DivDub)
dbg( "Original String : " &@LF& $_ScreenColors &@LF&@LF&@LF )
dbg( "DivDubbed String: " &@LF& $_DivDub &@LF&@LF&@LF)
dbg( "BackConvertet String: " &@LF& _Div_Math_Dub($_DivDub,0) &@LF&@LF&@LF)
; _DivDub( $sText ,[ $vDelim )]
; Converts the String to make it smaller.
; The Idea by Busti :P
; Made it working by Smoke_N & JdeB! Thanx to you Guys

Func _Div_Math_Dub($sText, $iConvert = 1, $vDelim = ';'); $iConvert = 0 will do the reversal
    Local $aSplit = StringSplit($sText, $vDelim)
    Local $sNewString
    If $iConvert Then
        $sText = $vDelim & $sText & $vDelim
        For $iCount = 1 To UBound($aSplit) - 1
            If $aSplit[$iCount] = "" Then ContinueLoop
            If StringInStr($sText, $vDelim & $aSplit[$iCount] & $vDelim) Then
                $sText = StringReplace($sText,$aSplit[$iCount] & $vDelim, '')
                $iExtended = @extended
                If $iExtended > 1 Then
                    $sNewString &= $aSplit[$iCount] & '*' & $iExtended & $vDelim
                Else
                    $sNewString &= $aSplit[$iCount] & $vDelim
                EndIf
            EndIf
        Next
    Else
        For $iCount = 1 To UBound($aSplit) - 1
            If StringInStr($aSplit[$iCount], '*') Then
                Local $aSplit2 = StringSplit($aSplit[$iCount], '*', 1)
                For $xCount = 1 To Number($aSplit2[2])
                    $sNewString &= $aSplit2[1] & $vDelim
                Next
            Else
                $sNewString &= $aSplit[$iCount] & $vDelim
            EndIf
        Next
    EndIf
    Return StringTrimRight($sNewString, 1)
EndFunc   ;==>_ConvertStrings
Func oo_format($avHEX)
    $avHexSplit=StringSplit( $avHEX , "" )
    For $i=1 To $avHexSplit[0]
        If $avHexSplit[$i] <> 0 Then ExitLoop
        $avHexSplit[$i] = ""
    Next
    Local $retmsg=""
    For $iret=1 To $avHexSplit[0]
        $retmsg &= $avHexSplit[$iret]
    Next
    Return $retmsg
EndFunc

Func _ScanScreen( $x1 , $y1 , $x2, $y2, $delim=";" )
    If $x2 < $x1 Or $y2 < $y1 Then Return -1
    Local $ret=""
    For $x = $x1 To $x2
        For $y = $y1 To $y2
            ;$n_form = oo_format(Hex(PixelGetColor($x,$y)))
            $n_form = Hex(PixelGetColor($x,$y))
            ;$n_form = PixelGetColor($x,$y)
            $ret &= $n_form&$delim

        Next
    Next
    $ret = $x1&';'&$y1&';'&$x2&';'&$y2&';'&$ret
    Return StringTrimRight($ret,1)
EndFunc

Func _DrawPic($svPicInput)
    Local $_=StringSplit($svPicInput,";")
    Local $nms=""
    For $o=4 To $_[0]
        $nms &= $_[$o]&';'
    Next
    $nms = StringTrimRight($nms,1)
    $nms = _Div_Math_Dub($nms,0)
    $newsplit = StringSplit($nms,";")
    #include <GuiConstants.au3>
    GuiCreate(  @ScriptName, $_[1], $_[2],-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
    GuiSetState(@SW_SHOW)
    
    For $x=1 To 20
        For $y=1 To 20
            
            $Graphic=GUICtrlCreateGraphic($x,$y,1,1)            
            GUICtrlSetGraphic($Graphic, $GUI_GR_COLOR, $newsplit[$y])
        
        Next
    Next
    GUICtrlSetGraphic($Graphic, $GUI_GR_REFRESH)
    While 1
        If GuiGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
        Sleep(1)
    WEnd
EndFunc

Func dbg($msg)
    ConsoleWrite( $msg&@LF )
EndFunc

the mainproblem is the _DrawPic part :wacko:

i wantet to complete this project about 4-5 weeks but errors over errors... now i restartet it and again errors over errors :D

Edited by Busti
My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity
Link to comment
Share on other sites

ok, i dont know why, but my brain wont think anymore today-.-...

only errors in my head xD

i wannt to draw some colors, but lol ?im to stupid to do it .... , heres the code :

$_ScreenColors = _ScanScreen( 10,10,20,20 )

$_DivDub = _Div_Math_Dub($_ScreenColors)
                        ;left;top;right;bottom
                        
_DrawPic($_DivDub)
dbg( "Original String : " &@LF& $_ScreenColors &@LF&@LF&@LF )
dbg( "DivDubbed String: " &@LF& $_DivDub &@LF&@LF&@LF)
dbg( "BackConvertet String: " &@LF& _Div_Math_Dub($_DivDub,0) &@LF&@LF&@LF)
; _DivDub( $sText ,[ $vDelim )]
; Converts the String to make it smaller.
; The Idea by Busti :P
; Made it working by Smoke_N & JdeB! Thanx to you Guys

Func _Div_Math_Dub($sText, $iConvert = 1, $vDelim = ';'); $iConvert = 0 will do the reversal
    Local $aSplit = StringSplit($sText, $vDelim)
    Local $sNewString
    If $iConvert Then
        $sText = $vDelim & $sText & $vDelim
        For $iCount = 1 To UBound($aSplit) - 1
            If $aSplit[$iCount] = "" Then ContinueLoop
            If StringInStr($sText, $vDelim & $aSplit[$iCount] & $vDelim) Then
                $sText = StringReplace($sText,$aSplit[$iCount] & $vDelim, '')
                $iExtended = @extended
                If $iExtended > 1 Then
                    $sNewString &= $aSplit[$iCount] & '*' & $iExtended & $vDelim
                Else
                    $sNewString &= $aSplit[$iCount] & $vDelim
                EndIf
            EndIf
        Next
    Else
        For $iCount = 1 To UBound($aSplit) - 1
            If StringInStr($aSplit[$iCount], '*') Then
                Local $aSplit2 = StringSplit($aSplit[$iCount], '*', 1)
                For $xCount = 1 To Number($aSplit2[2])
                    $sNewString &= $aSplit2[1] & $vDelim
                Next
            Else
                $sNewString &= $aSplit[$iCount] & $vDelim
            EndIf
        Next
    EndIf
    Return StringTrimRight($sNewString, 1)
EndFunc   ;==>_ConvertStrings
Func oo_format($avHEX)
    $avHexSplit=StringSplit( $avHEX , "" )
    For $i=1 To $avHexSplit[0]
        If $avHexSplit[$i] <> 0 Then ExitLoop
        $avHexSplit[$i] = ""
    Next
    Local $retmsg=""
    For $iret=1 To $avHexSplit[0]
        $retmsg &= $avHexSplit[$iret]
    Next
    Return $retmsg
EndFunc

Func _ScanScreen( $x1 , $y1 , $x2, $y2, $delim=";" )
    If $x2 < $x1 Or $y2 < $y1 Then Return -1
    Local $ret=""
    For $x = $x1 To $x2
        For $y = $y1 To $y2
            ;$n_form = oo_format(Hex(PixelGetColor($x,$y)))
            $n_form = Hex(PixelGetColor($x,$y))
            ;$n_form = PixelGetColor($x,$y)
            $ret &= $n_form&$delim

        Next
    Next
    $ret = $x1&';'&$y1&';'&$x2&';'&$y2&';'&$ret
    Return StringTrimRight($ret,1)
EndFunc

Func _DrawPic($svPicInput)
    Local $_=StringSplit($svPicInput,";")
    Local $nms=""
    For $o=4 To $_[0]
        $nms &= $_[$o]&';'
    Next
    $nms = StringTrimRight($nms,1)
    $nms = _Div_Math_Dub($nms,0)
    $newsplit = StringSplit($nms,";")
    #include <GuiConstants.au3>
    GuiCreate(  @ScriptName, $_[1], $_[2],-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
    GuiSetState(@SW_SHOW)
    
    For $x=1 To 20
        For $y=1 To 20
            
            $Graphic=GUICtrlCreateGraphic($x,$y,1,1)            
            GUICtrlSetGraphic($Graphic, $GUI_GR_COLOR, $newsplit[$y])
        
        Next
    Next
    GUICtrlSetGraphic($Graphic, $GUI_GR_REFRESH)
    While 1
        If GuiGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
        Sleep(1)
    WEnd
EndFunc

Func dbg($msg)
    ConsoleWrite( $msg&@LF )
EndFunc

the mainproblem is the _DrawPic part :D

i wantet to complete this project about 4-5 weeks but errors over errors... now i restartet it and again errors over errors :D

That's some painfull code to read.

You could start by making it a lot easier to read and maintain! That wierd array variable $_ for instance, may be legal, but it lends itself to crosseyed misinterpretation. Whitespace is your friend. Loosen up the formatting and read easier, which leads to fewer mistakes.

This portion of code:

Local $_=StringSplit($svPicInput,";")
Local $nms=""
For $o=4 To $_[0]
    $nms &= $_[$o]&';'
Next
$nms = StringTrimRight($nms,1)

... as far as I can tell, can be entirely replaced with:

$nms = $svPicInput

All your includes, including "#include <GuiConstants.au3>", should be grouped together at the top of the script, again, for readability and maintenance.

... and would some comments hurt 'ya? :D

So, what happens when you run it? :wacko:

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