I have several Xbasic functions that deal with 7 image controls in a ux component. Every time I work with them I have to use 7 individual if...else statements. Listed at the bottom of this post is an example of one of the 7 if/else statement groups. As you can see, the only difference in any of the conditions is the photo number (1 through 7). I'm converting from MS Access and in vba I would have used a for...next loop and substituted the photo number to construct the variable/control names something like this:
for x = 1 to 7
if e.dataSubmitted.("PHOTO" + x + "CHECKBOX") == "true" then
("fn_image" + x) = ""
else
("fn_image" + x) = rs.data("Photo" + x)
("fn_thumb" + x) = rs.data("Photo" + x + "thumb")
end if
next x
Is this possible in Xbasic?
Example Loop Statements:
if e.dataSubmitted.PHOTO1CHECKBOX == "true" then
fn_image1 = ""
else
fn_image1 = rs.data("Photo1")
fn_thumb1 = rs.data("Photo1thumb")
end if
if e.dataSubmitted.PHOTO2CHECKBOX == "true" then
fn_image2 = ""
else
fn_image2 = rs.data("Photo2")
fn_thumb2 = rs.data("Photo2thumb")
end if
if e.dataSubmitted.PHOTO3CHECKBOX == "true" then
fn_image3 = ""
else
fn_image3 = rs.data("Photo3")
fn_thumb3 = rs.data("Photo3thumb")
end if
if e.dataSubmitted.PHOTO4CHECKBOX == "true" then
fn_image4 = ""
else
fn_image4 = rs.data("Photo4")
fn_thumb4 = rs.data("Photo4thumb")
end if
if e.dataSubmitted.PHOTO5CHECKBOX == "true" then
fn_image5 = ""
else
fn_image5 = rs.data("Photo5")
fn_thumb5 = rs.data("Photo5thumb")
end if
if e.dataSubmitted.PHOTO6CHECKBOX == "true" then
fn_image6 = ""
else
fn_image6 = rs.data("Photo6")
fn_thumb6 = rs.data("Photo6thumb")
end if
if e.dataSubmitted.PHOTO7CHECKBOX == "true" then
fn_image7 = ""
else
fn_image7 = rs.data("Photo7")
fn_thumb7 = rs.data("Photo7thumb")
end if
for x = 1 to 7
if e.dataSubmitted.("PHOTO" + x + "CHECKBOX") == "true" then
("fn_image" + x) = ""
else
("fn_image" + x) = rs.data("Photo" + x)
("fn_thumb" + x) = rs.data("Photo" + x + "thumb")
end if
next x
Is this possible in Xbasic?
Example Loop Statements:
if e.dataSubmitted.PHOTO1CHECKBOX == "true" then
fn_image1 = ""
else
fn_image1 = rs.data("Photo1")
fn_thumb1 = rs.data("Photo1thumb")
end if
if e.dataSubmitted.PHOTO2CHECKBOX == "true" then
fn_image2 = ""
else
fn_image2 = rs.data("Photo2")
fn_thumb2 = rs.data("Photo2thumb")
end if
if e.dataSubmitted.PHOTO3CHECKBOX == "true" then
fn_image3 = ""
else
fn_image3 = rs.data("Photo3")
fn_thumb3 = rs.data("Photo3thumb")
end if
if e.dataSubmitted.PHOTO4CHECKBOX == "true" then
fn_image4 = ""
else
fn_image4 = rs.data("Photo4")
fn_thumb4 = rs.data("Photo4thumb")
end if
if e.dataSubmitted.PHOTO5CHECKBOX == "true" then
fn_image5 = ""
else
fn_image5 = rs.data("Photo5")
fn_thumb5 = rs.data("Photo5thumb")
end if
if e.dataSubmitted.PHOTO6CHECKBOX == "true" then
fn_image6 = ""
else
fn_image6 = rs.data("Photo6")
fn_thumb6 = rs.data("Photo6thumb")
end if
if e.dataSubmitted.PHOTO7CHECKBOX == "true" then
fn_image7 = ""
else
fn_image7 = rs.data("Photo7")
fn_thumb7 = rs.data("Photo7thumb")
end if
Comment