Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change readFromFile value through user input on a form

Status
Not open for further replies.

SleepingGiant

Programmer
Jul 8, 2002
7
US
I'm trying to create an image viewer that will display thumbnails that can change when called for by user input on a form. I have an edit field on the form called ID# for input from the user to key in a 6 digit number which corresponds to a named .jpg file in the alias IMAGE directory, (EG: 602001 = 602001.jpg, 602002 = 602002.jpg). If the image file called for is not there, it will display a static image showing Image Not Available. I'm having trouble with the ~(tilde) function creating a call for the named image file desired. If I hard code the correct 6 digit name with the file extension after, it works. If I alter it to a file name that does not exist, the static image displays correctly. I'm using Paradox v 10.0.0.719 and here is the code I have:

method pushButton(var eventInfo Event)
var
prodImg,INAImg Graphic
ID String
endVar
ID=ID#

if prodImg.readFromFile(":IMAGE:~ID.jpg") then
ImgArea = prodImg
else
INAImg.readFromFile(":IMAGE:INA.bmp")
ImgArea = INAImg
endIf
endMethod

Any assistance would be greatly appreciated. TIA

Walt :)
 
Try this. The tilde variables are only used for querys.

Code:
method pushButton(var eventInfo Event)
var 
  prodImg,INAImg Graphic
  ID String 
endVar  
 ID=ID#

if prodImg.readFromFile(":IMAGE:"+ID+".jpg") then
  ImgArea = prodImg
else
  INAImg.readFromFile(":IMAGE:INA.bmp")
  ImgArea = INAImg
endIf
endMethod

Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
if ID# holds a numeric or integer value (not a string) you will have to cast it as a string:

prodImg.readFromFile(":IMAGE:"+string(ID)+".jpg")



Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
Thanks Langley!

ID# does not contain a string. The six digit number is only an ID number to identify a specific item. My image files of each item are named by the id number. So using the (":IMAGE:"+ID+".jpg") makes it work exactly the way I need it to. I appreciate your assistance. Thanks again.

Walt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top