select image, answer

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
reelstuff
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 254
Joined: Mon Apr 16, 2007 12:06 am
Contact:

select image, answer

Post by reelstuff » Mon Aug 13, 2007 12:33 pm

Hello, everyone,

I am very new to revolution, I have more experience in L.A.M.P. than Meta Card or Revolution, so I am trying to adjust to a new way of thinking.

I want to allow a user to choose an image as a background for a form or grouped field, (later I will be figuring out how to output the form)

I found some useful tuts that point me in the right direction for cross platform code,

However, it reads in binary and I need the actual file to display as a background or some other method of allowing the user to place an image in the stack for output later as HTML or some other method of creating the form and image data.

This code is close, it would seem to be very close to what I am looking to do except for the url part which reads the file instead of placing the file in a container ect.

Code: Select all

function GetFileData pPrompt, pMacType, pWinType, pTextOrBinary
  if pPrompt is empty then put "Select a file:" into pPrompt
  if the platform is "MacOS" then
    answer file pPrompt of type pMacType
  else
    answer file pPrompt with filter pWinType
  end if
  if it is empty then exit to top
  if pTextOrBinary is in "binary" then
    put url ("binfile:"&it) into tData
  else put url ("file:"&it) into tData
  Err the result
  return tData
end GetFileData
This is as close as I could find to some examples of allowing the user to choose a file. I like the way this code handles the cros platform issues but apparently I am missing something about calling the file so it can be displayed,

any suggestions or thoughts would be greatly appreciated.

Klaus
Posts: 14190
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Mon Aug 13, 2007 2:40 pm

Hi reelstuff,

I seee 2 alternatives for you:

1. You already have an (empty) image object on your card:

Code: Select all

function GetFileData pPrompt, pMacType, pWinType, pTextOrBinary 
  if pPrompt is empty then put "Select a file:" into pPrompt 
  if the platform is "MacOS" then 
    answer file pPrompt of type pMacType 
  else 
    answer file pPrompt with filter pWinType 
  end if 
  if it is empty then exit to top 
#####
  set the filename of img "Your image here" to it
####
...
2. You import that image to your current card and thus create a new image:

Code: Select all

function GetFileData pPrompt, pMacType, pWinType, pTextOrBinary 
  if pPrompt is empty then put "Select a file:" into pPrompt 
  if the platform is "MacOS" then 
    answer file pPrompt of type pMacType 
  else 
    answer file pPrompt with filter pWinType 
  end if 
  if it is empty then exit to top 
######
import paint form file it
######
...
Hope that helps.


Regards

Klaus

reelstuff
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 254
Joined: Mon Apr 16, 2007 12:06 am
Contact:

thank you

Post by reelstuff » Mon Aug 13, 2007 3:06 pm

that did it, perfectly, thank you

Post Reply