Richtext to field conversion


[ Zettels Traum ] [ search / suche ]

At 15:05 21.08.98 +0200, you wrote:
>Hi,
>I have about 1200 RTF-text members which I would like to convert to field
>members so they can be manipulated at runtime. How do I do this?
>There must be a more efficient way than copy, paste and then format the
fields
>by hand.

this function does what you need.
it replaces #richtext members by #field members with the same text and name.
in order to keep you from accidentially replacing to often you have to feed
it the castlib, slotnumber in that castLib to begin at and slot number to
end. Those two parameters are optional and default to 1 or the last member
in the castlib.
it will scan the members within that range and only affect #richtext.


on richtextToField dLib,von,bis
  -- @ dp 11.2.98
  -- ersetzt Kommentare in #richtext durch Kommentare als field
  -- Parameter dLib zur Sicherheit obligat
  -- Parameter von,bis optional, grenzen den Bereich ein,
  --           in dem getauscht werden soll

  -- Aufruf Beispiel: richtextToField 1,12,15

  -- Argumente pruefen
  if voidP (dLib) then
    sendAlert "Zur Sicherheit verlangt dies Teil, ,
          das ausdruecklich eine Castlib als Argument benannt werden muss"
    return
  end if

  if voidP(von) then set von=1
  if voidP(bis) then set bis=the number of members of castlib dLib

  repeat with dMemberNum=von to bis
    set dMember=member dMemberNum of CastLib dLib
    -- nur #richtexts
    if the type of member dMember  <> #richText then next repeat

    -- Inhalt sichern
    set dText=the text of member dMember
    set dName=the name of member dMember

    -- #richtext weg und dorthin entsprechendes #Field
    erase member dMember
    set neu= new(#field, member dMemberNum of castLib dLib)
    set the Text of member Neu=dText
    set the name of member Neu=dName
  end repeat

end


Best regards
Daniel Plaenitz




Dazu:























D. Plänitz