Click the links below to explore the different sections of our site. If you have any questions about our products or services, don't hesitate to contact us.
Following are a number of links to pages that might interest you as a visitor of this web site.
copyright © 2005-07 by Mark Schonewille & Economy-x-Talk

Economy-x-Talk - Sample Scripts

Color Text (CompileIt!)

COMPILEIT HANDLER - Syntax Example:

   put the rect of cd fld ¬
   "whateverField" into theRect
   TextToCard "whateverText",¬
   theRect,"Geneva",9,"yellow",¬
   "center","black"





-- Harry Alloul
global aRect:R[8]

on TextToCard string, where, txtFont, txtSize, txtColor,txtJustify,bkgColor
  -- copyright string and help
  if string="!" then return "TextToCard 1.0 (c)1996 by Harry Alloul - All Rights Reserved"
  if string="?" then return "TextToCard <String>,<Rect>[,<Font>,<Size>,<Color>,<Justification>,<BackColor>]"
  -- check the rect param
  if the number of items of where <>4 then return "Error: Wrong parameter!"
  -- check if color exists
  if txtColor<>empty then put GetTextColor(txtColor)+0 into theColor
  -- check if background color exists
  if bkgColor<>empty then put GetTextColor(bkgColor)+0 into theColor2
  -- check if justification exists
  if txtJustify is not empty then put checkJustif(txtJustify) into theJustify
  GetPort savePort -- save current port
  put EvalExpr("the id of cd window") +0 into theWptr -- convert to windowPtr
  if theWptr=nil then return "Error: can't find the card window!"
  SetPort theWptr -- set to current card
  put theWptr@.txFont into saveFont -- save font
  put theWptr@.txSize into saveSize -- save size
  put theWptr@.fgColor into saveForeColor -- save color
  put theWptr@.bkColor into saveBackColor -- save color
  if txtFont<>empty then GetFNum txtFont, theFNum -- convert to toolbox font num
  if theFNum<>0 then TextFont theFNum -- set the font
  if txtSize+0<>0 then TextSize txtSize+0 -- set the font size
  if theColor<>0 then ForeColor theColor -- set the text color
  if theColor2<>0 then BackColor theColor2 -- set the background color
  StrToRect where,aRect -- convert to toolbox rect
  InsetRect aRect,1,1
  EraseRect aRect -- erase area
  -- then draw the text
  put charsHandle(string) into h
  HLock h
  TextBox h@,the number of chars of string+0,aRect, theJustify
  HUnlock h
  TextFont saveFont -- restore font
  TextSize saveSize -- restore size
  ForeColor saveForeColor -- restore color
  BackColor saveBackColor -- restore color
  SetPort savePort -- restore the window port
end TextToCard

function GetTextColor x
  if x="black" then return 33
  else if x="white" then return 30
  else if x="red" then return 205
  else if x="green" then return 341
  else if x="blue" then return 409
  else if x="cyan" then return 273
  else if x="magenta" then return 137
  else if x="yellow" then return 69
  else return 33 -- black
end GetTextColor

function checkJustif x
  if x="left" then return teJustLeft -- (le nouveau nom est teFlushLeft)
  else if x="center" then return teJustCenter --(teFlushCenter)
  else if x="right" then return teJustRight -- (teFlushRight)
  else return teJustLeft -- left par defaut
end checkJustif






Keep this extensive resource of tutorials and samples on-line! Support RunRev.info!
Yes, this script is useful. I make a donation and choose freely how much I want to donate on-line (PayPal). Click here if you want to make a donation in dollars.This script has not (completely) solved my problem and I want Economy-x-Talk to take care of it. Let me contact you.
Copyright©2002-2008 by Mark Schonewille, Nijmegen, the Netherlands. This web site is in no way affiliated with Runtime Revolution Ltd., but we do recommend the Revolution development platform.