Paul's Handy Scripts

Date:    Wed, 27 Mar 1996 17:26:11 +1000
From:    Paul Farry 
Subject: Coupla handy little scripts for you all




on padout str,whatchar,len,beforeorafter
  --Script written by Paul Farry (p.farry@cqu.edu.au)
  --Interactive Multimedia Unit
  --Central Queensland University
  --
  --Leave the comments in if you use this script
  --
  set slen = length(string(str))
  set howmany = len-slen
  if (howmany > 0)  then
    repeat with i = 1 to howmany
      if beforeorafter = #before then --it's going before
        set str = whatchar & str
      else if beforeorafter = #after then
        set str = str & whatchar
      end if
    end repeat
  end if
  return str
end

set myNumber = 22
put Padout(myNumber,"a",5,#before)
-- "aaa22"

put Padout(myNumber,"b",5,#after)
-- "22bbb"

You could add this little bit of script to the start of a routine, and then not actually have to worry about how many parameters get passed in.

on paramcompiler
  --Script written by Paul Farry (p.farry@cqu.edu.au)
  --Interactive Multimedia Unit
  --Central Queensland University
  --
  --Leave the comments in if you use this script
  --
  --Following is an explanation, you may remove this line and the explanation.
  --
  --You may like to exclude the first param, if you are say calling a
  --mouseup(script "gg",1)
  --                    ^maybe you could fake a clickon
  -- Can you see the potential ..
  set xx = []
  set firstparam = 1  --This is the first parameter you want to deal with
  repeat with i = firstparam to paramcount()
    append xx,param(i)
  end repeat
  callanotherprocedure(xx)
end