Hi,
I have some livecode experts could help me with the following problem.
I am trying to import images using the following script, the result display garbage.
I believed the problem lies in the field "text". How can I overcome this problem.
on mouseUp
   answer file "Select a file" with filter "Web Graphics,*.jpg;*.gif;*.png"
      if it <> "" then
      put it into theFilePath
      --don't forgett the brackets!
      put URL ("file:" & theFilePath) into field "text"
   else
      --no file was selected, or cancel was pressed
      beep
   end if
end mouseUp
Thanks for your help.
			
			
									
									
						How do I import a image file
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: How do I import a image file
Hi tanjc,
well, FIELDS are supposed to display TEXT and IMAGES to display images
You CAN of course display in a field, but not this way, it will requre that the
image is already IN the stack.
Do this to import the user selected image into the stack:
Best
Klaus
			
			
									
									
						well, FIELDS are supposed to display TEXT and IMAGES to display images

You CAN of course display in a field, but not this way, it will requre that the
image is already IN the stack.
Do this to import the user selected image into the stack:
Code: Select all
on mouseUp
  answer file "Select a file" with filter "Web Graphics,*.jpg;*.gif;*.png"
  put it into theFilePath
  
  ## I always check for the NEGATIVE side of things,
  ## so I can avoid long and maybe nested IF...THEN clauses :-)
  if theFilePath = EMPTY then
    beep
    exit mouseup
  end if
  
  ## Import image into stack as a new image:
  import paint from file theFilePath
  ## Done :-)
end mouseUpKlaus
Re: How do I import a image file
Hi...
try something like this...
Notice the difference, with 'set the filename'
Dixie
			
			
									
									
						try something like this...
Code: Select all
on mouseUp
   answer file ""
   if it is not empty then set the filename of image 1 to it
end mouseUpDixie
Re: How do I import a image file
Thanks very much to Klaus and Dixie.  The codes you provide are very useful, exactly what I am looking for.
I am new to LiveCode and have a lot to learn from you guys.
			
			
									
									
						I am new to LiveCode and have a lot to learn from you guys.
