Jump to content

New tool - a PreProcessor


kjactive
 Share

Recommended Posts

kjactive,

Nice work! Thanks for fixing them.

How about a new bug? Process Manager (March 3, 2007) creates a global constant for a standard GUI variable even though the variable is commented. Also, it does not define the variable $ES_MULTILINE which is used in the BitOR statement on that commented line.

Here's a simplified script so you can duplicate it:

#include 
;~   $ebGUI3 = GUICtrlCreateInput("", 10 * $rAdj, 10 * $rAdj, 330 * $rAdj, 130 * $rAdj, BitOR($GUI_SS_DEFAULT_INPUT, $ES_MULTILINE))
MsgBox(4096, "test", "test")
Exit

FYI, the hotkeys ^a, ^c are driving me nuts -): That's because they are the Windows hotkeys for Select All and Copy. If I allow Process Manager to remain running while checking its results, I can not use those hotkeys in other programs. I can't tell you how many times the "About" page has popped up using ^a, and I've compiled the script using ^c. :whistle:

phillip

Phillip

Link to comment
Share on other sites

Yessss - ha, thanks phillip123adams, Just keep on hammeren the application, I'll fix it what so ever - I hope anyway...

This one didn't produced any errors but just overloaded the script, The touble was that the scan process didn't special checked for comment included variables but processed all and one, Fixed now as all comment included variables get left out...

I can't tell you how many times the "About" page has popped up

Ha - Yes that's a nice advetice I did there, anyway I didn't have any trouble with Ctrl but I changed all shortcuts Ctrl to Shift - Okay...

Download from site

http://www.sitecenter.dk/latenight/nss-fol...t%20Manager.zip

kjactive :whistle: ( just fun - keep on your fine job )

Edited by kjactive
Link to comment
Share on other sites

kjactive,

Thanks! Project Manager 2.8 dated March, 4, 2007 fixed the last bug. Here's are 2 new issues so you can knock your head on the door :whistle: a couple of more times.

Issue 1: This issue is similar to the last, in that a GUI Constant is not being converted, but this time the line is not commented and it should be converted.

Here's a script to duplicate the 1st issue:

#include 
$sGUI1 = GUICreate("TEST", 450, 450, 105, 105, BitOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX))oÝ÷ Øw«{l¶ªºi­ê®¢×âçè¯[-Ë.xÚ-zØZµÊ'²Ö§·MúY$HÁ
R+'¢×(÷«µçm¢+l½©ny«­¢+Ù±½°
½¹ÍÐÀÌØíU%}MM}U1Q}U$õ  ¥Ñ=H ÁàÀÀÀÈÀÀÀÀ°ÁàÀÁÀÀÀÀÀ°ÁààÀÀÀÀÀÀÀ°ÀÌØí]M}MeM59T¤(ÀÌØíÍU$ÄõU%
ÉÑ ÅÕ½ÐíQMPÅÕ½Ðì°ÐÔÀ°ÐÔÀ°ÄÀÔ°ÄÀÔ±  ¥Ñ=H ÀÌØíU%}MM}U1Q}U$°ÁàÀÀÀÈÀÀÀÀ¤¤oÝ÷ Ø,¹í+"²Ëv¬l¹»-Û­y«Ú碻ayÊ'²Ö§¶ö«¦å{MúB¢Z+¡÷ôÑ÷쥩ì·)^oÝ÷ Øw«{l¶ªºi­ê®¢×âçè¯iÝË.y«­¢+ØÀÌØí¥¸ÄõU%
Ñɱ
ÉÑ%¹ÁÕÐ ÅÕ½ÐíÑÍÐÅÕ½Ðì°ÄÀÀ°ÄÀÀ¤)U%
ÑɱMÑMÑÑ ÀÌØí¥¸Ä°ÀÌØíU%}¹    1¤

phillip

Phillip

Link to comment
Share on other sites

Hallo Phillip123Adams

Well do still catch up with you and the great work you'r doing... No banging my head at the door but I'm a little amazed how easy this script is to debug, afterall there is a lot going around under the hood.

I didn't mention this before but Peoble that wants their scripts to be almost unreadable to other coders can use this application, just look at the preprocessed script and you know why...

Hopefully I fixed the two bugs Phillip123adams found...

Keep up the great work...

Download from site

http://www.sitecenter.dk/latenight/nss-fol...t%20Manager.zip

kjactive :whistle:

Edited by kjactive
Link to comment
Share on other sites

kjactive,

Nice job again. You have resolved the last issues I reported. I've tested Project Manager 2.8 (dated 3-5-2007) on 10 of my scripts, and I am happy to report that I have no new issues for you this morning :whistle: . When I get a chance, I will test on more scripts and let you know.

I also followed the directions in the help file to add PM to the Scite4AutoIt editor, and it worked perfectly.

Phillip

Phillip

Link to comment
Share on other sites

Yessss - that nice...

To qcriaco, I think that you'r using an old revision as this trouble was removed some updates ago, and I could not reproduce this error - Try downloading the last revision from the link below and Please report back...

Phillip123adams, what can I say anything but YESSS, the last trouble you found with the case sensitive trouble, I would never had found that one me self, great work, please keep up reporting...

I would like to get some suggestions too, what about the Alt shortcut keys, do this work, do this application miss some features, What about an automatically fileinclude feature?, like to drop a file into the application and get it buildin, what about an exclude all message strings as a new special preprocess option, as to get all strings into an external .txt file to be nation language processed ec.

Thanks goes to all coders that did spear me some time to report troublefull waters...

Download last revision date 5.3.07

http://www.sitecenter.dk/latenight/nss-fol...t%20Manager.zip

kjactive :whistle:

Edited by kjactive
Link to comment
Share on other sites

I would like to get some suggestions too...

kjactive,

1. The Hotkeys still cause problems in other applications while PM is running, when certain capital letters are required. It would be nice if Hotkeys were application dependent. But since they are not, how about a menu option to enable/disable the hot keys?

2. Perhaps you could add an option that would NOT remove multiple blank characters in quoted strings. For example, double spaces may be required (or desirable) in messages, or when searching for a string in a text file, etc. Or, is this what you meant by "exclude all message string"?

3. How about an option that removes line continuations? This would reduce file size a tiny bit more.

4. I like your idea of extracting strings for language translation. How about a feature that could make the substitutions by reading the translation from an external file of strings arranged in the same order as in the PM list. PM could list the strings, the programmer could do the translation, and PM could read the translation and write a "pre" for that language with the name of the language as part of the filename.

PM should list a string only once. If a second string is identical to another, only list it once so the translation could be done only once.

Strings with concatenated variables should be listed with the variable names.

And probably other things I haven't though of yet.

Phillip

Phillip

Link to comment
Share on other sites

Okay GCriaco and I found the trouble reported. These was a little strange as they came because there was a hidden window from another program with a title matched Preferences - I keep this in mind when I write other applications...

Right now I'm testing a Language Translation editer to attach to Project Manager...

Download rev. 2.9 at site

http://www.sitecenter.dk/latenight/nss-fol...t%20Manager.zip

kjactive :whistle:

Link to comment
Share on other sites

Hey kjactive - just did preliminary tests with your preprocessor, worked great! Just wanted to say that I think it is super cool that you spend your time making this kind of 'low-level' enhancement for Autoit, enabling (potentially) everyone's stuff to run better/faster/smaller..etc.

Props for doing the work! :whistle:

Sunaj

Okay GCriaco and I found the trouble reported. These was a little strange as they came because there was a hidden window from another program with a title matched Preferences - I keep this in mind when I write other applications...

Right now I'm testing a Language Translation editer to attach to Project Manager...

Download rev. 2.9 at site

http://www.sitecenter.dk/latenight/nss-fol...t%20Manager.zip

kjactive :P

Link to comment
Share on other sites

Well yes but even better, if you got MSAgent installed, this would provide you with a guided tour around the Project Manager with Genie or the Merlin character - just click at the MSAgent script or use help menu 'MSAgent' ( only attached if MSAgent is installed ), I do love these little fellows.

If you don't have these around here's some background. Project Manager is a Large Project and Preprocess manager to sample large projects and do a PreProcess to gain as much speed and less bites for the intepretter to deal with and a benefit would be that the PreProcessed script has all Global variables and Functions needed as an 'all buildin script', as this script only needs the intepretter and as compiled model now independed from the Autoit3 system - A normal project would be reduced about 20% - 50% as all build in depending on the method used.

For those of you AutoItters that has a concern about coders looking into the code - A preProcessed script is almost unreadable

and when I'm finished with the Language Tranlation routines - absolute Unreadable...

Every script can have its own makefile attached that provide uniqe settngs to this particulare script. The makefile script will overrule the default scan process and can include some special functions needed for some dynamically created function calls done with the 'CALL' function - Use the Makefile editor, a makefile is kind of script local preferences and easy created...

How to get a new project started - Set the process parametre, Load in a script with the 'process control' and a new script is written with a _Pre attached ( no changes made to the original script ), test the preprocessed script with the 'test control' and if everything runs smoothly, attach a makefile with the 'Write control' - this will set the parametre for this particulare script the same at every PreProcess. Finally do a compile, done from the 'Compile control' that would provide directly access to AutoWrapper or Au32Exe,

well all these actions can be done automatic from startup...

There's some more exotic features that can be read about in the topics attached but one thing importent is that the Project Manager can easy be installed as a SciTe macro tool and operate directly from this menu - there's an example in the topics under 'Special Notes' on how to do this...

Actually the fun part for me, besides that I think Autoit3 needs this kind of tool for large projects, was to write the deep scan process, that is a hard one, as this is a kind of endless hole scan function and another thing that surpricesses me is how easy this application is to debug, after all there's al lot going around under the hood in this application, but thanks to all devoted buggers it's now almost bug free I hope - thank goes to all...

Almost finished but still on the ToDo list is an option to make processed script 'language translate able' and automatically write an .LNG script attached than get called from the script at startup...

Hope this can cast some light in here for you...

Still open fore Idears and comments...

kjactive :whistle:

Edited by kjactive
Link to comment
Share on other sites

Hallo LouLou

I can see that the trouble comes from a Global variable in the IE.au3 UDF but what's wrong I have to look into the PreProcessed script, Could you drop it to me on a mail and I'll look into it...

kjactive :whistle:

Link to comment
Share on other sites

  • 3 weeks later...

Hi kjactive,

Would it be possible for you to introduce a new format for comments (like end of line ";safe; actual comment" and "#cs safe ... #ce /safe" for blog comments) that could be used by people regularly working with your preprocessor so that one could simply check a box in the P.M. like "Remove Safe comments" thereby getting rid of a spectacular amount of problems relating to cutover lines and whatnot..?! I realize that I would have to through all my code comments if you implemented this.. but only once, I really think it could be killer for larger projects..etc.! :shocked:

And.. a possible (micro)bug report:

The line:

GUICtrlSetData($h_ClearClipboardCombo, "Clear on exit, Yes")

becomes:

GUICtrlSetData($h_ClearClipboardCombo, "Clear on exit,Yes")

Also:

GUICtrlCreateGroup("Stuff ( ) ", 20, 77, 460, 159) ; odd spacing needed

becomes:

GUICtrlCreateGroup(" Stuff () ", 20, 77, 460, 159) ; odd spacing needed

I know the latter example is a bit out there but I need to do like that to be able to draw another line of text in the space that is then made into a link!

Last thing, it could be really cool if there was a do-not-process-this-bit tag.. like:

;safe; start no process

MsgBox(4096, "data", "yes this msgbox can now retain odd spacing because it is not processed ( ) :(")

MsgBox(4096, "data", "yes this msgbox2 can now retain odd spacing because it is not processed ( ) :P")

;safe; end no process

Hope you'll keep working on this.. basically it is super useful! Before I had a range of script that I needed to distribute but was not able to because of the size increase on compile, which is quite a lot if 20-30 micro script needs to go in one package - now i can just include one compiled file and then have it execute the smaller preprocessed scripts.

Cheers,

Sunaj

EDIT: fixed errors in text

Edited by Sunaj
Link to comment
Share on other sites

The following script causes the runtime error:

--> IE.au3 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)

C:\AutoIt\PodCast\Podcast_Pre.au3 (310) : ==> Unknown function name.:

Local $f_NotifyStatus = _IEErrorNotify()

Local $f_NotifyStatus = ^ ERROR

Here is the script:

#include <IE.au3>
#include "get_mp3_tag.au3"
;~ #include <array.au3>

;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Icon=Question
If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(36,"Verifica Autore","Autore del Podcast: " & _Podcaster() & @CRLF & @CRLF & "Vuoi scaricarlo?")
Select
    Case $iMsgBoxAnswer = 6 ;Yes
        ; Installazione Componenti
        If @Compiled Then
            FileInstall("Downloader.exe", @ScriptDir & "\Downloader.exe")
        EndIf

        $iRC = RunWait(@ScriptDir & "\Downloader.exe -download http://rockplus.podzone.org/rockplus/pod/rrto" & @YEAR & "_" & @MON & "_" & @MDAY & ".mp3 " _
            & @ScriptDir & "\rrto" & @YEAR & "_" & @MON & "_" & @MDAY & ".mp3", @ScriptDir)
        
        ;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Info
        MsgBox(64,"Podcast","Download Podcast "& _RenameMP3() & " OK")

    Case $iMsgBoxAnswer = 7 ;No
        Exit
EndSelect

Exit

;--------------------------------------------------------------------------------------------------------------------------------------------------------------------

Func _Podcaster()
    $oIE =_IECreate("http://www.radiorock.to/index.php#idhome=240&main__state=DownPod", 0, 0,1)
    $sText = _IEBodyReadText($oIE)
;~  ConsoleWrite("Body Text: " &  $sText & @CRLF)
    $iIn = StringInStr($sText, "Puoi scaricare Il podcast di") + 28
;~  ConsoleWrite("In: " &  $iIn & @CRLF)
    $iOut = StringInStr($sText, "in onda dal")
;~  ConsoleWrite("Out: " &  $iOut & @CRLF)
    $sPodcaster = StringMid($sText, $iIn, $iOut - $iIn)
    ConsoleWrite("Podcaster: " &  StringStripWS (StringStripWS ($sPodcaster, 1), 2) & @CRLF)
    Return $sPodcaster
EndFunc 

Func _RenameMP3()
    Dim $iCnt, $sFile, $aData, $aLabel, $sOut = ""

    $sFile = "rrto" & @YEAR & "_" & @MON & "_" & @MDAY & ".mp3"
    $aData = _MP3GetTag($sFile)
    If @error Then 
        MsgBox (0, "MP3 Tag Info", "No TAG info was found.")
        Exit
    Endif

    FileMove(@ScriptDir & "\" & $sFile , "rrto" & @YEAR & "_" & @MON & "_" & @MDAY & "-" & $aData[1] & ".mp3", 1)
    
    Return @ScriptDir & "\" & "rrto" & @YEAR & "_" & @MON & "_" & @MDAY & "-" & $aData[1] & ".mp3"
EndFuncoÝ÷ ØÜç^~)^ªê-ëf§{Z«·ªê-jëh×6#include-once
;===============================================================================
;
; Description:      Retrieve MP3 tag info
; Parameter(s):     File name
; Requirement(s):   Autoit Beta 3.104.123+ (DllStruct, Binary, RegExp)
; Return Value(s):  On Success - array with data:
;                       0 - Title
;                       1 - Artist
;                       2 - Album
;                       3 - Year
;                       4 - Comment
;                       5 - Track number
;                       6 - Genre
;                       7 - Length (for V2 only, may be used for determine length for VBR files)
;                       8 - Tag version
;                   On Failure empty string and sets @ERROR:
;                       1 - Info not found
; Author(s):        YDY (Lazycat)
; Version:          2.5.1
; Date:             06.05.2006
; Note(s):          None
;
;===============================================================================

Func _MP3GetTag($sFile)
    Local $ret = DllCall("kernel32.dll","int","CreateFile", _
                        "str",$sFile, _
                        "int",0x80000000, _
                        "int",0, _
                        "ptr",0, _
                        "int",3, _
                        "int",0x80, _
                        "ptr",0)
                        
    If @error OR Not $ret[0] Then 
        SetError(1)
        Return ""
    Endif
    Local $vTag = _MP3GetV2Tag($ret[0])
    If not IsArray($vTag) Then $vTag = _MP3GetV1Tag($ret[0], FileGetSize($sFile) - 128)
    DllCall("kernel32.dll","int","CloseHandle","int", $ret[0])
    If IsArray($vTag) Then Return $vTag
    SetError(1)
    Return ""
EndFunc

Func _MP3GetV1Tag($hFile, $nTagPos)
    Local $pTag = _FileReadToStruct("char[3];char[30];char[30];char[30];char[4];char[30];byte", $hFile, $nTagPos)    
    If not (_DllStructArrayAsString($pTag, 1, 3) == "TAG") Then Return "" ; ID3v1 tag NOT found
    Local $asInfo[9]
    $asInfo[0] = _DllStructArrayAsString($pTag, 2, 30) ; Title
    $asInfo[1] = _DllStructArrayAsString($pTag, 3, 30) ; Peformer
    $asInfo[2] = _DllStructArrayAsString($pTag, 4, 30) ; Album
    $asInfo[3] = _DllStructArrayAsString($pTag, 5, 4)  ; Year
    $asInfo[4] = _DllStructArrayAsString($pTag, 6, 30) ; Comment
    $asInfo[5] = ""                                    ; Track number  
    $asInfo[8] = "1.0"
    If DllStructGetData($pTag, 6, 29) = 0 Then ; Version 1.1
        $asInfo[5] = DllStructGetData($pTag, 6, 30) 
        $asInfo[8] = "1.1"
    EndIf
    $asInfo[6] = _MP3GetGenreByID(DllStructGetData($pTag, 7)) ; Genre
    $asInfo[7] = ""
    Return($asInfo)
EndFunc

Func _MP3GetV2Tag($hFile)
Local $nTagSize = 1, $nFrameOffset = 10, $nTagInfo
Local $asInfo[9], $sID, $pFrame, $pHeader, $pTemp, $nFrameSize, $sData, $p

$pHeader = _FileReadToStruct("char[3];byte;byte;byte;dword;dword", $hFile, 0)
If not (StringLeft(DllStructGetData($pHeader, 1), 3) = "ID3") Then Return

For $i = 0 To 8
    $asInfo[$i] = ""
Next

; Set tag version
$asInfo[8] = StringFormat("2.%d.%d", DllStructGetData($pHeader, 2), DllStructGetData($pHeader, 3))

$nTagInfo = DllStructGetData($pHeader, 4)
$nTagSize = _SSIntToInt(DllStructGetData($pHeader, 5)) + 10

If _IsBitSet($nTagInfo, 4) Then $nTagSize = $nTagSize + 10  ; Footer presented, RARE case
If _IsBitSet($nTagInfo, 6) Then $nFrameOffset = 10 + _SSIntToInt(DllStructGetData($p, 5)) ; ExtHeader presented

$pFrame = DllStructCreate("char[4];dword;short")

While $nFrameOffset < $nTagSize
    $pFrame = _FileReadToStruct($pFrame, $hFile, $nFrameOffset)
    $sID = DllStructGetData($pFrame, 1)
    $nFrameSize = _SSIntToInt(DllStructGetData($pFrame, 2))
    If $nFrameSize > $nTagSize Then Exitloop
    $pTemp = _FileReadToStruct("byte;byte[" & $nFrameSize - 1 & "]", $hFile, $nFrameOffset + 10)

    $sData = _GetDecodedText(DllStructGetData($pTemp, 1), DllStructGetData($pTemp, 2), $nFrameSize)

    Select
        Case $sID == "TIT2" ; Title 
            $asInfo[0] = $sData
        Case $sID == "TPE1" ; Performer (primary)
            $asInfo[1] = $sData
        Case $sID == "TPE2" ; Performer (secondary)
            If $asInfo[1] == "" Then $asInfo[1] = $sData
        Case $sID == "TALB" ; Album
            $asInfo[2] = $sData
        Case $sID == "TYER" ; Year
            $asInfo[3] = $sData
        Case $sID == "COMM" ; Required special
            If $asInfo[4] == "" Then ; MS ShellExt tag editor add empty COMM at the end of tag...
                ; Not sure if this is correct method...
                If DllStructGetData($pTemp, 2, 4) = 0 Then
                   If DllStructGetData($pTemp, 2, 5) = 0 Then
                       $asInfo[4] = _GetDecodedText(DllStructGetData($pTemp, 1), StringTrimLeft(DllStructGetData($pTemp, 2), 5), $nFrameSize)
                   Else
                       $asInfo[4] = _GetDecodedText(DllStructGetData($pTemp, 1), StringTrimLeft(DllStructGetData($pTemp, 2), 4), $nFrameSize)
                   EndIf
                EndIf
            EndIf
        Case $sID == "TRCK" ; Track number
            $asInfo[5] = $sData
        Case $sID == "TCON" ; Genre
            $asInfo[6] = $sData
            $sData = StringRegExp($sData, "\((\d{1,3})\)", 1)
            If @extended Then $asInfo[6] = _MP3GetGenreByID($sData[0])
        Case $sID == "TLEN" ; Length!
            $asInfo[7] = Int(Number($sData)/1000)
            $asInfo[7] = StringFormat("%d:%02d", Int($asInfo[7] / 60), $asInfo[7] - Int($asInfo[7] / 60) * 60)
        Case StringLen($sID) < 4 or not StringIsAlNum($sID)
            Exitloop ; Zero-byte padding (end of tag), wrong sID -> Exitloop                           
    EndSelect
    $nFrameOffset = $nFrameOffset + $nFrameSize + 10  
    $pTemp = 0
Wend
Return($asInfo)
EndFunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Support functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func _MP3GetGenreByID($iID)
    Local $asGenre = StringSplit("Blues,Classic Rock,Country,Dance,Disco,Funk,Grunge,Hip-Hop," & _
    "Jazz,Metal,New Age, Oldies,Other,Pop,R&B,Rap,Reggae,Rock,Techno,Industrial,Alternative," & _
    "Ska,Death Metal,Pranks,Soundtrack,Euro-Techno,Ambient,Trip-Hop,Vocal,Jazz+Funk,Fusion," & _
    "Trance,Classical,Instrumental,Acid,House,Game,Sound Clip,Gospel,Noise,Alternative Rock," & _
    "Bass,Soul,Punk,Space,Meditative,Instrumental Pop,Instrumental Rock,Ethnic,Gothic,Darkwave," & _
    "Techno-Industrial,Electronic,Pop-Folk,Eurodance,Dream,Southern Rock,Comedy,Cult,Gangsta," & _
    "Top 40,Christian Rap,Pop/Funk,Jungle,Native US,Cabaret,New Wave,Psychadelic,Rave,Showtunes," & _
    "Trailer,Lo-Fi,Tribal,Acid Punk,Acid Jazz,Polka,Retro,Musical,Rock & Roll,Hard Rock,Folk," & _
    "Folk-Rock,National Folk,Swing,Fast Fusion,Bebob,Latin,Revival,Celtic,Bluegrass,Avantgarde," & _
    "Gothic Rock,Progressive Rock,Psychedelic Rock,Symphonic Rock,Slow Rock,Big Band,Chorus," & _
    "Easy Listening,Acoustic,Humour,Speech,Chanson,Opera,Chamber Music,Sonata,Symphony,Booty Bass," & _
    "Primus,Porn Groove,Satire,Slow Jam,Club,Tango,Samba,Folklore,Ballad,Power Ballad,Rhytmic Soul," & _
    "Freestyle,Duet,Punk Rock,Drum Solo,Acapella,Euro-House,Dance Hall,Goa,Drum & Bass,Club-House," & _
    "Hardcore,Terror,Indie,BritPop,Negerpunk,Polsk Punk,Beat,Christian Gangsta,Heavy Metal,Black Metal," & _
    "Crossover,Contemporary C,Christian Rock,Merengue,Salsa,Thrash Metal,Anime,JPop,SynthPop", ",")
    If ($iID >= 0) and ($iID < 148) Then Return $asGenre[$iID + 1]
    Return("")
EndFunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Common functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func _DllStructArrayAsString($p, $index, $size, $start = 1)
    Local $sTemp = "", $char
    For $i = $start to $size
        $char = DllStructGetData($p, $index, $i)
        If $char = 0 then Return $sTemp
        $sTemp &= Chr($char)
    Next
    Return $sTemp
EndFunc

Func _SSIntToInt($nSSInt)
    Local $nRet = 0
    For $i = 0 To 3
        $nRet = $nRet + BitShift(BitAND(BitShift($nSSInt, 8 * (3-$i)), 0xFF), -7 * $i)
    Next
    Return($nRet)
EndFunc

Func _IsBitSet($nNum, $nBit)
    Return BitAND(BitShift($nNum, $nBit), 1)
EndFunc

Func _FileReadToStruct($vStruct, $hFile, $nOffset)
    If not DllStructGetSize($vStruct) Then $vStruct = DllStructCreate($vStruct)
    Local $nLen = DllStructGetSize($vStruct)
    Local $ret  = DllCall("kernel32.dll","int","SetFilePointer", _
                    "int",$hFile, _
                    "int",$nOffset, _
                    "int",0, _
                    "int",0) ; FILE_BEGIN
    Local $pRead = DllStructCreate("dword")
    $ret    = DllCall("kernel32.dll","int","ReadFile", _
                    "int",$hFile, _
                    "ptr",DllStructGetPtr($vStruct), _
                    "int", $nLen, _
                    "ptr",DllStructGetPtr($pRead), _
                    "ptr",0)
    If @error Then 
        SetError(1)
    EndIf
    Local $nRead = DllStructGetData($pRead, 1)
    $pRead = 0
    SetExtended($nRead)
    If not ($nRead = $nLen) Then SetError(2)
    Return $vStruct
EndFunc

Func _GetDecodedText($nType, $sText, $nSize)
    Switch $nType
        Case 0        ; ASCII
            If ($nSize - 1) = 1 Then Return Chr($sText)
            Return $sText
        Case 0x1, 0x2 ; Unicode
            Return _Unicode2Asc($sText)
        Case 0x3      ; UTF-8
            Return _Unicode2Asc(_Utf82Unicode($sText))
    EndSwitch
EndFunc

;;;;;;;;;;;;;;;;;;;;;;;; Unicode conversion functions originally written by Arilvv ;;;;;;;;;;;;;;;;;;;;;;;

Func _Unicode2Asc($UniString)
    Local $lb, $hb, $InpBuf
    Local $BufferLen = StringLen($UniString)
    Local $Input = DllStructCreate("ubyte[" & $BufferLen & "]")
    DllStructSetData($Input, 1, $UniString)
    $lb = DllStructGetData($Input, 1, 1)
    $hb = DllStructGetData($Input, 1, 2)
    If (($lb = 0xFF) and ($hb = 0xFE)) or (($lb = 0xFE) and ($hb = 0xFF)) Then ; BOM found
        $BufferLen -= 2
        $InpBuf = DllStructCreate("byte[" & $BufferLen & "]", DllStructGetPtr($Input) + 2)
    Else
        $InpBuf = DllStructCreate("byte[" & $BufferLen & "]", DllStructGetPtr($Input))
    EndIf

    Local $Output = DllStructCreate("char[" &  $BufferLen & "]")    
    Local $Return = DllCall("kernel32.dll", "int", "WideCharToMultiByte", _
        "int", 0, _
        "int", 0, _
        "ptr", DllStructGetPtr($InpBuf), _
        "int", $BufferLen / 2, _
        "ptr", DllStructGetPtr($Output), _
        "int", $BufferLen, _
        "int", 0, _
        "int", 0)   
    Return DllStructGetData($Output, 1)
EndFunc

Func _Utf82Unicode($Utf8String)
    Local $BufferSize = StringLen($Utf8String) * 2
    Local $Buffer = DllStructCreate("byte[" & $BufferSize & "]")
    Local $Return = DllCall("Kernel32.dll", "int", "MultiByteToWideChar", _
        "int", 65001, _
        "int", 0, _
        "str", $Utf8String, _
        "int", StringLen($Utf8String), _
        "ptr", DllStructGetPtr($Buffer), _
        "int", $BufferSize)
    Return StringLeft(DllStructGetData($Buffer, 1), $Return[0] * 2)
EndFunc

Thanks for youw very useful work

Peppe

Edited by gcriaco
Link to comment
Share on other sites

Hallo gcriaco

I have been away for a easter holliday in Madrid but don't worry, there's been a lot of suggestion and some bugs reported that I nailed down ( I hope ) - as a matter of fact you did marked a troublefull spot for me - Thanks...

I must admit that nearly all PMs trouble comes from IE.au3, genious as it is, also very compact and different structured at in masive 166Kb UDF, I don't quiet understand every acpect in this UDF but can see that there is some vital function calls included in strings and there is no way my Project Manager can see the difference between strings and function calls - I haven't found the clue yet!!! and this is the trouble in your case - but don't despair...

Project manager provide an easy way to include dynamically created functions ec. and in your case it's a function called __IEInternalErrorHandler ( beaware that there's a function called _IEInternalErrorHandler too ) - but as I don't understand this UDF fully, you just have to work around to see if any other function has to be special included by the Function Editor called from the edit menu...

Theres some whole new options available in the new Project Manager revision:

1.Dynamically create TerraTec language translation support, preprocess and buildin these automatically - as an easy option to every application providing languages support, a language translation editor is almost finished and will sone get included into PM...

2.Makefile can now be edited before any scan done...

3.Included a process Information tooltip popup ( '<<' control )...

4.Changed scan process as broken lines do always get sampled to one line in the final script...

5.Global variable values that get included do now always get preprocessed into their real values...

6.New keyword option attached (**) now owerrule the scan process and buildin these #includes into the final script as non processed...

7.Option to increase the scan parametre as an option if something goes wrong...

8.Process time is uptimized a lot as a lot of testing functions is now left out...

9.Gained a lot of executes speed with the processed option 'PreProcess buildin Globals'...

10.Written a lot of topics notes...

Some reported Bug fixes and uptimized security processes done...

Download from site:

http://www.sitecenter.dk/latenight/nss-fol...t%20Manager.zip

Please keep up reporting bugs and comments....

kjactive :shocked:

Edited by kjactive
Link to comment
Share on other sites

New code and new Project Manager = new execution error (see the attached gif):

#Region Compiler directives section
;** This is a list of compiler directives used by CompileAU3.exe.
;** comment the lines you don't need or else it will override the default settings
;#Compiler_Prompt=y                                 ;y=show compile menu
;** AUT2EXE settings
;#Compiler_AUT2EXE=
#Compiler_Icon=Media Clip.ico                       ;Filename of the Ico file to use
;#Compiler_OutFile=                                 ;Target exe filename.
#Compiler_Compression=4                             ;Compression parameter 0-4  0=Low 2=normal 4=High
#Compiler_Allow_Decompile=y                         ;y= allow decompile
;#Compiler_PassPhrase=                              ;Password to use for compilation
;** Target program Resource info
#Compiler_Res_Comment=Podcast Download (http://www.radiorock.to)
#Compiler_Res_Description=Podcast
#Compiler_Res_Fileversion=1.1
#Compiler_Res_LegalCopyright=Giuseppe Criaco
; free form resource fields ... max 15
#Compiler_Res_Field=Email|gcriaco@quipo.it
#Compiler_Res_Field=Release Date|11/4/2007          ;Free format fieldname|fieldvalue
#Compiler_Res_Field=Update Date|11/4/2007           ;Free format fieldname|fieldvalue
#Compiler_Res_Field=Internal Name|Podcast.exe       ;Free format fieldname|fieldvalue
#Compiler_Res_Field=Status|Beta                     ;Free format fieldname|fieldvalue
#Compiler_Run_AU3Check=y                            ;Run au3check before compilation
; The following directives can contain:
;   %in% , %out%, %icon% which will be replaced by the fullpath\filename.
;   %scriptdir% same as @ScriptDir and %scriptfile% = filename without extension.
#Compiler_Run_Before=                               ;process to run before compilation - you can have multiple records that will be processed in sequence
#Compiler_Run_After=move "%out%" "%scriptdir%"      ;process to run After compilation - you can have multiple records that will be processed in sequence
#EndRegion

; ----------------------------------------------------------------------------
; Author:           G Criaco
; Version:          1.1
; Script Function:  Podcast Download
; ----------------------------------------------------------------------------

#include <IE.au3>
;~ #include "get_mp3_tag.au3"

; Installazione Componenti
If @Compiled Then
    FileInstall("Downloader.exe", @ScriptDir & "\Downloader.exe")
EndIf

$oIE =_IECreate("http://www.radiorock.to/index.php", 0, 0,1)
$sText = _IEBodyReadText($oIE)
;~ ConsoleWrite("Body Text: " &  $sText & @CRLF)

;Podcast Today
$iIn = StringInStr($sText, "Il podcast di oggi è condotto da ") + 33
$iOut = StringInStr($sText, ", in onda dal ")
$sPodcasterToday = StringMid($sText, $iIn, $iOut - $iIn)
$iIn = $iOut + 14
$sPodcastTodayDate = StringMid($sText, $iIn, 10)
;~ ConsoleWrite("Podcast: " &  $sPodcasterToday & " - " & $sPodcastTodayDate & @CRLF)

;Podcast Yesterday
$iIn = StringInStr($sText, "il podcast di ieri, condotto da ") + 32
$iOut = StringInStr($sText, " andato in onda il ")
$sPodcasterYesterday = StringMid($sText, $iIn, $iOut - $iIn)
$iIn = $iOut + 19
$sPodcastYesterdayDate = StringMid($sText, $iIn, 10)
;~ ConsoleWrite("Podcast: " &  $sPodcasterYesterday & " - " & $sPodcastYesterdayDate & @CRLF)

#Region --- CodeWizard generated code Start ---
;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes, No, and Cancel, Icon=Question
If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(35,"Podcast",$sPodcasterToday & " - " & $sPodcastTodayDate & @CRLF & $sPodcasterYesterday & " - " & $sPodcastYesterdayDate _
    & @CRLF & @CRLF & "Vuoi eseguire il download?" & @CRLF & "Sì, per scaricare il Podcast di oggi" & @CRLF & "No, per scaricare il podcast di ieri" _
    & @CRLF & "Annulla, per non scaricare")
Select
    Case $iMsgBoxAnswer = 6 ;Yes
        $aDate = StringSplit($sPodcastTodayDate, '/')

        $iRC = RunWait(@ScriptDir & "\Downloader.exe -download http://rockplus.podzone.org/rockplus/pod/rrto" & $aDate[3] & "_" & $aDate[2] & "_" & $aDate[1] & ".mp3 " _
            & '"' & @ScriptDir & "\rrto" & $aDate[3] & "_" & $aDate[2] & "_" & $aDate[1] & "-" & $sPodcasterToday & ".mp3" & '"', @ScriptDir)
        
        ;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Info
        MsgBox(64,"Podcast","Download Podcast di " & $sPodcasterToday & " - " & $sPodcastTodayDate & " OK")

    Case $iMsgBoxAnswer = 7 ;No
        $aDate = StringSplit($sPodcastYesterdayDate, '/')

        $iRC = RunWait(@ScriptDir & "\Downloader.exe -download http://rockplus.podzone.org/rockplus/pod/rrto" & $aDate[3] & "_" & $aDate[2] & "_" & $aDate[1] & ".mp3 " _
            & '"' & @ScriptDir & "\rrto" & $aDate[3] & "_" & $aDate[2] & "_" & $aDate[1] & "-" & $sPodcasterYesterday & ".mp3" & '"', @ScriptDir)
        
        ;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Info
        MsgBox(64,"Podcast","Download Podcast di " & $sPodcasterYesterday & " - " & $sPodcastYesterdayDate & " OK")

    Case $iMsgBoxAnswer = 2 ;Cancel
EndSelect

Exit

;--------------------------------------------------------------------------------------------------------------------------------------------------------------------

;~ Func _RenameMP3()
;~  Dim $iCnt, $sFile, $aData, $aLabel, $sOut = ""

;~  $sFile = "rrto" & @YEAR & "_" & @MON & "_" & @MDAY & ".mp3"
;~  $aData = _MP3GetTag($sFile)
;~  If @error Then 
;~      MsgBox (0, "MP3 Tag Info", "No TAG info was found.")
;~      Exit
;~  Endif

;~  FileMove(@ScriptDir & "\" & $sFile , "rrto" & @YEAR & "_" & @MON & "_" & @MDAY & "-" & $aData[1] & ".mp3", 1)
;~  
;~  Return @ScriptDir & "\" & "rrto" & @YEAR & "_" & @MON & "_" & @MDAY & "-" & $aData[1] & ".mp3"
;~ EndFunc

post-1378-1176449535_thumb.gif

Link to comment
Share on other sites

Hej Peppe

I ran a PM language translation test on your previous script and discovered that you must be from Italy as I now understand what's your application is all about...

Well this is just the same trouble from IE.au3, probably geniious but still a massive 166kb script with a lot of a kind of dynamically function calls - function calls included as strings, actually a lot but I do not use this UDF as I use the native activex components directly and I don't quite understand every aspect in this UDF but there is no way that PM can look into dynamically created functions, these MUST be manually buildin with the script uniqe makefile script - but this process only has to be done ones and actually speedup the scan process....

Run the PreProcessed script from SciTE and you get an error message with more information where in your case it's about a function called __IEInternalErrorHandler ( beaware that there's a function called _IEInternalErrorHandler too )

I will in future look closer into this UDF and maybe get a clue on what to do but until this, please use the manually function include option from the menu 'Function Editor'

Thanks for your report...

kjactive :shocked:

Edited by kjactive
Link to comment
Share on other sites

Hej Peppe

I ran a PM language translation test on your previous script and discovered that you must be from Italy as I now understand what's your application is all about...

Well this is just the same trouble from IE.au3, probably geniious but still a massive 166kb script with a lot of a kind of dynamically function calls - function calls included as strings, actually a lot but I do not use this UDF as I use the native activex components directly and I don't quite understand every aspect in this UDF but there is no way that PM can look into dynamically created functions, these MUST be manually buildin with the script uniqe makefile script - but this process only has to be done ones and actually speedup the scan process....

Run the PreProcessed script from SciTE and you get an error message with more information where in your case it's about a function called __IEInternalErrorHandler ( beaware that there's a function called _IEInternalErrorHandler too )

I will in future look closer into this UDF and maybe get a clue on what to do but until this, please use the manually function include option from the menu 'Function Editor'

Thanks for your report...

kjactive :shocked:

Error message of PreProcessed script from SciTE:

--> IE.au3 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)

--> IE.au3 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)

C:\AutoIt\PodCast\Podcast_Pre.au3 (351) : ==> The requested action with this object has failed.:

"makefile included functions" from the function editor with __IEInternalErrorHandler: anything is OK.

Thanks for support and keep up the good work.

All the best

Peppe.

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