Special Characters mess up

Hi,
I’m having a problem in detecting a character in applescript. I am doing an SQL query on a news database (in DTI’s PageSpeed software), and where the ‘tag’ character should appear in the results (which is ASCII character 7), all I get is a square box.
Similarly, when I get this text into applescript as a string and then search through it for the ASCII -7 character it doesn’t detect it. However I am able to send the character directly to PageSpeed, and it appears as it would if typed.
It seems as though the applescript ‘engine’ itself does not recognise the character.
Any ideas??
Thanks,
Peter Dutton.

Is it possible for us to see the code? Most would be able to help if they could see it. :slight_smile:

: Is it possible for us to see the code? Most would be able to help
: if they could see it. :slight_smile:

Here is the code (I have omitted a few stock date conversion routines). Sorry that it’s a bit messy!

copy (ASCII character of 7) to _tag
set headTag to _tag & "Headline" & _tag
set byTag to _tag & "ByLine" & _tag
set textTag to _tag & "Text" & _tag


tell application "PageSpeed42.ppc"
        activate
        set dbref to GetDBHomeRef DBType 1
        -- Type of Database.  News = 1, Ad = 2, Graphics = 3, ClassAd = 4, Locations=5, and High Res=6        
        set this_SQL to "select s.id from story s where s.rundate = "" & dbDate & "" and s.statusid = 2108107"
        set mySQL to my SendSQL(this_SQL, dbref)
end tell

-- Now there is a list of ID's, loop through these to query the DB for text.
repeat with i from 1 to the count of mySQL
        repeat with y from 1 to the count of (item i of mySQL)
                set this_SQL to "select s.text from story s where s.id = " & (item y of (item i of mySQL))
                set this_Rs to my SendSQL(this_SQL, dbref)
                repeat with x from 1 to the count of this_Rs
                        if (item x of this_Rs) does not contain headTag then
                                --tell application (path to frontmost application as text)
                                --beep
                                display dialog "No Headline tag has been defined for this story"
                                --end tell
                        end if
                        if (item x of this_Rs) does not contain byTag then
                                --tell application (path to frontmost application as text)
                                --beep
                                display dialog "No ByLine tag has been defined for this story"
                                --end tell
                        end if
                        if (item x of this_Rs) does not contain textTag then
                                --tell application (path to frontmost application as text)
                                --beep
                                display dialog "No Text tag has been defined for this story"
                                --end tell
                        end if
                        --tell application (path to frontmost application as text)
                        --        display dialog (item x of this_Rs) default answer (item x of this_Rs)
                        --end tell
                end repeat
        end repeat
end repeat


on SendSQL(LocalSQL, activedbRef) -- LocalSQL is your query, activeDBRef is the database type
        tell application "PageSpeed42.ppc"
                set queryRes to (GenericQuery LocalSQL DBProc activedbRef)
                -- genericquery is in pagespeed dictionary requiring query and which db to connect to
        end tell
        return queryRes --returns list of lists {{ }}
end SendSQL

The script always displays the dialog for “no tag defined”, even when I run it on text that I know contains the right tag.

Thanks,

Peter Dutton

ascii character 7 is a non-printing character (the BEL char). non-printing chars always show up as the square box, but the presence of the box indicates that the string does indeed contain the char.
you can’t ‘type’ an ascii 7 char unless you use an escape key sequence. i think you need to tell us exactly what the ‘tag character’ string is that you are searching for. are you sure ‘ascii character 7’ is what you mean?

set str1 to ASCII character 7 
set str2 to ASCII number 7
set str3 to "this string con " & str1 & " tains the character of ascii code # 7 in the middle of the word contains." 
set str4 to "this string con " & str2 & " tains the ascii code # of the character 7 in the middle of the word contains."
set theOffset1 to offset of str1 in str3 set theOffset2 to offset of str2 in str4