Table name: pics
Field Memo(binary): pict

I saved a JPEG file to a memo(binary) field with the following code:
mbpict=filetostr("c:\pictures\xxxx.jpg")
sele pics
append blank
replace pict with mbpict

I have a form with a grid displaying other info from the table pics.dbf. As
I move through each record in the grid I want to display the jpg saved to a
memo(binary) field with filetostr(). I've gone to the AfterRowColumnChange in
the Grid and added the following code:

STRTOFILE(pics.pict,"temp.jpg")
thisform.image1.PictureVal="temp.jpg"
thisform.refresh

Nothing displays.

Once I get it to display I have another issue that I believe I can use to
append multiple jpg's to a table. Originally I was appending to a general
field but I've noticed most have suggested saving it to a memo(binary). That
sounds better since you can't display a JPG in an Image control (only the
name). If I could I might keep the use of the general field.
I use GETDIR() to locate the pictures I want to pull in. I save them in a
general field. If I'm going to save them in a memo(binary) field what would
the code be? Below is the code to append to the general field.

Current code:
CD GETDIR()
nFiles = ADIR(ajpeg, "*.jpg")
IF nFiles > 0
FOR i = 1 to nFiles
APPEND BLANK
APPEND GENERAL pic FROM ajpeg(i,1)
REPLACE pics.descripe WITH ajpeg(i,1)
replace picdate WITH DATE()
ENDFOR
ENDIF

Thanks
Rusty Gallo

RE: JPEG display in Image control using STRTOFILE() by Allan

Allan
Sat Jun 16 23:14:00 CDT 2007

hi rusty,

assuming the original file ext is .JPG, your code could be:

*-- create a Temp File
lcFileName = GETENV("TEMP") + "\" + "_"+SUBSTR(SYS(2015), 4) + ".JPG"

*-- test if the extraction is successful
IF STRTOFILE(pics.pict, lcFileName) > 0
IF FILE(lcFileName)
ThisForm.image1.Picture = lcFileName
ThisForm.image1.Refresh()
ENDIF
ENDIF

you can also put a clean up code when you close the form like erasing the
temp file, or so...

hope this would help...

allan

"Rusty" wrote:

> Table name: pics
> Field Memo(binary): pict
>
> I saved a JPEG file to a memo(binary) field with the following code:
> mbpict=filetostr("c:\pictures\xxxx.jpg")
> sele pics
> append blank
> replace pict with mbpict
>
> I have a form with a grid displaying other info from the table pics.dbf. As
> I move through each record in the grid I want to display the jpg saved to a
> memo(binary) field with filetostr(). I've gone to the AfterRowColumnChange in
> the Grid and added the following code:
>
> STRTOFILE(pics.pict,"temp.jpg")
> thisform.image1.PictureVal="temp.jpg"
> thisform.refresh
>
> Nothing displays.
>
> Once I get it to display I have another issue that I believe I can use to
> append multiple jpg's to a table. Originally I was appending to a general
> field but I've noticed most have suggested saving it to a memo(binary). That
> sounds better since you can't display a JPG in an Image control (only the
> name). If I could I might keep the use of the general field.
> I use GETDIR() to locate the pictures I want to pull in. I save them in a
> general field. If I'm going to save them in a memo(binary) field what would
> the code be? Below is the code to append to the general field.
>
> Current code:
> CD GETDIR()
> nFiles = ADIR(ajpeg, "*.jpg")
> IF nFiles > 0
> FOR i = 1 to nFiles
> APPEND BLANK
> APPEND GENERAL pic FROM ajpeg(i,1)
> REPLACE pics.descripe WITH ajpeg(i,1)
> replace picdate WITH DATE()
> ENDFOR
> ENDIF
>
> Thanks
> Rusty Gallo
>

Re: JPEG display in Image control using STRTOFILE() by Stefan

Stefan
Sun Jun 17 04:26:41 CDT 2007

In addition to Alan's comment...

"Rusty" <Rusty@discussions.microsoft.com> schrieb im Newsbeitrag
news:C91888EF-1821-4B11-9C69-098280793CF7@microsoft.com...
> Table name: pics
> Field Memo(binary): pict
>
> I saved a JPEG file to a memo(binary) field with the following code:
> mbpict=filetostr("c:\pictures\xxxx.jpg")
> sele pics
> append blank
> replace pict with mbpict
>
> I have a form with a grid displaying other info from the table pics.dbf.
> As
> I move through each record in the grid I want to display the jpg saved to
> a
> memo(binary) field with filetostr(). I've gone to the AfterRowColumnChange
> in
> the Grid and added the following code:
>
> STRTOFILE(pics.pict,"temp.jpg")
> thisform.image1.PictureVal="temp.jpg"
> thisform.refresh
>
> Nothing displays.

You can StrToFile() the binary content but then you'd use the
image.Picture property.
When you want to use the image.PictureVal property, you do
not need the additional rewrite-to-disk step:
thisform.image1.PictureVal=pics.pict &&w/o quotes


> STRTOFILE(pics.pict,"temp.jpg")
This one would not work on Vista or on WinXP when the user account
is a "Limited" one. You'd better write the temp file into the
GetEnv("Temp") folder for example.


hth
-Stefan




--
|\_/| ------ ProLib - programmers liberty -----------------
(.. ) Our MVPs and MCPs make the Fox run....
- / See us at www.prolib.de or www.AFPages.de
-----------------------------------------------------------



RE: JPEG display in Image control using STRTOFILE() by Rusty

Rusty
Mon Jun 18 08:17:00 CDT 2007

Thanks...it's perfect.

"Allan" wrote:

> hi rusty,
>
> assuming the original file ext is .JPG, your code could be:
>
> *-- create a Temp File
> lcFileName = GETENV("TEMP") + "\" + "_"+SUBSTR(SYS(2015), 4) + ".JPG"
>
> *-- test if the extraction is successful
> IF STRTOFILE(pics.pict, lcFileName) > 0
> IF FILE(lcFileName)
> ThisForm.image1.Picture = lcFileName
> ThisForm.image1.Refresh()
> ENDIF
> ENDIF
>
> you can also put a clean up code when you close the form like erasing the
> temp file, or so...
>
> hope this would help...
>
> allan
>
> "Rusty" wrote:
>
> > Table name: pics
> > Field Memo(binary): pict
> >
> > I saved a JPEG file to a memo(binary) field with the following code:
> > mbpict=filetostr("c:\pictures\xxxx.jpg")
> > sele pics
> > append blank
> > replace pict with mbpict
> >
> > I have a form with a grid displaying other info from the table pics.dbf. As
> > I move through each record in the grid I want to display the jpg saved to a
> > memo(binary) field with filetostr(). I've gone to the AfterRowColumnChange in
> > the Grid and added the following code:
> >
> > STRTOFILE(pics.pict,"temp.jpg")
> > thisform.image1.PictureVal="temp.jpg"
> > thisform.refresh
> >
> > Nothing displays.
> >
> > Once I get it to display I have another issue that I believe I can use to
> > append multiple jpg's to a table. Originally I was appending to a general
> > field but I've noticed most have suggested saving it to a memo(binary). That
> > sounds better since you can't display a JPG in an Image control (only the
> > name). If I could I might keep the use of the general field.
> > I use GETDIR() to locate the pictures I want to pull in. I save them in a
> > general field. If I'm going to save them in a memo(binary) field what would
> > the code be? Below is the code to append to the general field.
> >
> > Current code:
> > CD GETDIR()
> > nFiles = ADIR(ajpeg, "*.jpg")
> > IF nFiles > 0
> > FOR i = 1 to nFiles
> > APPEND BLANK
> > APPEND GENERAL pic FROM ajpeg(i,1)
> > REPLACE pics.descripe WITH ajpeg(i,1)
> > replace picdate WITH DATE()
> > ENDFOR
> > ENDIF
> >
> > Thanks
> > Rusty Gallo
> >

Re: JPEG display in Image control using STRTOFILE() by Rusty

Rusty
Mon Jun 18 08:19:00 CDT 2007

Thanks...


"Stefan Wuebbe" wrote:

> In addition to Alan's comment...
>
> "Rusty" <Rusty@discussions.microsoft.com> schrieb im Newsbeitrag
> news:C91888EF-1821-4B11-9C69-098280793CF7@microsoft.com...
> > Table name: pics
> > Field Memo(binary): pict
> >
> > I saved a JPEG file to a memo(binary) field with the following code:
> > mbpict=filetostr("c:\pictures\xxxx.jpg")
> > sele pics
> > append blank
> > replace pict with mbpict
> >
> > I have a form with a grid displaying other info from the table pics.dbf.
> > As
> > I move through each record in the grid I want to display the jpg saved to
> > a
> > memo(binary) field with filetostr(). I've gone to the AfterRowColumnChange
> > in
> > the Grid and added the following code:
> >
> > STRTOFILE(pics.pict,"temp.jpg")
> > thisform.image1.PictureVal="temp.jpg"
> > thisform.refresh
> >
> > Nothing displays.
>
> You can StrToFile() the binary content but then you'd use the
> image.Picture property.
> When you want to use the image.PictureVal property, you do
> not need the additional rewrite-to-disk step:
> thisform.image1.PictureVal=pics.pict &&w/o quotes
>
>
> > STRTOFILE(pics.pict,"temp.jpg")
> This one would not work on Vista or on WinXP when the user account
> is a "Limited" one. You'd better write the temp file into the
> GetEnv("Temp") folder for example.
>
>
> hth
> -Stefan
>
>
>
>
> --
> |\_/| ------ ProLib - programmers liberty -----------------
> (.. ) Our MVPs and MCPs make the Fox run....
> - / See us at www.prolib.de or www.AFPages.de
> -----------------------------------------------------------
>
>
>

Re: JPEG display in Image control using STRTOFILE() by Dan

Dan
Mon Jun 18 11:04:49 CDT 2007

This will break on systems that already have a backslash on Getenv("TEMP").

Use Addbs(Getenv("TEMP")) instead.

Dan

Allan wrote:
> hi rusty,
>
> assuming the original file ext is .JPG, your code could be:
>
> *-- create a Temp File
> lcFileName = GETENV("TEMP") + "\" + "_"+SUBSTR(SYS(2015), 4) + ".JPG"
>
> *-- test if the extraction is successful
> IF STRTOFILE(pics.pict, lcFileName) > 0
> IF FILE(lcFileName)
> ThisForm.image1.Picture = lcFileName
> ThisForm.image1.Refresh()
> ENDIF
> ENDIF
>
> you can also put a clean up code when you close the form like erasing
> the temp file, or so...
>
> hope this would help...
>
> allan
>
> "Rusty" wrote:
>
>> Table name: pics
>> Field Memo(binary): pict
>>
>> I saved a JPEG file to a memo(binary) field with the following
>> code: mbpict=filetostr("c:\pictures\xxxx.jpg")
>> sele pics
>> append blank
>> replace pict with mbpict
>>
>> I have a form with a grid displaying other info from the table
>> pics.dbf. As I move through each record in the grid I want to
>> display the jpg saved to a memo(binary) field with filetostr(). I've
>> gone to the AfterRowColumnChange in the Grid and added the following
>> code:
>>
>> STRTOFILE(pics.pict,"temp.jpg")
>> thisform.image1.PictureVal="temp.jpg"
>> thisform.refresh
>>
>> Nothing displays.
>>
>> Once I get it to display I have another issue that I believe I
>> can use to append multiple jpg's to a table. Originally I was
>> appending to a general field but I've noticed most have suggested
>> saving it to a memo(binary). That sounds better since you can't
>> display a JPG in an Image control (only the name). If I could I
>> might keep the use of the general field. I use GETDIR() to locate
>> the pictures I want to pull in. I save them in a general field. If
>> I'm going to save them in a memo(binary) field what would the code
>> be? Below is the code to append to the general field.
>>
>> Current code:
>> CD GETDIR()
>> nFiles = ADIR(ajpeg, "*.jpg")
>> IF nFiles > 0
>> FOR i = 1 to nFiles
>> APPEND BLANK
>> APPEND GENERAL pic FROM ajpeg(i,1)
>> REPLACE pics.descripe WITH ajpeg(i,1)
>> replace picdate WITH DATE()
>> ENDFOR
>> ENDIF
>>
>> Thanks
>> Rusty Gallo



Re: JPEG display in Image control using STRTOFILE() by Anders

Anders
Mon Jun 18 13:23:53 CDT 2007

Image.Picture = "temp.jpg"
Image.PictureVal= picts.pict

-Anders

"Rusty" <Rusty@discussions.microsoft.com> wrote in message
news:C91888EF-1821-4B11-9C69-098280793CF7@microsoft.com...
> Table name: pics
> Field Memo(binary): pict
>
> I saved a JPEG file to a memo(binary) field with the following code:
> mbpict=filetostr("c:\pictures\xxxx.jpg")
> sele pics
> append blank
> replace pict with mbpict
>
> I have a form with a grid displaying other info from the table pics.dbf.
> As
> I move through each record in the grid I want to display the jpg saved to
> a
> memo(binary) field with filetostr(). I've gone to the AfterRowColumnChange
> in
> the Grid and added the following code:
>
> STRTOFILE(pics.pict,"temp.jpg")
> thisform.image1.PictureVal="temp.jpg"
> thisform.refresh
>
> Nothing displays.
>
> Once I get it to display I have another issue that I believe I can use
> to
> append multiple jpg's to a table. Originally I was appending to a general
> field but I've noticed most have suggested saving it to a memo(binary).
> That
> sounds better since you can't display a JPG in an Image control (only the
> name). If I could I might keep the use of the general field.
> I use GETDIR() to locate the pictures I want to pull in. I save them in
> a
> general field. If I'm going to save them in a memo(binary) field what
> would
> the code be? Below is the code to append to the general field.
>
> Current code:
> CD GETDIR()
> nFiles = ADIR(ajpeg, "*.jpg")
> IF nFiles > 0
> FOR i = 1 to nFiles
> APPEND BLANK
> APPEND GENERAL pic FROM ajpeg(i,1)
> REPLACE pics.descripe WITH ajpeg(i,1)
> replace picdate WITH DATE()
> ENDFOR
> ENDIF
>
> Thanks
> Rusty Gallo
>