Import pictures

richard z ximcom at hotmail.com
Thu Nov 20 07:19:40 CST 2003


Hi Ruslan,

I´ve tried to post this message to the mailinglist but I just got the mail 
back again. So I´m now posting it to you instead.

Best regards
Richard
---------------------

Hi,

I have some problems with importing pictures into a vdb-file.

First just a quick look how the Director fields and the database fields look 
like:
-----------------------------------------------------------------
-- Copy values from Director fields to the database fields.
-----------------------------------------------------------------
on CollectFields
global gMyDataBase, gCursor
if gMyDataBase = 0 then
return
end if
SetField( gCursor, "title", the text of member "ftitle" )
SetField( gCursor, "idd", the text of member "fidd" )
SetField( gCursor, "author", the text of member "fauthor" )
SetField( gCursor, "isbn", the text of member "fisbn" )
SetField( gCursor, "subject", the text of member "fsubject" )
SetField( gCursor, "desc", the text of member "fdesc" )
SetField( gCursor, "price", the text of member "fprice" )
SetField( gCursor, "year", the text of member "fyear" )
SetField( gCursor, "imageref", the text of member "fimageref" )   --- This 
field (in my backup.txt file) contains all the names of the pictures (from 
1.jpg to 7000.jpg)
end
-----------------------------------------------------------------



I have been using this command to import pictures into my vdb file:
-----------------------------------------------------------------
"dbAddpictures":

      if gMyDataBase = 1 then
      return
      end if

      set tempCursor = new ( xtra "VCursor", GetRef(gMyDataBase),"select * 
from person", kServer, kReadWrite )
      set count to 1

      repeat while count <= 7000

        -- Clear memory buffer of the Cursor for a new record

        SetBlank( tempCursor )

        set c = String(count)

        SetField( tempCursor, "title", "" )
        SetField( tempCursor, "idd", "" )
        SetField( tempCursor, "author", "" )
        SetField( tempCursor, "bn", ""  )
        SetField( tempCursor, "subject", "" )
        SetField( tempCursor, "descr", "" )
        SetField( tempCursor, "price", "" )
        SetField( tempCursor, "year", ""  )
        SetField( tempCursor, "imageref", "" )

        set the filename of member "fimage" to count & ".JPG"
        set the filename of member "fimage" to the moviePath& "Pictures\" & 
count & ".jpg"

        if( count = count ) then
        set thePict = member "fimage"
        end if

        setPicture( tempCursor, "Image", thePict )
        AddRecord( tempCursor )

        put c into field "dbGoToRecord"
        set count = count+1
       end repeat

      -- free Valentina's memory occupied by the cursor.
      set tempCursor = 0
      Flush(gMyDataBase)
-----------------------------------------------------------------


I have been using this command to import the text from the txt file to the 
vdb file:
-----------------------------------------------------------------
"dbImporttext":

if ValidCursor(gCursor) then
ImportASCII( gCursor, "backup.txt", TAB, RETURN )
end if
-----------------------------------------------------------------

If I use the import picture command and then the import text command with 
for example ten records each the vdb file will end up with
with first ten records with pictures (without any text in the text fields), 
and then ten records with the information from the backup.txt file
in text fields (without any pictures in the image field).

This means that I´ll get the double amount of records from what I want and 
no text TOGETHER with picture. The meaning is of course that each picture
should be placed with the belonging text field.

May I please get some help to modify the "dbAddpictures":-command above so 
that the inserting of pictures can be done at the right place in the vdb 
file.

Best regards
Richard

_________________________________________________________________
Hitta rätt köpare på MSN Köp & Sälj http://www.msn.se/koposalj



More information about the Valentina mailing list