RealBASIC question

FieldDoc

Registered
Hi,

I hope somebody can help me out as I really am struggling with something that is probably fairly simple.

To simplify things, I have 2 edit fields - one named InputField, the other name OutputField. InputField has multiline OFF and is not styled. OutputField is multiline ON, is styled and is NOT enabled (i.e. the user can't type into it).

I have written code that takes the sentence that the user types into InputField, uses the Split function and puts each word of the sentence into a separate element in an array. The code also puts whatever was in InputField at the end of OutputField (preserving what was already in OutputField). InputField is then cleared and a counter records how many lines of text there are in OutputField.

I would like to be able to control the colour of whole lines in OutputField. I have an array called LineColour that stores the RGB colour that I want for the corresponding line in OutputField to be (for instance if LineColour(5) = RGB(255, 0, 0) I want all of line 5 in OutputField to be red. Can anybody help me in making this happen. I really can't figure it out. It just seems too complicated - as I essentially have a large string (in OutputField) that needs certain parts one colour and other parts another.

Any and all help greatly appreciated,

FieldDoc
 
Hmm, I think one possible way that comes in my mind is a funktion that take the actual value from outpufield and copy it to a dummy var. That start using somethink like:

DummyVar=OutputField.Text

For Counter=1 To CountFields(DummyVar,Chr(10))

// Get the next line
ThisLIne=NthField(DummyVar,Chr(10),Counter)

// Remember the actualk length
ActualFieldLen=Len(Outputfiled.Text)

// Add the next line to the field
Outputfield.SelStart=ActualFieldLen
OutpuField.SetText=ThisLine+Chr(10)

// Select the last inserted line
Outputfield.SelStart=ActualFieldLen
OutputField.SelLength=Len(ThisLine)
OutputFielf.SelTextColor=MyLineColor(Counter)

Next


Ok, this is maybe not a perfect solution and need to be checked for typos. But in general this should work for you. Chr(10) is the NextLIne Char used in EditField on a Mac so you can use this to split the lines around this char.

And if you havent used it bevor:

Outputfield.SelStart=ActualFieldLen
OutpuField.SetText=ThisLine+Chr(10)
is the same as
OutputField.Text=OutputField.Text+ThisLine+Chr(10)
just that it works faster and doesn't cause flickering.

If you've got any further questions feel free to contact me direct using AIM/ICQ or Mail.
 
Back
Top