Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSAttributedStringMBS class.

NSAttributedStringMBS.initWithAttributedString(text as NSAttributedStringMBS) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of the given attributed string.

Returns true on success.

NSAttributedStringMBS.initWithDocFormat(data as MemoryBlock) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Initializes string with content of given DOC file data.

Returns true on success.
documentAttributes: Optional dictionary to receive the attributes.

See also:

NSAttributedStringMBS.initWithDocFormat(data as memoryblock, byref documentAttributes as dictionary) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Initializes string with content of given DOC file data.

Returns true on success.
documentAttributes: Optional dictionary to receive the attributes.

See also:

NSAttributedStringMBS.initWithHTML(data as MemoryBlock) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of given HTML file data.
Example
Var n as NSAttributedStringMBS
n=new NSAttributedStringMBS
if n.initWithHTML("<b>test</b>") then
MsgBox n.text
else
MsgBox "failed"
end if

Var attribText as new NSAttributedStringMBS
Var text as string = "<P>Hello öäü</P>"

text = ConvertEncoding(text, encodings.ISOLatin1)

If attribText.initWithHTML(text) Then
MsgBox attribText.text
End If

documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

With plugin version 9.4 this uses the system function to parse html. The old plugin function is available with the name initWithHTMLOld.

On Mac OS X 10.6 the text encoding expected is ISO Latin 1 as far as I see.

See also:

NSAttributedStringMBS.initWithHTML(data as MemoryBlock, BaseURL as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes the object with html code from a given url.
Example
Var n as NSAttributedStringMBS
n=new NSAttributedStringMBS
if n.initWithHTML("<b>test</b>","http://www.apple.com") then
MsgBox n.text
else
MsgBox "failed"
end if

Returns true on success.
documentAttributes: Optional dictionary to receive the attributes.

See also:

NSAttributedStringMBS.initWithHTML(data as memoryblock, byref documentAttributes as dictionary) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of given HTML file data.

Returns true on success.
documentAttributes: Optional dictionary to receive the attributes.

With plugin version 9.4 this uses the system function to parse html. The old plugin function is available with the name initWithHTMLOld.

On Mac OS X 10.6 the text encoding expected is ISO Latin 1 as far as I see.

See also:

NSAttributedStringMBS.initWithHTML(data as memoryblock, options as Dictionary, byref documentAttributes as dictionary) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 22.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of given HTML file data.
Example
Var theBody As String = "<html><body>Test äöü</body></html>"

Var documentAttributes As Dictionary
Var documentOptions As New Dictionary

// define the text encoding
Const NSUTF8StringEncoding = 4
documentOptions.Value(NSAttributedStringMBS.NSCharacterEncodingDocumentOption) = NSUTF8StringEncoding
// and a default base URL for finding images
documentOptions.Value(NSAttributedStringMBS.NSBaseURLDocumentOption) = NSURLMBS.URLWithString("https://monkeybreadsoftware.de/")
// and a timeout for network queries
documentOptions.Value(NSAttributedStringMBS.NSTimeoutDocumentOption) = 30

Var BodyAttributed As New NSAttributedStringMBS
If BodyAttributed.initWithHTML(theBody, documentOptions, documentAttributes) Then
MessageBox BodyAttributed.Text
Else
Break // failed?
End If

Returns true on success.
options: Put in some options for parsing the document like NSCharacterEncodingDocumentOption or NSTextEncodingNameDocumentOption.
documentAttributes: Optional dictionary to receive the attributes.

See also:

NSAttributedStringMBS.initWithHTMLOld(data as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 9.4 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of given HTML file data.

With plugin version 9.4 the initWithHTML method uses the system function to parse html. The old plugin function is available with the name initWithHTMLOld.

NSAttributedStringMBS.initWithPath(file as folderitem) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 9.4 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of file at the given file.

documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

NSAttributedStringMBS.initWithPath(file as folderitem, byref documentAttributes as dictionary) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of file at the given file.

documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

NSAttributedStringMBS.initWithPath(path as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 9.4 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of file at the given path string.

documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

NSAttributedStringMBS.initWithPath(path as string, byref documentAttributes as dictionary) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of file at the given path string.

documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

NSAttributedStringMBS.initWithRTF(data as MemoryBlock) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of given RTF file data.

documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

Some examples using this method:

NSAttributedStringMBS.initWithRTF(data as memoryblock, byref documentAttributes as dictionary) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of given RTF file data.

documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

NSAttributedStringMBS.initWithRTFD(data as MemoryBlock) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of given RTFD file data.

documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

NSAttributedStringMBS.initWithRTFD(data as memoryblock, byref documentAttributes as dictionary) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of given RTFD file data.

documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

NSAttributedStringMBS.initWithString(text as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of given plain text.
Example
Var n as NSAttributedStringMBS
n=new NSAttributedStringMBS
if n.initWithHTML("test") then
MsgBox n.text
else
MsgBox "failed"
end if

documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

NSAttributedStringMBS.initWithString(text as string, withAttributes as Dictionary) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of given plain text.
Example
Var n as NSAttributedStringMBS
n=new NSAttributedStringMBS
if n.initWithHTML("test") then
MsgBox n.text
else
MsgBox "failed"
end if

documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

NSAttributedStringMBS.initWithURL(file as folderitem) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of file at the given file.
Example
Var n as NSAttributedStringMBS
n=new NSAttributedStringMBS
if n.initWithURL(SpecialFolder.Desktop.Child("testfile")) then
MsgBox n.text
else
MsgBox "failed"
end if

documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

NSAttributedStringMBS.initWithURL(file as folderitem, byref documentAttributes as dictionary) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of file at the given file.
Example
Var n as NSAttributedStringMBS
Var documentAttributes as dictionary
n=new NSAttributedStringMBS
if n.initWithURL(SpecialFolder.Desktop.Child("testfile"), documentAttributes) then
MsgBox n.text
else
MsgBox "failed"
end if

documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

NSAttributedStringMBS.initWithURL(url as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of file at the given url.

documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

NSAttributedStringMBS.initWithURL(url as string, byref documentAttributes as dictionary) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes string with content of file at the given url.

documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

NSAttributedStringMBS.isEqualToAttributedString(other as NSAttributedStringMBS) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Compares both strings.
Example
Var n as NSAttributedStringMBS
Var m as NSAttributedStringMBS

n=new NSAttributedStringMBS
if n.initWithString("test") then
MsgBox n.text
else
MsgBox "failed"
end if

m=new NSAttributedStringMBS
if m.initWithString("test") then
MsgBox n.text
else
MsgBox "failed"
end if

if m.isEqualToAttributedString(n) then
MsgBox "Ok"
else
MsgBox "failed"
end if

m=new NSAttributedStringMBS
if m.initWithString("test2") then
MsgBox n.text
else
MsgBox "failed"
end if

if m.isEqualToAttributedString(n) then
MsgBox "failed"
else
MsgBox "Ok"
end if

Returns true if they are equal in content.

NSAttributedStringMBS.itemNumberInTextList(list as NSTextListMBS, location as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 18.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the index of the item at the given location within the list.

list: The text list.
location: The location of the item.

Returns the index within the list.

The items on this page are in the following plugins: MBS MacBase Plugin.


The biggest plugin in space...