Jump to content

mystery character


Recommended Posts

hello.

i am using Melba's script to pull file information.  The returned data shows question marks only in a consolewrite but not in a msgbox so when I was debugging was getting wrong results. (Note: to get a value back you have to chose an actual photo image that would have date taken field populated)

$sFile = FileOpenDialog("Choose Photo", "Your_Path\", "Images(*.jpg)")

ConsoleWrite(_GetDate($sFile) & @CRLF)
MsgBox(0,"",_GetDate($sFile))

Func _GetDate($sPassed_File_Name)

    Local $iError = 0

    Local $sDir_Name = StringRegExpReplace($sPassed_File_Name, "(^.*\\)(.*)", "\1")
    Local $sFile_Name = StringRegExpReplace($sPassed_File_Name, "^.*\\", "")

    Local $sDOS_Dir = FileGetShortName($sDir_Name, 1)

    Local $oShellApp = ObjCreate("shell.application")
    If IsObj($oShellApp) Then
        Local $oDir = $oShellApp.NameSpace($sDOS_Dir)
        If IsObj($oDir) Then
            Local $oFile = $oDir.Parsename($sFile_Name)
            If IsObj($oFile) Then

                If @OSVersion = "WIN_VISTA" Or @OSVersion = "WIN_7" Then
                    $date = $oDir.GetDetailsOf($oFile, 12) ; Date Taken

                    return $date
                EndIf

            Else
                $iError = 3
            EndIf
        Else
            $iError = 2
        EndIf
    Else
        $iError = 1
    EndIf

    If $iError > 0 Then
        Local $sMsg = "Could not read File Properties" & @CRLF & @CRLF & _
        $iError & @CRLF & @CRLF & $sPassed_File_Name
        MsgBox(0, "Error", $sMsg)
    EndIf

EndFunc

consolewrite

?7/?10/?2012 ??5:55 AM

msgbox (same variable):

7/10/2012 5:55 AM

i try doing a stringreplace to get rid of the "?" but it doesn't work

any thoughts?

thanks in advance!

 

Edited by gcue
Link to comment
Share on other sites

No, ConsoleWrite convert the Unicode string to ANSI (let's call it that name) and ANSI doesn't have these characters, so they get converted (destroyed to) question marks.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

stringtoasciiarray always helps me with garbage text, because my regex is weak

#include<array.au3>

$sFile = FileOpenDialog("Choose Photo", "Your_Path\", "Images(*.jpg)")
$sDate = _GetDate($sFile)
$aAsc = StringToASCIIArray($sDate)

for $i = ubound($aAsc) - 1 to 0 step -1
    If $aAsc[$i] = "8206" then _ArrayDelete($aAsc , $i)
Next

for $i = 0 to ubound($aAsc) - 1
    $aAsc[$i] = Chr($aAsc[$i])
Next

$sFrmt = _ArrayToString($aAsc , "")

consolewrite($sFrmt & @CRLF)
msgbox(0, '' , $sFrmt)


Func _GetDate($sPassed_File_Name)

    Local $iError = 0

    Local $sDir_Name = StringRegExpReplace($sPassed_File_Name, "(^.*\\)(.*)", "\1")
    Local $sFile_Name = StringRegExpReplace($sPassed_File_Name, "^.*\\", "")

    Local $sDOS_Dir = FileGetShortName($sDir_Name, 1)

    Local $oShellApp = ObjCreate("shell.application")
    If IsObj($oShellApp) Then
        Local $oDir = $oShellApp.NameSpace($sDOS_Dir)
        If IsObj($oDir) Then
            Local $oFile = $oDir.Parsename($sFile_Name)
            If IsObj($oFile) Then

                If @OSVersion = "WIN_VISTA" Or @OSVersion = "WIN_7" Then
                    $date = $oDir.GetDetailsOf($oFile, 12) ; Date Taken

                    return $date
                EndIf

            Else
                $iError = 3
            EndIf
        Else
            $iError = 2
        EndIf
    Else
        $iError = 1
    EndIf

    If $iError > 0 Then
        Local $sMsg = "Could not read File Properties" & @CRLF & @CRLF & _
        $iError & @CRLF & @CRLF & $sPassed_File_Name
        MsgBox(0, "Error", $sMsg)
    EndIf

EndFunc

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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