'Set file name for Image field + set a default folder & image.
ImageFilename = ui_get_image_filename(a5.get_path()+"\Photos\Products\small\default.jpg")
If ImageFilename = ""
then
'user selected cancel, so end script
end
end if
Dim TempObj as p
dim readonly_flag as l
'Get a pointer to the Object on the Form/Browse that has the image file ref field.
TempObj = obj(topparent.name(16)+":"+"Image")
'Check if the image field is readonly
readonly_flag = TempObj.field.readonly
if readonly_flag = .t.
then
ui_msg_box("Error","Cannot change image in Image field '"+"Image"+"' because it is read-only",UI_STOP_SYMBOL)
end
else
dim Tbl as p
'Get a pointer to the table for the image field
Tbl = tempobj.Field_Get().table_get()
dim Fld as p
'Get a pointer to the image field
Fld = tempobj.field_get()
'If the table is in View mode, put it in change mode
If tbl.mode_get() = 0 then
tbl.change_begin()
fld.value_put(image_filename_encode(ImageFileName))
tbl.change_end(.t.)
else
fld.value_put(image_filename_encode(ImageFileName))
end if
'now refresh the object
tempObj.refresh() end if
'Get the full path and set images name in the field iname
DIM vfile as C
vfile=a5_eval_expression(parentform.image)
'Now just get the file name with extension
DIM vfile2 as C
vfile2=file.filename_parse(vfile,"ne")
parentform:iname.value=vfile2
end if |