PDA

View Full Version : This may be a bug testing image fields and variables. Please advise?


ABC123

DaveM
01-12-2015, 04:40 PM
Any and all help is appreciated! Thanks in advance!

dim global vstimg4 as c ="x"
dim global vstimg3 as c ="x"
dim global vstimg2 as c ="x"
dim global vstimg1 as c ="x"
var->vstimg4 = parentform:Img4.value
var->vstimg3 = parentform:Img3.value
var->vstimg2 = parentform:Img2.value
var->vstimg1 = parentform:Img1.value


3953639537

I have declared 4 global variables( so I could see easy for testing. The idea is to read the four image(png) fields to see if anything is there. I can only get 3 fields and 3 variables in the read out whether empty or no. Img 2 is blank as it should be. Xbasic is being cal from on depart of image field. image field 4 is not in the variable list at all(biggest problem)

Stan Mathews
01-12-2015, 05:50 PM
A jpg/jpeg/png field's form object value is binary data. Not sure you can test that way.

Try this button code. (Alter to suit your situation.)

tst = parentform:img.value
ui_msg_box("",""+isblank("var->tst"))

DaveM
01-12-2015, 05:56 PM
Actually it does test that way since I am only testing for the existence of anything.

Oddly the variables are there and they are working, but do not show in the global variable viewer.

I have an image in img 1 and img 4



?var->vstimg4
= ‰PNG
?var->vstimg2
= ""
?var->vstimg3
= ""
?var->vstimg1
= ‰PNG



It has to be abug in the reader. No big deal Wonder if I should report it??

I went ahead and reported it. It is a small bug, but cost me a couple hours of extra work and could save someone else more.

DaveM
01-13-2015, 01:52 AM
To help anybody else needing to do this(an I am sure there are better ways) Here is the complete code I needed for the process. It counts the images(max is 4) and sets a counter field for the actual amout starting with 1 then 2. If they skip one of the image fields, it will not count the next field if there is one. Using this when you read an empty img field that is empty it gives "" and if it has something in it gives "%.png"



dim shared vstimg4 as c =""
dim shared vstimg3 as c =""
dim shared vstimg2 as c =""
dim shared vstimg1 as c =""

dim shared timg1 as L = .f.
dim shared timg2 as L = .f.
dim shared timg3 as L = .f.
dim shared timg4 as L = .f.
'-----------------------------------------
dim vidnum as n
dim t as P
'read the id_num field from form
var->vidnum = parentform.id_num.value
dim vmode as n
t = table.get("stuccoimg")
vmode = t.mode_get()
select
case vmode = 0
t.change_begin()
case vmode = 2
t.enter_end()
t.change_begin()
end select
dim shared nimages as n
'-----------------------------------------Getting values from image fields
var->vstimg4 = parentform:Img4.value
var->vstimg3 = parentform:Img3.value
var->vstimg2 = parentform:Img2.value
var->vstimg1 = parentform:Img1.value

if var->vstimg1 <> "" then
var->timg1 = .t.
end if

if var->vstimg2 <> "" then
var->timg2 = .t.
end if

if var->vstimg3 <> "" then
var->timg3 = .t.
end if

if var->vstimg4 <> "" then
var->timg4 = .t.
end if

select 'setting the number of images
case var->timg4 = .t. .AND. var->timg3 = .t. .AND. var->timg2 = .t. .AND. var->timg1 = .t.
var->nimages = 4
case var->timg4 = .f. .AND. var->timg3 = .t. .AND. var->timg2 = .t. .AND. var->timg1 = .t.
var->nimages = 3
case var->timg4 = .f. .AND. var->timg3 = .f. .AND. var->timg2 = .t. .AND. var->timg1 = .t.
var->nimages = 2
case var->timg4 = .f. .AND. var->timg3 = .f. .AND. var->timg2 = .f. .AND. var->timg1 = .t.
var->nimages = 1
case var->timg4 = .f. .AND. var->timg3 = .f. .AND. var->timg2 = .f. .AND. var->timg1 = .f.
var->nimages = 0
end select

t.howmany = var->nimages ' posting to the needed table
t.change_end()