Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Classic ASP Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

The Chilkat StringArray object

The Chilkat string array object is a utility class used by many of the Chilkat components. It's not an array. It's an object that contains 0 or more strings that can be retrieved by index. The reason Chilkat created this object is that string arrays are handled differently in different programming languages. The CkStringArray object (or Chilkat.StringArray in .NET) is used whenever a collection of strings is passed to a method, or returned from a method. This example demonstrates some very basic usage. How to create a string array, populate it with some entries, sort it, retrieve entries, etc.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
'  This is not an array -- it's an object.
set sa = Server.CreateObject("Chilkat_9_5_0.CkStringArray")

'  Append some strings.
sa.Append "abc"
sa.Append "Abc"
sa.Append "123"
sa.Append "Chilkat Software, Inc."

'  How many strings?

n = sa.Count
Response.Write Server.HtmlEncode(n) & "<br>"

'  Iterate over the strings contained in the object:

For i = 0 To n - 1
    Response.Write Server.HtmlEncode(sa.GetString(i)) & "<br>"
Next

'  Sort in ascending order:

ascending = 1
sa.Sort ascending

Response.Write Server.HtmlEncode("Sorted:") & "<br>"
For i = 0 To n - 1
    Response.Write Server.HtmlEncode(sa.GetString(i)) & "<br>"
Next

'  Save to a file (one string per line).
'  Line endings are controlled by the Crlf property.
useCrlf = 1
sa.Crlf = useCrlf
sa.SaveToFile "strings.txt"

'  Clear the string array.
sa.Clear 

'  Load the string array from a file.  Each line in the
'  file becomes a string contained in the object:
sa.LoadFromFile "strings.txt"

'  Remove a string by exact match:
sa.Remove "abc"

'  Remove a string by index (1st string is at index 0):
sa.RemoveAt 2

'  The Trim property can be set to automatically trim whitespace
'  from the beginning and end of any string added to the object:
sa.Trim = 1

'  Append some strings from a comma-separated list:
sa.SplitAndAppend "apple, orange, banana, pear, lime",","

'  What do we have now?
Response.Write Server.HtmlEncode("-------- After SplitAndAppend:") & "<br>"
n = sa.Count
For i = 0 To n - 1
    Response.Write Server.HtmlEncode(sa.GetString(i)) & "<br>"
Next

'  Serialize the complete object to a base64 string:

serialized = sa.Serialize()

Response.Write Server.HtmlEncode("-------- Serialized:") & "<br>"
Response.Write Server.HtmlEncode(serialized) & "<br>"

'  Restore from a serialized string:
set sa2 = Server.CreateObject("Chilkat_9_5_0.CkStringArray")
sa2.AppendSerialized serialized

Response.Write Server.HtmlEncode("-------- After AppendSerialized:") & "<br>"
n = sa2.Count
For i = 0 To n - 1
    Response.Write Server.HtmlEncode(sa2.GetString(i)) & "<br>"
Next

'  Set the Unique property to prevent duplicates from being added:
sa.Unique = 1
sa.Clear 
sa.Append "apple"
sa.Append "banana"
sa.Append "apple"
sa.Append "banana"

'  What do we have now?
Response.Write Server.HtmlEncode("-------- Unique strings:") & "<br>"
n = sa.Count
For i = 0 To n - 1
    Response.Write Server.HtmlEncode(sa.GetString(i)) & "<br>"
Next

'  Find the location of a specific string
'  (case insensitive).

startIndex = 0
index = sa.Find("apple",startIndex)
If (index >= 0) Then
    Response.Write Server.HtmlEncode("found apple at index " _
         & index) & "<br>"
Else
    Response.Write Server.HtmlEncode("apple not found") & "<br>"
End If


%>
</body>
</html>

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.