Image in text and variables

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
ajperks
Posts: 60
Joined: Sat Sep 06, 2014 3:38 pm

Image in text and variables

Post by ajperks » Wed Nov 14, 2018 8:38 pm

As part of my project, I can put images in with the text in a text field.
At the moment, everything is being done in a test stack for ease of working.
I simply use this code to get and place the picture.

To acquire the picture I use this.

Code: Select all

on mouseup
   local tHeight, twidth, NewWth, NewHt, Ratio, tempvar
   Set height of image id 1840 to 268
   set width of image id 1840 to 332
   if the text of the target is empty then -- no painted pixels
      answer file "Please choose an image to display:" with type "All Images|jpg,jpeg,gif,png|JPEG,GIFf,PNGf"
      set the filename of image id 1840 to it
      
      put the formattedWidth of image id 1840 into twidth
      put the formattedheight of image id 1840 into tHeight
      put tWidth / tHeight into Ratio
      
      if tWidth > tHeight then
         put 332 into NewWth
         put 332 / ratio into NewHt
      else
         put  268  into NewHt
         put 268 * ratio into NewWth
      end if 
      
   end if  

   Set height of image id 1840 to NewHt
   set width of image id 1840 to NewWth   
     
end mouseup 
To place the picture in the text field I use this.

Code: Select all

on mouseup
 
   set the imageSource of last char  of fld "NewPost" to 1840
   --put empty into image id 1836
   --set the htmltext of  fld "Field" to the htmltext of fld "NewPost"
   
end mouseup

I need some help and advice on placing that text with image into another variable.

Also, how can the text and image be stored as an item, in a table field or other storage medium.

Is this easier to do with the browser object and if so, how do I save the combined data from this object?

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”