SDL Passolo Automation SDL Passolo 2018

March 2018 SDL Passolo Automation

SDL Passolo 2018

March 2018 ii SDL Passolo Automation A

Legal notice 0 Legal notice

Copyright and trademark information relating to this product release.

Copyright © 2000–2018 SDL Group.

SDL Group means SDL PLC. and its subsidiaries and affiliates. All intellectual property rights contained herein are the sole and exclusive rights of SDL Group. All references to SDL or SDL Group shall mean SDL PLC. and its subsidiaries and affiliates details of which can be obtained upon written request.

All rights reserved. Unless explicitly stated otherwise, all intellectual property rights including those in copyright in the content of this website and documentation are owned by or controlled for these purposes by SDL Group. Except as otherwise expressly permitted hereunder or in accordance with copyright legislation, the content of this site, and/or the documentation may not be copied, reproduced, republished, downloaded, posted, broadcast or transmitted in any way without the express written permission of SDL.

Passolo is a registered trademark of SDL Group. All other trademarks are the property of their respective owners. The names of other companies and products mentioned herein may be the trademarks of their respective owners. Unless stated to the contrary, no association with any other company or product is intended or should be inferred.

This product may include open source or similar third-party software, details of which can be found by clicking the following link: Acknowledgments on page 0 .

Although SDL Group takes all reasonable measures to provide accurate and comprehensive information about the product, this information is provided as-is and all warranties, conditions or other terms concerning the documentation whether express or implied by statute, common law or otherwise (including those relating to satisfactory quality and fitness for purposes) are excluded to the extent permitted by law.

To the maximum extent permitted by law, SDL Group shall not be liable in contract, tort (including negligence or breach of statutory duty) or otherwise for any loss, injury, claim liability or damage of any kind or arising out of, or in connection with, the use or performance of the Software Documentation even if such losses and/or damages were foreseen, foreseeable or known, for: (a) loss of, damage to or corruption of data, (b) economic loss, (c) loss of actual or anticipated profits, (d) loss of business revenue, (e) loss of anticipated savings, (f) loss of business, (g) loss of opportunity, (h) loss of goodwill, or (i) any indirect, special, incidental or consequential loss or damage howsoever caused.

All Third Party Software is licensed "as is." Licensor makes no warranties, express, implied, statutory or otherwise with respect to the Third Party Software, and expressly disclaims all implied warranties of non-infringement, merchantability and fitness for a particular purpose. In no event will Licensor be liable for any damages, including loss of data, lost profits, cost of cover or other special, incidental, consequential, direct, actual, general or indirect damages arising from the use of the Third Party Software or accompanying materials, however caused and on any theory of liability. This limitation will apply even if Licensor has been advised of the possibility of such damage. The parties acknowledge that this is a reasonable allocation of risk.

Information in this documentation, including any URL and other Internet Web site references, is subject to change without notice. Without limiting the rights under copyright, no part of this may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of SDL Group.

4 SDL Passolo Automation Contents

1 Legal notice ...... 3

2 Acknowledgments ...... 21

3 Passolo Automation Object Model ...... 23

4 About SDL Passolo Automation ...... 25

Scripting and Automation ...... 26

COM - Some background ...... 26

Automation of SDL Passolo ...... 27

Using Macros in Passolo ...... 28

The System Macro ...... 29

Automating other applications from Passolo ...... 29

What's new in SDL Passolo Automation ...... 30

Getting help ...... 30

5 Using SDL Passolo Automation ...... 33

The PassoloApp Object ...... 34

Projects ...... 34

Source lists ...... 35

Translation Lists ...... 36

Languages ...... 36

Example 1 - Changing simulate translation ...... 37

Example 2 - Adding checks ...... 38

Example 3 - Creating a project ...... 39

Example 4 - Integrating the TRADOS Workbench ...... 41

Example 5 - Handling of other file types ...... 42

Example 6 - Automate PASSOLO from ...... 46

6 The Basic Editor ...... 47

Code window ...... 48 Editor assistance features ...... 49 File menu ...... 50 Edit menu ...... 51

SDL Passolo Automation v Sheet menu ...... 55 View menu ...... 55 Macro menu ...... 58 Help menu ...... 59

Object Browser ...... 59

User Dialog Editor ...... 60 Toolbox controls ...... 62

Project references ...... 63

Debugging tools ...... 65 Debug menu ...... 65 Break bar ...... 66 Data Tool Tips ...... 66 Immediate window ...... 66 Watch window ...... 67 Stack window ...... 67 Loaded window ...... 67

7 Basic programming concepts ...... 69

Variables and constants ...... 70 Definitions ...... 70 Data Types, declarations and scope ...... 71 Array declaration ...... 73 Object variables ...... 73 Built-In constants ...... 74

Functions and subroutines ...... 74 Definitions ...... 74 Declarations ...... 75

Controlling program flow ...... 75 GoTo Statement ...... 76 If-Then-Else Statements ...... 76 Select-Case Structure ...... 77 With Statement ...... 78 For-Each Loop ...... 79 For-Next Loop ...... 79 Do-While And Do-Until Loop ...... 80

vi SDL Passolo Automation Error Handling ...... 80

Code optimization ...... 81

8 Reference ...... 83

Object PassoloApp ...... 84 Methods ...... 265 PassoloApp.ConvertASCII2Unicode ...... 84 PassoloApp.ConvertUnicode2ASCII ...... 84 PassoloApp.GetConcordances ...... 85 PassoloApp.GetDefaultCodePage ...... 86 PassoloApp.GetLangCode ...... 87 PassoloApp.GetLangID ...... 88 PassoloApp.GetLastOutput ...... 89 PassoloApp.GetTerminology ...... 89 PassoloApp.GetTextCounts ...... 90 PassoloApp.Import ...... 91 PassoloApp.ImportOptions ...... 91 PassoloApp.Output ...... 92 PassoloApp.Quit ...... 92 PassoloApp.SelectFile ...... 92 PassoloApp.SelectFolder ...... 93 PassoloApp.SendAddInMessage ...... 93 PassoloApp.ShowAppStatus ...... 93 PassoloApp.TranslateText ...... 94 PassoloApp.TransLists ...... 95 Properties ...... 265 PassoloApp.ActiveProject ...... 95 PassoloApp.ActiveSourceDisplay ...... 96 PassoloApp.ActiveSourceList ...... 96 PassoloApp.ActiveTransDisplay ...... 97 PassoloApp.ActiveTransList ...... 97 PassoloApp.Build ...... 98 PassoloApp.DisplayAlerts ...... 98 PassoloApp.FreeExportLicenses ...... 99 PassoloApp.Glossaries ...... 99 PassoloApp.License ...... 99 PassoloApp.Option ...... 100 PassoloApp.OutputWnd ...... 107 PassoloApp.Projects ...... 107 PslProject.Tasks ...... 108 PassoloApp.Unicode ...... 108

SDL Passolo Automation vii PassoloApp.User ...... 108 PassoloApp.Version ...... 109 PassoloApp.Visible ...... 109 Events ...... 109 PassoloApp.AfterAlignTarget ...... 109 PassoloApp.AfterCheckTransList ...... 110 PassoloApp.AfterGenerateTarget ...... 110 PassoloApp.AfterUpdateSourceList ...... 111 PassoloApp.AfterUpdateTransList ...... 111 PassoloApp.BeforeAlignTarget ...... 112 PassoloApp.BeforeCheckTransList ...... 112 PassoloApp.BeforeGenerateTarget ...... 112 PassoloApp.BeforeUpdateSourceList ...... 113 PassoloApp.BeforeUpdateTransList ...... 113 PassoloApp.OnAutoTranslate ...... 114 PassoloApp.OnCheckString ...... 114 PassoloApp.OnCloseProject ...... 115 PassoloApp.OnCloseSourceList ...... 115 PassoloApp.OnCloseTransList ...... 115 PassoloApp.OnEditSourceString ...... 115 PassoloApp.OnEditTransString ...... 115 PassoloApp.OnEndScript ...... 116 PassoloApp.OnFilterSourceString ...... 116 PassoloApp.OnFilterTransString ...... 117 PassoloApp.OnHotkey[n] ...... 117 PassoloApp.OnOpenProject ...... 118 PassoloApp.OnOpenSourceList ...... 118 PassoloApp.OnOpenTransList ...... 118 PassoloApp.OnProcessUserFile ...... 118 PassoloApp.OnSimulateTranslation ...... 119 PassoloApp.OnSizeToContent ...... 119 PassoloApp.OnStartScript ...... 120

Object PslAppStatus ...... 120 Methods ...... 120 PslAppStatus.Step ...... 120 Properties ...... 120 PslAppStatus.Aborted ...... 120 PslAppStatus.ProgressMax ...... 121 PslAppStatus.ProgressMin ...... 121 PslAppStatus.ProgressPos ...... 121 PslAppStatus.Text ...... 121

viii SDL Passolo Automation Object PslGlossaries ...... 121 Methods ...... 265 PslGlossaries.Add ...... 122 PslGlossaries.Item ...... 122 PslGlossaries.Remove ...... 122 Properties ...... 265 PslGlossaries.Application ...... 123 PslGlossaries.Count ...... 123 PslGlossaries.Parent ...... 123

Object PslGlossary ...... 123 Methods ...... 265 PslGlossary.CreateQuickIndex ...... 124 Properties ...... 265 PslGlossary.Application ...... 124 PslGlossary.Disabled ...... 124 PslGlossary.FileName ...... 125 PslGlossary.IsEmbedded ...... 125 PslGlossary.Parent ...... 125 PslGlossary.QuickIndexState ...... 125

Object HistoryItem ...... 126 Methods ...... 265 PslHistoryItem.GetRect ...... 126 Properties ...... 265 PslHistoryItem.Comment ...... 126 PslHistoryItem.Date ...... 127 PslHistoryItem.Property ...... 127 PslHistoryItem.State ...... 128 PslHistoryItem.Text ...... 128 PslHistoryItem.UserName ...... 129

Object HistoryItems ...... 129 Properties ...... 265 PslHistoryItems.Count ...... 130 PslHistoryItems.Item ...... 130

Object PslLanguage ...... 131 Properties ...... 265 PslLanguage.GetStatistics ...... 131 PslLanguage.LangCode ...... 131 PslLanguage.LangID ...... 132 PslLanguage.Option ...... 132

SDL Passolo Automation ix PslLanguage.Project ...... 132 PslSourceList.Properties ...... 133 PslSourceList.Property ...... 133 PslLanguage.StringCount ...... 134 PslLanguage.WordCount ...... 134

Object PslLanguages ...... 135 Methods ...... 265 PslLanguages.Add ...... 135 PslLanguages.AddLangCode ...... 135 PslLanguages.FindLangCode ...... 136 PslLanguages.FindLangID ...... 137 PslLanguages.Item ...... 137 PslLanguages.Remove ...... 138 Properties ...... 265 PslLanguages.Application ...... 138 PslLanguages.Count ...... 138 PslLanguages.Parent ...... 139

Object PslOutputWnd ...... 139 Methods ...... 265 PslOutputWnd.Clear ...... 139 Properties ...... 265 PslOutputWnd.JumpError ...... 140 PslOutputWnd.JumpNumber ...... 140 PslOutputWnd.JumpTarget ...... 141 PslOutputWnd.LineCount ...... 141 PslOutputWnd.Text ...... 142 PslOutputWnd.Type ...... 142

Object PslProject ...... 143 Methods ...... 265 PslProject.AddTargetPathRule ...... 143 PslProject.BaseLanguage ...... 145 PslProject.BaseProject ...... 145 PslProject.Close ...... 145 PslProject.CreateQuickIndex ...... 146 PslProject.Export ...... 146 PslProject.ExportTransBundle ...... 147 PslProject.FindTargetPathRule ...... 148 PslProject.Import ...... 149 PslProject.ImportBinaryResource ...... 150 PslProject.ImportTransBundle ...... 150

x SDL Passolo Automation PslProject.IsTransBundle ...... 151 PslProject.LogMessage ...... 151 PslProject.Maintenance ...... 151 PslProject.PrepareTransBundle ...... 152 PslProject.Properties ...... 152 PslSourceList.Property ...... 153 PslProject.ResumeSaving ...... 153 PslProject.SuspendSaving ...... 154 PslProject.UpdateSourceLists ...... 154 PslProject.UpdateTransLists ...... 154 Properties ...... 265 PslProject.Comment ...... 155 PslProject.DisplayComment ...... 155 PslProject.Glossaries ...... 156 PslProject.Languages ...... 156 PslProject.Location ...... 157 PslProject.Name ...... 157 PslProject.QuickIndexState ...... 157 PslProject.SourceLists ...... 158 PslProject.SynchronizeExports ...... 158 PslProject.Tasks ...... 159 PslProject.TransLists ...... 159 PslProject.UserFiles ...... 159

Object PslProjects ...... 159 Methods ...... 265 PslProjects.Add ...... 160 PslProjects.Close ...... 160 PslProjects.Item ...... 161 PslProjects.Open ...... 161 Properties ...... 265 PslProjects.Application ...... 162 PslProjects.Count ...... 162 PslProjects.Parent ...... 162

Object PslProperties ...... 163 Methods ...... 265 PslProperties.Find ...... 163 PslProperties.RemoveAll ...... 163 Properties ...... 265 PslProperties.Count ...... 164 PslProperties.Name ...... 164

SDL Passolo Automation xi PslProperties.Value ...... 165

Object PslResData ...... 165 Methods ...... 265 PslResData.AddFileExtension ...... 166 PslResData.AddLanguage ...... 166 PslResData.GetEntryData ...... 166 PslResData.ListResource ...... 168 PslResData.ProcessEntry ...... 168 PslResData.ProcessResource ...... 169 PslResData.SetEntryData ...... 169 Properties ...... 265 PslResData.Action ...... 170 PslResData.Error ...... 170 PslResData.SourceLanguage ...... 171 PslResData.SourceFile ...... 171 PslResData.SourceCodePage ...... 171 PslResData.TargetCodePage ...... 171 PslResData.TargetFile ...... 172 PslResData.TargetLanguage ...... 172

Object PslResource ...... 172 Methods ...... 265 PslResource.AutoLayout ...... 172 PslResource.ChangeID ...... 173 PslResource.ExportBinary ...... 173 PslResource.ImportBinary ...... 174 PslResource.OpenResourceEditor ...... 174 Properties ...... 265 PslResource.Attribute ...... 174 PslResource.FirstStringIndex ...... 175 PslResource.ID ...... 175 PslResource.IDName ...... 175 PslResource.IsBinary ...... 176 PslResource.Number ...... 176 PslResource.State ...... 176 PslResource.StringCount ...... 177 PslResource.Type ...... 177

Object PslResourceEditor ...... 177 Methods ...... 265 PslResourceEditor.FlipLayout ...... 177 PslResourceEditor.ResetLayout ...... 178

xii SDL Passolo Automation Object PslSourceDisplay ...... 178 Methods ...... 265 PslSourceDisplay.String ...... 178 PslSourceDisplay.StringCount ...... 179

Object PslSourceList ...... 179 Methods ...... 265 PslSourceList.Close ...... 179 PslSourceList.Open ...... 180 PslSourceList.Save ...... 180 PslSourceList.SetTargetPathRule ...... 180 PslSourceList.Update ...... 181 PslSourceList.UnExport ...... 182 Properties ...... 265 PslSourceList.IsOpen ...... 182 PslSourceList.ExtLang ...... 182 PslSourceList.ExportDate ...... 183 PslSourceList.ExportFile ...... 183 PslSourceList.ExtLangCount ...... 183 PslSourceList.Extract ...... 184 PslSourceList.FileDate ...... 185 PslSourceList.FindID ...... 185 PslSourceList.LangID ...... 186 PslSourceList.LastChange ...... 186 PslSourceList.LastUpdate ...... 186 PslSourceList.Leverage ...... 187 PslSourceList.ListID ...... 187 PslSourceList.Option ...... 187 PslSourceList.Parser ...... 187 PslSourceList.Properties ...... 188 PslSourceList.Property ...... 188 PslSourceList.Resource ...... 189 PslSourceList.ResourceCount ...... 190 PslSourceList.Project ...... 190 PslSourceLists.Remove ...... 190 PslSourceList.Selected ...... 191 PslSourceList.Size ...... 191 PslSourceList.SourceFile ...... 191 PslSourceList.State ...... 192 PslSourceList.String ...... 192 PslSourceList.StringCount ...... 193 PslSourceList.Title ...... 194

SDL Passolo Automation xiii PslSourceList.WordCount ...... 194

Object PslSourceLists ...... 194 Methods ...... 265 PslSourceLists.Add ...... 194 PslSourceLists.AddWithParser ...... 195 Properties ...... 265 PslSourceLists.Application ...... 195 PslSourceLists.Count ...... 196 PslSourceLists.Item ...... 196 PslSourceLists.Parent ...... 196

Object PslSourceString ...... 197 Methods ...... 265 PslSourceString.ChangeID ...... 197 PslSourceString.GetOldRect ...... 197 PslSourceString.GetRect ...... 198 PslSourceString.GetTextCounts ...... 198 Properties ...... 265 PslSourceString.Attribute ...... 199 PslSourceString.Comment ...... 199 PslSourceString.DateChanged ...... 199 PslSourceString.DateCreated ...... 199 PslSourceString.Description ...... 200 PslSourceString.ID ...... 200 PslSourceString.IDName ...... 201 PslSourceString.Number ...... 201 PslSourceString.OldText ...... 201 PslSourceString.OutputError ...... 201 PslSourceString.ParserComment ...... 202 PslSourceString.Properties ...... 202 PslSourceString.Property ...... 202 PslSourceString.Resource ...... 203 PslSourceString.ResType ...... 203 PslSourceString.SourceList ...... 204 PslSourceString.State ...... 204 PslSourceString.Text ...... 205 PslSourceString.Type ...... 205

Object PslStatistics ...... 205 Methods ...... 264 Properties ...... 265 PslStatistics.AutoTranslated ...... 205

xiv SDL Passolo Automation PslStatistics.Fuzzy95_99 ...... 206 PslStatistics.Fuzzy85_94 ...... 206 Psl.Statistics.Fuzzy75_84 ...... 206 Psl.Statistics.Fuzzy30_74 ...... 207 PslStatistics.PreTranslated ...... 207 PslStatistics.Repeats ...... 207 PslStatistics.ToReview ...... 207 PslStatistics.Total ...... 208 PslStatistics.ToTranslate ...... 208 PslStatistics.Translatable ...... 208 PslStatistics.Translated ...... 208 PslStatistics.Translation ...... 209

Object PslStringCounter ...... 209 Methods ...... 264 Properties ...... 265 PslStringCounter.CharCount ...... 209 PslStringCounter.LetterCount ...... 210 PslStringCounter.StringCount ...... 211 PslStringCounter.WordCount ...... 211

Object PslTask ...... 212 Methods ...... 264 Properties ...... 265 PslTask.Application ...... 212 PslTask.Comment ...... 212 PslTask.Done ...... 213 PslTask.DueDate ...... 213 PslTask.Link ...... 213 PslTask.Number ...... 213

Object PslTasks ...... 214 Methods ...... 265 PslTasks.Add ...... 214 PslTasks.Delete ...... 214 Properties ...... 265 PslTasks.Application ...... 215 PslTasks.Count ...... 215 PslTasks.Item ...... 215

Object PslTransBundle ...... 215 Methods ...... 265 PslTransBundle.AddAllProjectUserFiles ...... 216

SDL Passolo Automation xv PslTransBundle.AddGlossary ...... 216 PslTransBundle.AddMacro ...... 216 PslTransBundle.AddOptions ...... 216 PslTransBundle.AddTransList ...... 217 PslTransBundle.AddUserFile ...... 217 PslTransBundle.License ...... 217 PslTransBundle.MarkAsExported ...... 218 PslTransBundle.RemoveRight ...... 218 PslTransBundle.SetComment ...... 218 PslTransBundle.SetRefLanguage ...... 219 PslTransBundle.SplitBundle ...... 219

Object PslTransDisplay ...... 220 Methods ...... 264 Properties ...... 265 PslTransDisplay.String ...... 220 PslTransDisplay.StringCount ...... 221

Object PslTranslation ...... 221 Methods ...... 264 Properties ...... 265 PslTranslation.Match ...... 221 PslTranslation.Origin ...... 222 PslTranslation.SourceString ...... 222 PslTranslation.TransString ...... 222

Object PslTranslations ...... 222 Methods ...... 265 PslTranslations.Add ...... 222 PslTranslations.Item ...... 223 PslTranslations.Remove ...... 223 Properties ...... 265 PslTranslations.Application ...... 224 PslTranslations.Count ...... 224 PslTranslations.Parent ...... 224 PslTranslations.SourceLangID ...... 225 PslTranslations.SourceString ...... 225 PslTranslations.StringType ...... 225 PslTranslations.TargetLangID ...... 225

Object PslTransList ...... 225 Methods ...... 265 PslTransList.AutoTranslate ...... 226

xvi SDL Passolo Automation PslTransList.Check ...... 227 PslTransList.Close ...... 227 PslTransList.CreateSimulation ...... 227 PslTransList.DecorateText ...... 228 PslTransList.Delete ...... 228 PslTransList.Export ...... 229 PslTransList.FindID ...... 229 PslTransList.GenerateTarget ...... 230 PslTransList.GetConcordances ...... 230 PslTransList.GetStatistics ...... 231 PslTransList.GetTerminology ...... 232 PslTransList.Import ...... 233 PslTransList.Leverage ...... 233 PslTransList.Open ...... 233 PslTransList.Save ...... 234 PslTransList.ScanTargetFile ...... 234 PslTransList.SetTargetPathRule ...... 235 PslTransList.SimulateTranslation ...... 235 PslTransList.TranslateText ...... 236 PslTransList.UndecorateText ...... 237 PslTransList.Update ...... 237 PslTransList.UnDelete ...... 237 PslTransList.UnExport ...... 238 Properties ...... 265 PslTransList.ExportDate ...... 238 PslTransList.ExportFile ...... 238 PslTransList.FileDate ...... 238 PslTransList.IsDeleted ...... 239 PslTransList.IsOpen ...... 239 PslTransList.IsSimulation ...... 239 PslTransList.Language ...... 239 PslTransList.LastChange ...... 240 PslTransList.LastGeneration ...... 240 PslTransList.LastUpdate ...... 240 PslTransList.ListID ...... 241 PslTransList.Parser ...... 241 PslTransList.Properties ...... 242 PslTransList.Property ...... 242 PslTransList.Resource ...... 243 PslSourceList.ResourceCount ...... 243 PslTransList.Project ...... 244 PslTransList.Selected ...... 244

SDL Passolo Automation xvii PslTransList.Simulation ...... 244 PslTransList.Size ...... 245 PslTransList.SourceList ...... 245 PslTransList.State ...... 245 PslTransList.String ...... 245 PslTransList.StringCount ...... 246 PslTransList.TargetFile ...... 247 PslTransList.Title ...... 248 PslTransList.TransRate ...... 248 PslTransList.WordCount ...... 248

Object PslTransLists ...... 249 Methods ...... 265 PslTransLists.Add ...... 249 PslTransLists.Application ...... 249 PslTransLists.Count ...... 249 PslTransLists.Item ...... 250 PslTransLists.Open ...... 250 PslTransLists.Parent ...... 251

Object PslTransString ...... 251 Methods ...... 265 PslTransString.GetRect ...... 251 PslTransString.GetSourceRect ...... 251 PassoloApp.GetSourceTextCounts ...... 252 PslTransString.GetTextCounts ...... 252 PslStatistics.Total ...... 253 PslTransString.History ...... 253 PslTransString.OutputError ...... 253 PslTransString.Properties ...... 254 PslTransString.SetRect ...... 254 Properties ...... 265 PslTransString.Attribute ...... 254 PslTransString.Comment ...... 255 PslTransString.DateChanged ...... 255 PslTransString.DateCreated ...... 255 PslTransString.DateTranslated ...... 255 PslTransString.Description ...... 256 PslTransString.GetContentSize ...... 256 PslTransString.IDName ...... 257 PslTransString.ID ...... 257 PslTransString.Number ...... 257 PslTransString.OldText ...... 258

xviiiSDL Passolo Automation PslTransString.Origin ...... 258 PslTransString.ParserComment ...... 258 PslTransString.Property ...... 258 PslTransString.Resource ...... 259 PslTransString.ResType ...... 260 PslTransString.SourceProperties ...... 260 PslTransString.SourceProperty ...... 261 PslTransString.SourceText ...... 261 PslTransString.State ...... 261 PslTransString.Text ...... 262 PslTransString.TransComment ...... 263 PslTransString.TransList ...... 263 PslTransString.Type ...... 263 PslTransString.User ...... 264

Object PslUserFile ...... 264 Methods ...... 264 Properties ...... 265 PslUserFile.Name ...... 264

Object PslUserFiles ...... 265 Methods ...... 265 PslUserFiles.Add ...... 265 PslUserFiles.Extract ...... 265 Properties ...... 265 PslUserFiles.Application ...... 266 PslUserFiles.Count ...... 266 PslUserFiles.Item ...... 266

9 Appendix ...... 267

SDL Passolo Automation xix xx SDL Passolo Automation A

Acknowledgments 0 Acknowledgments

SDL Passolo includes open source or similar third-party software. Apache log4net The Apache log4net library is a tool to help the programmer output log statements to a variety of output targets. log4net is a port of the Apache log4j™ framework to the Microsoft® .NET runtime. BCGControlBar Pro for MFC BCGControlBar ("Business Components Gallery ControlBar") is an MFC extension library that allows you to create Microsoft Office 2000/XP/2003/2007/2010/2013 and -like applications with full customization options. Google Translation API Google Translate API provides a simple programmatic interface for translating an arbitrary string into any supported language. Json.NET Json.NET is a popular high-performance JSON framework for .NET. Mono.Celcil Cecil enables you to load existing managed assemblies, browse all the contained types, modify them on the fly and save back to the disk the modified assembly. Nalpeiron The Patented (8,843,745) Nalpeiron Licensing & Analytics Service is a hosted product that enables you to control your applications and understand your Customers usage with flexible and easy to implement Software License Management. SQLite SQLite is an in-process library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. WinWrap Basic WinWrap® Basic is a .NET/WPF/COM component which is an alternative to ActiveX, VBScript, VB6, VBA, Sax Basic and VSTA scripting. WinWrap provides advanced end-user scripting and automation. XCEED .NET FTP library XCEED offers efficient FTP and FTPS (FTP over SSL) file transfer to .NET or ASP.NET apps. DotNetZip DotNetZip is a class library and toolset for manipulating zip files. Use VB, C# or any .NET language to easily create, extract, or update zip files. ZipArchive library C++ library that adds ZIP compression functionality to software.

22 SDL Passolo Automation B

Passolo Automation Object Model 0 Passolo Automation Object Model

SDL Passolo uses an Automation Object to automate repeating tasks and to change or to extend functions. The automation object can be used within the scripting engine of Passolo or from any other automation client like Visual Basic or JScript.

Installation

The Professional Edition and the Team Edition register this object:

• PASSOLO 8 Object The Translator edition registers this object:

• PASSOLO 8 Translator Object The Demo version does not support automation.

ӍAboutUsingReference SDL SDL Passolo Passolo Automation AutomationӍӍ

24 SDL Passolo Automation C

About SDL Passolo Automation 0 About SDL Passolo Automation

Scripting and Automation

Scripting and Automation are powerful concepts to customize applications and integrate applications so that they work together like one single application.

Automation makes it possible to control SDL Passolo from other applications like workflow management systems.

Scripting means that you can write your own macros within Passolo to extend or customize the functionality of Passolo.

One macro can be defined as the system macro. This macro is active all the time and depending on actions performed in Passolo call back functions will be called in the system macro. Using the system macro the functionality of Passolo can be changed and the user even will not notice it.

As it is possible to automate Passolo from other applications, the powerful scripting engine allows it to integrate other application into Passolo seamlessly. COM - Some background

Using Sax Basic effectively requires that you should have a understanding of COM, component based computing and the Passolo Object Model. COM (the ) is a binary standard for interfacing and interoperation of (possibly, separately-developed) components. More and more, everything Microsoft offers is COM-compliant.

COM is based on the principle of separation between interface and implementation. Microsoft defines standard, public interfaces, and several implementations of an interface can be provided. Any correct implementation (server) of an interface, and any correct client thereof, will interoperate transparently, regardless of such issues as programming languages being used.

A normal COM interface is just a binary table of entry points (addresses) of procedures that are called to invoke an object's functionality (methods) and get (and possibly set) the values of its properties. Such interfaces are often called either standard or custom. The standard ones are those that are published and released by Microsoft as part of some interoperation protocol while all the others, developed either by Microsoft or by other firms as part of the specification of particular applications or controls, are the custom ones.

COM allows extremely fast and compact implementation. When residing in the same process, a COM server and its client talk to each other (on a standard or custom interface) with direct procedure calls. All of Microsoft's languages, integrated into Visual Studio (VC++, VJ++, VB), support COM, as do many 3rd-party languages (Delphi, Perl, C++Builder, PowerBuilder, Microfocus COBOL, etc).

Automation is the COM way to guarantee interoperation with interpreted languages, which may intrinsically need to bind with an object at runtime. Performance will be slower than with custom interfaces, due to the interpretive access and perhaps to the need for types used in the interface to be constrained to Automation-compatible ones. Probably the most widespread is Microsoft Visual Basic for Applications (VBA). Sax Basic, the scripting language of SDL Passolo is nearly identical and compatible.

26 SDL Passolo Automation About SDL Passolo Automation 0

Automation of SDL Passolo

You can automate SDL Passolo from any programming language that is able to connect to automation servers. Using automation, Passolo can be integrated into workflow management systems. Nearly every operation which is normally performed by a user can be automated without human interaction.

To open a project from a Microsoft Visual Basic application and perform some operations you only have to:

• Create a new Visual Basic project • From the menu Project choose References and check SDL Passolo 2016 Object Library • Add a button to the form • Double-click on the button and enter the following code for the callback handler subroutine:

Private Sub Command1_Click() Dim PSL As PassoloApp Set PSL = CreateObject("Passolo.Application") ' Open the project PSL.Projects.Open ("c:\samples\notepad.lpu") ' Update stringlists PSL.ActiveProject.SourceLists(1).Update PSL.ActiveProject.TransLists(1).Update ' Autotranslate PSL.ActiveProject.TransLists(1).AutoTranslate ' Generate targetfile and quit PSL.ActiveProject.TransLists(1).GenerateTarget PSL.Quit pslSaveChanges End Sub

SDL Passolo Versions

Different versions of Passolo use different application object names. "Passolo.Application" uses the Passolo version that has been installed last. If you're using different Passolo versions side by side, your must use a versioned object name to address the correct version.

Version Versioned Object Name uuid SDL Passolo 2018 Passolo.Application.18 {6F87400A-242D-46D0-96C7- 678F85D9C349} SDL Passolo 2016 Passolo.Application.16 {A2023D96-FCF6-437B-8CDC- 84946B256DDD} SDL Passolo 2015 Passolo.Application.15 {6F0A6A19-F203-463E-8702- CE795A5BE307} SDL Passolo 2011 Passolo.Application.11 {56004006-4162-47d6-B694- 2EDFFBAAEB9F} SDL Passolo 2009 Passolo.Application.8 {AEF5F6AE-7307-4cbb-B613- 71C65D60250E}

SDL Passolo Automation 27 0 About SDL Passolo Automation

Version Versioned Object Name uuid PASSOLO 2007 Passolo.Application.7 {8B2C6424-4792-412d-8918- 1E72E7BA3D3D} PASSOLO 6 Passolo.Application.6 {DE3E6479-853B-4d31-83C7- E9A5B7DB4724} PASSOLO 5 Unicode Passolo.UnicodeApplication.5 {A065C728-58DE-409b-A6A6- 946CF78421A2} PASSOLO 5 ASCII Passolo.Application.5 {3F3AA3C3-54E6-4ead-AEA1- DB3F2C88857D} PASSOLO 4 Unicode Passolo.UnicodeApplication.4 {AD38F5F7-706C-42c8-83B2- 1086FD8575C5} PASSOLO 4 ASCII Passolo.Application.4 {FB9D4356-FEA2-4cba-AC24- 957CF897AC65}

Note: If you automate Passolo from an external application, the internal scripting engine will be disabled and the system macro will not run.

Using Macros in Passolo

Instead of using an external programming development tool, you can also use the scripting engine embedded in SDL Passolo. The scripting engine is VBA compatible and includes an editor and a debugger.

Macros are managed in the dialog Macros (menu Tools / Macros). You can edit or run existing macros and you can create new macros. Also you can assign a shortcut to a macro so that you can execute macros in Passolo at any time by just pressing the shortcut.

When a macro will be executed the subroutine main will be called and Passolo will wait until the subroutine is finished.

An instance of the PassoloApp object is available at any time when a macro is running and can be accessed using the object variable PSL. So the previous sample code will also work in a macro. Only the declaration and creation of PassoloApp has to be deleted:

Sub Main 'Open the project PSL.Projects.Open ("c:\ddata\demo\notepad\notepad2.lpj") ' Update stringlists PSL.ActiveProject.SourceLists(1).Update PSL.ActiveProject.TransLists(1).Update ' Autotranslate PSL.ActiveProject.TransLists(1).AutoTranslate ' Generate targetfile and quit PSL.ActiveProject.TransLists(1).GenerateTarget End Sub

ӍAutomation of SDL Passolo

28 SDL Passolo Automation About SDL Passolo Automation 0

The System Macro

In the dialog Macro you can select one of the available macros as the system macro. When you start the system macro with the command Tools / System Macro / Start System Macro this macro will be active all the time. When you work with SDL Passolo some of the actions you perform will issue events. If the related call back handlers are defined in the system macro, these events can be processed.

Enter the following code to your system macro to display a message box pops every time you press 8.

Public Sub PSL_OnHotkey8() MsgBox("You have pressed 8!") End Sub

Please refer to the documentation of the class PassoloApp to get more information about the call back handlers that can be implemented.

You can also implement call back handlers if you automate Passolo from Visual Basic. In this case you must declare the PassoloApp object as Dim WithEvents psl As PassoloApp.

If you automate Passolo from an external application, the internal scripting engine will be disabled and theObject system PassoloApp macro will not run. Ӎ Automating other applications from Passolo

In order to use another application in a SDL Passolo macro, you should add a reference to the object.

Open the dialog References by selecting the menu Edit followed by References.

To use for example Microsoft Excel, select the Microsoft Excel Object Library. If you use objects of the Microsoft Excel Object Library in the script you will get context sensitive help about the available proper- ties, methods and parameters.

The following macro demonstrates how to open Excel, create a workbook and add data from a translation list to the sheet.

Sub Main ' Get a translation list Dim trn As PslTransList Set trn = PSL.Projects(1).TransLists(1) If trn Is Nothing Then Exit Sub ' Open Excel and create a workbook Dim ex As Excel.Application Set ex = CreateObject("Excel.Application") Dim wb As Excel.Workbook Set wb = ex.Workbooks.Add ' Add soure strings, translated string anddescriptions Dim i As Long For i = 1 To trn.StringCount With wb.ActiveSheet .Range("a" & CStr(i)) = trn.String(i).SourceText .Range("b" & CStr(i)) = trn.String(i).Text

SDL Passolo Automation 29 0 About SDL Passolo Automation

.Range("c" & CStr(i)) = trn.String(i).Description End With Next i ex.Visible =True MsgBox("Click to close Excel") ex.Quit End Sub

What's new in SDL Passolo Automation

This page contains the latest changes made to SDL Passolo Automation.

Changes in SDL Passolo Automation 2016

• Changed the following methids for IPslProject interface: • from VARIANT_BOOL UpdateSourceLists(); to VARIANT_BOOL UpdateSourceLists([optional] VARIANT ReportPath); • from VARIANT_BOOL UpdateTransLists(); to VARIANT_BOOL UpdateTransLists([optional] VARIANT ReportPath);

Changes in SDL Passolo Automation 2015

• Added the BSTR Origin; property to the IPslTransString interface: • Added several new languages/dialects codes to PslLanguageID enum. Getting help

After having understood the basic principle of the object model, all you have to do is obtain some information about the names of all the objects and what properties and methods they have.

There are in principle three different ways of obtaining this information:

SDL Passolo Object Reference

The Passolo Object Reference contains a complete list of all SDL Passolo objects, their attributes, methods and call backs. Short examples demonstrate the use of methods and attributes.

30 SDL Passolo Automation About SDL Passolo Automation 0

Online documentation for the PASSOLO object model and SAX Basic

Whenever you have typed a SAX Basic keyword or a Passolo object, method or attribute in a module, you can place the cursor in the keyword and press F1. This should bring you to help on that keyword. Try the word "PassoloApp".The help screen should give you an option to list all the methods and properties of the object.

The Object browser

The SAX Basic Editor has a built-in tool for locating objects and properties - The Object Browser. This object browser is built much like your file browser in Windows. You may not find much use for the object browser at first, but when you get more comfortable with SAX Basic you find that it can be a useful tool. The Object Browser allows you to find information by stepping through a hierarchy. Try searching for a few words like PSLTransString or PassoloApp. The Object Browser allows you to explore PASSOLO's object library. The Object Browser can be selected by clicking the Object Browser button in the Sax Basic Editor toolbar. The Object Browser consists of two lists:

• Data Types which contains the object types • Methods/Properties which contains the methods and properties The right side of the Object Browser will display information on the selected object.

ӍReference

SDL Passolo Automation 31 0 About SDL Passolo Automation

32 SDL Passolo Automation D

Using SDL Passolo Automation 0 Using SDL Passolo Automation

The PassoloApp Object

The mother object in SDL Passolo is the object PassoloApp. This is a direct reference to the Passolo program itself. It provides some helper functions and gives you access to all other Passolo objects. For a complete description of all objects and attributes refer to the chapter Passolo Object Model Reference.

Within the Sax Basic Engine you access the PassoloApp object via the predefined PSL object. There is no need to declare or create the object. Just type "PSL".

If you automating Passolo from another scripting engine like Visual Basic you need to create an Passo- loApp object. It's recommended that you name this object "PSL".That makes it easier to reuse parts of the script in the Sax Basic Engine.

PassoloApp is the only object which exposes events to the system macro. Use the system macro to defineObjectReferenceAutomationThe System event PassoloAppӍ Macro of handlers, SDLӍ Passolo whichӍ extend the functionality of Passolo. Ӎ Projects

The collection PslProjects contains all projects that are opened in SDL Passolo. You access this collection with PassoloApp.Projects.

This example lists all open projects:

Sub Main Dim i As Integer For i = 1 To PSL.Projects.Count Dim prj As PslProject Set prj = PSL.Projects(i) PSL.Output prj.Name Next i End Sub

Because PslProjects is a collection, this code can be easier written as:

Dim prj As PslProject For Each prj In PSL.Projects PSL.Outputprj.Name Next prj

The current project, i.e. the project from the active window, can be accessed with PassoloApp.ActiveProject.

34 SDL Passolo Automation Using SDL Passolo Automation 0

Opening existing projects

To open an existing project use the method PslProjects.Open:

PSL.Projects.Open("c:\MyProjects\MyProject.lpj")

Remember, that the unicode version of Passolo uses the extension .lpu.

Creating new projects

To create a new project, use the method PslProjects.Add. With PslSourceLists.Add and PslLanguages.Add you set your source files and target languages.

Dim prj As PslProject Set prj = PSL.Projects.Add("Test","c:\MyProjects") prj.SourceLists.Add("c:\MyApplication.exe") prj.Languages.Add("deu")

A detailed example to create projects you find in Example 3.

ExamplePslLanguages.AddPslProjects.OpenPslProjects.AddPslSourceLists.AddPassoloApp.ProjectsӍObjectPslProjects 3 - CreatingӍ ӍӍӍӍ Ӎ a project Source lists

The collection PslSourceLists contains the source lists of a project. Your access this collection with PassoloApp.SourceLists.

This example lists all source lists of the current project:

Sub Main Dim prj As PslProject Set prj = PSL.ActiveProject If prj Is Nothing Then Exit Sub Dim i As Integer For i = 1 To prj.SourceLists.Count Dim src As PslSourceList Set src = prj.SourceLists(i) PSL.Output src.Title Next i End Sub

Because PslSourcesLists is a collection, the loop can be easier written as:

Dim src As PslSourceList For Each src In prj.SourceLists PSL.Output src.Title Next src

Note: The "for each" loop does not release the object after each loop. To prevent excessive memory consumption in large projects you should use the method from the first example.

SDL Passolo Automation 35 0 Using SDL Passolo Automation

The current source list, i.e. the source list from the active window or the source list that is selected in the project window, can be accessed with PassoloApp.ActiveSourceList. Translation Lists

The collection PslTransLists contains the translation lists of a project. Your access this collection with PslProject.TransLists.

This example lists all translation lists of the current project:

Sub Main Dim prj As PslProject Set prj = PSL.ActiveProject If prj Is Nothing Then Exit Sub Dim i As Integer For i = 1 To prj.TransLists.Count Dim trn As PslTransList Set trn = prj.TransLists(i) PSL.Output trn.SourceList.Title & " - " & trn.Language.LangCode Next i End Sub

Because PslTransLists is a collection, the loop can be easier written as:

Dim trn As PslSourceList For Each trn In prj.TransLists PSL.Output trn.SourceList.Title & " - " & trn.Language.LangCode Next trn

Note: The "for each" loop does not release the object after each loop. To prevent excessive memory consumption in large projects you should use the method from the first example.

The current source list, i.e. the translation list from the active window or the translation list that is selectedPslProject.TransListsPassoloApp.ActiveTransList in the projectӍ window, can be accessed with PassoloApp.ActiveTransList. Ӎ Languages

The collection PslLanguages contains the target languages of a project. Your access this collection with PassoloApp.Languages.

This example lists all target languages of the current project:

Sub Main Dim prj As PslProject Set prj = PSL.ActiveProject If prj Is Nothing Then Exit Sub Dim i As Integer For i = 1 To prj.Languages.Count Dim lang As PslLanguage Set lang = prj.Languages(i) PSL.Output lang.LangCode Next i

36 SDL Passolo Automation Using SDL Passolo Automation 0

End Sub

Because PslLanuages is a collection, the loop can be easier written as:

Dim lang As PslLanguage For Each lang In prj.Languages PSL.Output lang.LangCode Next lang

ӍObjectPslProject.Languages PslLanguages Ӎ Example 1 - Changing simulate translation

This example shows how you can change the way SDL Passolo generates a simulated translation of a source file by implementing a call back handler in the system macro.

To do this you have to implement a call back handler PSL_OnSimulateTranslation, which is called for every string that needs to be translated for the simulation. The macro could look like this:

0001 ' We want to check if Asian characters are processed correctly 0002 Public Sub PSL_OnSimulateTranslation(SrcStr As PslSourceString, _ 0003 Text As String, X As Long, Y As Long, _ 0004 Cx As Long, Cy As Long, Handled As Boolean) 0005 0006 Handled = True ' Yes we handle simulation 0007 0008 If SrcStr.Type = "DialogFont" Then 0009 Text = "Arial Unicode MS" 'If font, choose a Unicode font 0010 Else 0011 Text = "[" & SrcStr.Text & ChrW(20442) & "]" ' Add chars 0012 End If 0013 End Sub

Line 6 tells Passolo, that the simulation is handled by the call back handler. If Handled is not set to True, the internal simulation will be used.

The automation interface of Passolo exposes nearly all information to the client and there are only very limited checks or restrictions. Line 8 checks what kind of string will be processed and we don't want to translate the dialog font. Instead a dialog font should be used that is able to display Japanese characters.

Line 11 generates the translated string. Apart from the text also the coordinates of dialog Controls can be changed during simulation.

How to use it

Select PslSimTrans as the system macro in the dialog Macro and active the system macro with the command Tools / System Macro / Start System Macro. Select a translation list and select from the menu String List and then Simulate Translation.

SDL Passolo Automation 37 0 Using SDL Passolo Automation

Example 2 - Adding checks

This example demonstrates the use of external components (Microsoft VBScript Regular Expressions) and the use of regular expression.

Although SDL Passolo has build-in checks for C-format specifiers like %d %s we want to show how this feature could be implemented with a system macro.

If format specifiers are used in the texts, the order of the format specifiers must not be changed in the translation, otherwise data will be displayed wrong or the software might even crash. To add this additional check you have to implement the call back handler PSL_OnCheckString.

0001 Public Sub PSL_OnCheckString(Ctl As PslTransString) 0002 Dim i As Integer 0003 Dim srccoll As MatchCollection 0004 Dim trgcoll As MatchCollection 0005 Dim regexpr As RegExp 0006 Dim srcstring As String 0007 Dim trgstring As String 0008 0009 ' If we dont have to deal with string list 0010 If Ctl.ResType <> "StringTable" Then Exit Sub 0011 0012 ' No C-format specifiers 0013 If InStr(Ctl.SourceText, "%") = 0 And _ 0014 InStr(Ctl.Text, "%") = 0 Then Exit Sub 0015 0016 Set regexpr = New RegExp 0017 regexpr.Pattern = _ 0018 "([^%]|^)%-?\d*\.?\d*(ld|lo|lx|d|o|x|h|c|s|f|n)" 0019 regexpr.IgnoreCase = True 0020 regexpr.Global=True 0021 Set srccoll = regexpr.Execute(Ctl.SourceText) 0022 Set trgcoll = regexpr.Execute(Ctl.Text) 0023 0024 If srccoll.Count <> trgcoll.Count Then 0025 Ctl.OutputError _ 0026 "Different number of format specifiers" 0027 Exit Sub 0028 End If 0029 0030 For i = 0 To srccoll.Count - 1 0031 srcstring = srccoll.Item(i) 0032 trgstring = trgcoll.Item(i) 0033 0034 If Left(srcstring,1) <> "%" Then 0035 srcstring = Mid(srcstring, 2) 0036 End If 0037 0038 If Left(trgstring,1) <> "%" Then 0039 trgstring = Mid(trgstring,2) 0040 End If 0041 0042 If srcstring <> trgstring Then 0043 Ctl.OutputError _ 0044 CStr(i + 1) + ". Format specifier different" 0045 Exit Sub 0046 End If 0047 Next 0048 End Sub

We use a RegExp object to deal with regular expressions (Lines 3 to 5). This object is not part of the SAX Basic Runtime Library. So we need to add a reference to that component. The topic Project References

38 SDL Passolo Automation Using SDL Passolo Automation 0

describes how to do this. Choose Microsoft VBScript Regular Expressions 5.5 which is the component we need.

Line 17/18 sets the regular expression which describes the layout of the C-format specifiers. Using this expression we extract in line 21 and 22 collections of strings from both the source and target string that fits this pattern.

If the number of strings is different in the source or target collection an error message will be generated in line 25. The member function OuputError writes the message to the output window together with information about the translation string object itself. In Passolo you can use F4 to jump to the translation string as you can do it also with errors or warning generated by the Passolo itself.

In the For loop the C-format specifiers are checked one by one to see if the order is the same for both source and target string.

How to use it

Select PslCheckCPP as the system macro in the dialog Macro and active the system macro with the command Tools / System Macro / Start System Macro. Open a translation list and select Translation / Check all Translations. If the string list contains texts that violate the check, you should get error messages like in the following example:

ӍProjectPslTransString.OutputError references Ӎ Example 3 - Creating a project

This examples demonstrates the use of macros that can be invoked by pressing a shortcut and the use of dialogs in macros.

Suppose you want to create a project which should contain all executable files of a specified directory. This can be done easily with a macro.

From line 2 to line 14 a dialog is defined. You can use the dialog editor in the SAX Basic editor to create dialogs. Open the dialog editor with the menu command Edit / UserDialog. For the user dialog a dialog handler function will be generated automatically, see line 46 to 89. By adding some code, we allow the user to select directories for the SDL Passolo project and the source files.

The code for setting up the project and adding the source files is straight forward. In line 20 a new project is added to PassoloApp. From lines 30 to 35 files with the extension will be added to the project and in the lines 38 to 43 files with the extension dll will be added to the project.

How to use it

Select PslAutoProjectFromFolder and assign it to the shortcut ++F5. If you press the shortcut the following dialog comes up.

Enter a name and a directory path for the project. Select the directory of the source files and press OK and let the macro create the project.

SDL Passolo Automation 39 0 Using SDL Passolo Automation

0001 Sub Main 0002 Begin Dialog UserDialog 540,161,"Bulk Project", _ 0003 .BulkProject ' %GRID:10,7,1,1 0004 Text 10,14,130,14,"Name of the Project:",.Text1 0005 Text 10,42,200,14,"Directory for Project:",.Text2 0006 Text 10,70,170,14,"Directory with files:",.Text3 0007 TextBox 220,7,270,21,.Project 0008 TextBox 220,35,270,21,.PSLDir 0009 TextBox 220,63,270,21,.SourceDir 0010 PushButton 500,35,30,21,"...",.GetPSLDir 0011 PushButton 500,63,30,21,"...",.GetSourceDir 0012 OKButton 430,105,90,21 0013 CancelButton 430,133,90,21 0014 End Dialog 0015 Dim dlg As UserDialog 0016 If Dialog(dlg) = 0 Then Exit Sub 0017 0018 ' Create PASSOLO project 0019 Dim prj As PslProject 0020 Set prj = PSL.Projects.Add(dlg.Project, dlg.PSLDir) 0021 0022 If prj Is Nothing Then 0023 MsgBox ("Failed to add project") 0024 Exit Sub 0025 End If 0026 0027 ' Go to source directory and scan all exes 0028 ChDir(dlg.SourceDir) 0029 Dim file As String 0030 file = Dir$("*.exe") 0031 While file <> "" 0032 prj.SourceLists.Add(dlg.SourceDir & "\" & file, _ 0033 file, pslLangEnglishUSA) 0034 file = Dir$() 0035 Wend 0036 0037 ' same for DLLs 0038 file = Dir$("*.dll") 0039 While file <> "" 0040 prj.SourceLists.Add(dlg.SourceDir & "\" & file, _ 0041 file, pslLangEnglishUSA) 0042 file = Dir$() 0043 Wend 0044 End Sub 0045 0046 Private Function BulkProject(DlgItem$,Action%,SuppValue&) _ 0047 As Boolean 0048 Dim folder As String 0049 0050 ' We only want to check button clicks 0051 If Action% <> 2 Then Exit Function 0052 0053 ' Let user select project directory 0054 If DlgItem$ = "GetPSLDir" Then 0055 If PSL.SelectFolder(folder, _ 0056 "Select Directory for Project") Then 0057 DlgText "PSLDir", folder 0058 End If 0059 BulkProject = True 0060 End If 0061 0062 ' Let user select source directory 0063 If DlgItem$ = "GetSourceDir" Then 0064 If PSL.SelectFolder(folder, _ 0065 "Select Directory of Files") Then 0066 DlgText "SourceDir", folder 0067 End If 0068 BulkProject = True

40 SDL Passolo Automation Using SDL Passolo Automation 0

0069 End If 0070 0071 ' Only OK if user has enter all data 0072 If DlgItem$ = "OK" Then 0073 If DlgText("SourceDir") = "" Then 0074 MsgBox("Please select directory of files") 0075 BulkProject = True 0076 Exit Function 0077 End If 0078 If DlgText("PSLDir") = "" Then 0079 MsgBox("Please select directory for project") 0080 BulkProject = True 0081 Exit Function 0082 End If 0083 If DlgText("SourceDir") = "" Then 0084 MsgBox("Please enter project name") 0085 BulkProject = True 0086 Exit Function 0087 End If 0088 End If 0089 End Function

Example 4 - Integrating the TRADOS Workbench

It is possible to get translations for texts also from other applications. This example demonstrates how the TRADOS Workbench can be used for automatic translation.

0001 Option Explicit 0002 0003 Dim TW3App As TW4Win.Application 0004 Dim TW3Mem As TW4Win.TranslationMemory 0005 0006 Public Sub PSL_OnAutoTranslate(Translations As PslTranslations, _ 0007 ByVal MinMatch As Long, ByVal MaxCount As Long) 0008 Dim TUnit As TranslationUnit, i As Integer 0009 0010 If TW3Mem Is Nothing Then Exit Sub 0011 0012 TW3Mem.Search (Translations.SourceString) 0013 Set TUnit = TW3Mem.TranslationUnit 0014 0015 For i = 1 To TW3Mem.HitCount 0016 Translations.Add(TUnit.Target, TUnit.Source, TUnit.Score, "TW") 0017 TUnit.Next 0018 Next i 0019 End Sub 0020 0021 Public Sub PSL_OnStartScript() 0022 Set TW3App = CreateObject("TW4Win.Application") 0023 0024 If TW3App Is Nothing Then 0025 MsgBox("Can't open the TRADOS Workbench") 0026 Exit Sub 0027 End If 0028 0029 Set TW3Mem = TW3App.TranslationMemory 0030 TW3Mem.Open("c:\ddata\demo\trados\psldemoed.tmw", "User") 0031 End Sub

SDL Passolo Automation 41 0 Using SDL Passolo Automation

To start the TRADOS Workbench takes quite a while, so it make sense to start the Workbench directly when the macro is started (lines 21 to 31). The Workbench application object and translation memory object are global (lines 3 and 4) and will exist until the system macro is stopped or SDL Passolo is closed.

Note: In order to use the TRADOS Workbench you must add a reference to TRADOS Translator's Work- bench Type Library.

If the user presses F8 in the editor windows of SDL Passolo the call back handler PSL_OnAutoTranslate will be called. Translations.SourceString contains the string that needs to get translated. In line 12 the text will be looked up in the translation memory. The translations returned from the translation memory will be added to the collection of translations in lines 15 to 18.

How to use it

Select PslTrados as the system macro in the dialog Macro and active the system macro with the command Tools / System Macro / Start System Macro.

Open a translation list and double click a text that you want to translate. In the editor window press F8. The result could look like this:

ӍProjectPassoloApp.OnAutoTranslatePslTranslations.SourceString references Ӎ Ӎ Example 5 - Handling of other file types

This examples demonstrate how to write handler that is able to parse and generate INI files.

The handler to be implemented is PSL_OnProcessUserFile. The parameter is used to establish the communication between SDL Passolo and the handler.

The handler is called for several purposes and rd.Action indicates why Passolo calls the handler:

pslResUpdGetFileExtensionsPassolo wants to know the filestypes which the handler supports. In this case the handler calls rd.AddFileExtension with each filetype/file extension it supports (lines 126 to 129). pslResUpdScanData and Passolo wants to scan a source file or generate the target file. In this case pslResUpdGenerate rd.SourceFile contains the name of the source file and rd.TargetFile contains the name of the target file. In Passolo resource string are entries in resources, like dialog controls in a dialog. For an ini file each section can be defined as a resource and the keys can be defined as resource entries. Before you can add resource string to a string list, the parent resource must be defined by calling rd.ProcessResource (line 40). To add an entry to a string list, you must call rd.SetEntryData with the parameter pslResUpdId and the id of the entry. With a second call to rd.SetEntryData with the parameter pslResUpdText you must set the text of the entry. And finally you must call rd.ProcessEntry so that Passolo processes the resource entry (lines 46 to 48). In case of PslResUpdGenerate the translated version of the entry text is available after the call to rd.ProcessEntry. Call rd.GetEntryData with the parameter pslResUpdText to get the translated text to generate the target file (line 51 to 54).

42 SDL Passolo Automation Using SDL Passolo Automation 0

pslResUpdGetFileExtensionsPassolo wants to know the filestypes which the handler supports. In this case the handler calls rd.AddFileExtension with each filetype/file extension it supports (lines 126 to 129). pslResUpdListContent Passolo wants to know which resources in which languages are contained in the source file. In this case the handler calls rd.ListResource for each resource in each language found in the source file. The first parameter is the resource type, the second parameter is the resource name and the third parameter is the language. If the language can not be determined it is recommended to use 0 as the neutral language (line 83). pslResUpdCheckSourceTargetPassolo wants to know if the source file can be processed by the handler and the target file is valid. If the source file can not be processed by the handler or the source file does not exist, the handler should set rd.Error to a non-zero value (line 90 to 115). In the case of ini files it is not useful to use the source file also as the target file. This case is handled in the lines 104 to 107. pslResUpdGetLanguages Passolo wants to know which source languages are contained in the source file. rd.AddLanguage must be called for each language found in the source file. If the source language can not be determined, it is recommended to call rd.AddLanguage(0) so that Passolo uses the neutral language for the source file. In case that the source file contains more than one language the handler must only process data with the requested source language when scanning the source file or generating the target file. Use ResData. SourceLanguage to determine the source language and if you need to know the target language read the attribute ResData.TargetLanguage.

How to use it

Select PslIniScan as the system macro in the dialog Macro and active the system macro with the command Tools / System Macro / Start System Macro. If you want to add a new source file, you should now be able to filter only ini files in the file selector box. If you have selected a ini file you will be able to see the ini sections in the Info dialog (which can be opened in the properties dialog of the source list). And finally you should be able to work with ini files as you would do it with other supported files types:

0001 ' If INI-section, return section name otherwise emtpy string 0002 Function GetHeader(ln As String) As String 0003 If Left(ln,1) <> "[" Or Right(ln, 1) <> "]" Then Exit Function 0004 0005 GetHeader = Mid(ln, 2, Len(ln) - 2) 0006 End Function 0007 0008 ' Get Position of "=" if not found or comment return 0 0009 Function GetDataPos(ln As String) As Long 0010 GetDataPos = 0 0011 ' Comment? 0012 If Left(ln,1) = ";" Then Exit Function 0013 0014 GetDataPos = InStr(ln, "=") 0015 End Function 0016 0017 ' Update translation list and generate target file 0018 Function IniUpdate(rd As PslResData) As Long 0019 Dim fso As Scripting.FileSystemObject 0020 Dim tsi As Scripting.TextStream

SDL Passolo Automation 43 0 Using SDL Passolo Automation

0021 Dim tso As Scripting.TextStream 0022 Dim s As String, header As String, i As Integer 0023 0024 Set fso = New Scripting.FileSystemObject 0025 Set tsi = fso.OpenTextFile(rd.SourceFile) 0026 0027 ' Generating target file 0028 If rd.Action = pslResUpdGenerate Then 0029 Set tso = fso.CreateTextFile(rd.TargetFile) 0030 End If 0031 0032 IniUpdate = 0 0033 0034 On Error GoTo ende 0035 While True 0036 s = tsi.ReadLine 0037 ' Handle new section header 0038 If GetHeader(s) <> "" Then 0039 header = GetHeader(s) 0040 rd.ProcessResource "INI-Section", header 0041 Else 0042 ' Only if section header is there and line contains data 0043 If header <> "" Then 0044 i = GetDataPos(s) 0045 If i <> 0 Then 0046 rd.SetEntryData(pslResUpdId, Left(s, i - 1)) 0047 rd.SetEntryData(pslResUpdText, Mid(s, i + 1)) 0048 rd.SetEntryData(pslResUpdCtrl, "") 0049 rd.ProcessEntry 0050 ' Generate changed line 0051 If rd.Action = pslResUpdGenerate Then 0052 s = Left(s, i - 1) & "=" & _ 0053 rd.GetEntryData(pslResUpdText) 0054 End If 0055 End If 0056 End If 0057 End If 0058 0059 ' Write data to target file 0060 If rd.Action = 1 Then 0061 tso.WriteLine(s) 0062 End If 0063 Wend 0064 ende: 0065 End Function 0066 0067 Function IniListContent(rd As PslResData) As Long 0068 Dim fso As Scripting.FileSystemObject 0069 Dim tsi As Scripting.TextStream 0070 Dim s As String, header As String 0071 0072 Set fso = New Scripting.FileSystemObject 0073 Set tsi = fso.OpenTextFile(rd.SourceFile) 0074 0075 IniListContent = 0 0076 On Error GoTo ende 0077 0078 ' Add all sections 0079 While True 0080 s = tsi.ReadLine 0081 header = GetHeader(s) 0082 If header <> "" Then 0083 rd.ListResource "INI-Section", header, 0 0084 End If 0085 Wend 0086 ende: 0087 End Function 0088

44 SDL Passolo Automation Using SDL Passolo Automation 0

0089 0090 Function IniCheckFiles(rd As PslResData) As Long 0091 Dim fso As Scripting.FileSystemObject 0092 Dim ts As Scripting.TextStream 0093 Dim s As String 0094 Set fso = New Scripting.FileSystemObject 0095 0096 ' No INI file 0097 If UCase(Right(rd.SourceFile, 3)) <> "INI" Then GoTo failure 0098 0099 ' File does not exists 0100 On Error GoTo failure 0101 Set ts = fso.OpenTextFile(rd.SourceFile) 0102 0103 ' target file, should not be the same as source file 0104 If rd.TargetFile <> "" Then 0105 If UCase(rd.SourceFile) = UCase(rd.TargetFile) Then _ 0106 GoTo failure 0107 End If 0108 0109 IniCheckFiles = 0 0110 Exit Function 0111 0112 failure: 0113 IniCheckFiles = 1 0114 0115 End Function 0116 0117 Function IniGetLanguages(rd As PslResData) As Long 0118 ' Only Language neutral 0119 IniGetLanguages = 0 0120 rd.AddLanguage(0) 0121 End Function 0122 0123 Public Sub PSL_OnProcessUserFile(rd As PslResData) 0124 rd.Error = 0 0125 0126 If rd.Action = pslResUpdGetFileExtensions Then 0127 rd.AddFileExtension("INI Files (*.ini)", "*.ini") 0128 Exit Sub 0129 End If 0130 0131 ' No Ini file 0132 If UCase(Right(rd.SourceFile, 3)) <> "INI" Then Exit Sub 0133 0134 Select Case rd.Action 0135 Case pslResUpdGenerate 0136 rd.Error = IniUpdate(rd) 0137 Case pslResUpdScanData 0138 rd.Error = IniUpdate(rd) 0139 Case pslResUpdListContent 0140 rd.Error = IniListContent(rd) 0141 Case pslResUpdCheckSourceTarget 0142 rd.Error = IniCheckFiles(rd) 0143 Case pslResUpdGetLanguages 0144 rd.Error = IniGetLanguages(rd) 0145 Case Else 0146 rd.Error = 1 0147 End Select 0148 End Sub

ӍPassoloApp.OnProcessUserFile

SDL Passolo Automation 45 0 Using SDL Passolo Automation

Example 6 - Automate PASSOLO from Visual Basic

This example demonstrates how you can automate SDL Passolo from another application. A Visual Basic application is used to create a temporary project with notepad.exe as a source file. A sheet in Excel will be opened and all source strings will be copied to the Excel sheet. Passolo will be closed and the temporary project will be deleted.

0001 Private Sub Command1_Click() 0002 Dim psl As PassoloApp 0003 Dim pslprj As PslProject 0004 Dim srclst As PslSourceList 0005 0006 Set psl = CreateObject("PASSOLO.Application") 0007 Set pslprj = psl.Projects.Add("Scratch", "c:\temp\scratch") 0008 Set srclst = pslprj.SourceLists.Add("c:\winnt\system32\notepad.exe", "Notepad") 0009 srclst.Update 0010 0011 Dim x As Excel.Application 0012 Dim wb As Excel.Workbook 0013 Dim ws As Excel.Worksheet 0014 Set x = New Excel.Application 0015 Set wb = x.Workbooks.Add() 0016 Set ws = x.ActiveSheet 0017 0018 Dim i As Long 0019 For i = 1 To srclst.StringCount 0020 ws.Range("a" & CStr(i)).Select 0021 x.ActiveCell.FormulaR1C1 = srclst.String(i).Text 0022 Next i 0023 x.Visible = True 0024 0025 psl.Quit 0026 Dim fs As FileSystemObject 0027 Set fs = CreateObject("Scripting.FileSystemObject") 0028 fs.DeleteFile ("c:\temp\scratch\scratch.tok\logfile.txt") 0029 fs.DeleteFile ("c:\temp\scratch\scratch.tok\notepad.bin") 0030 fs.DeleteFile ("c:\temp\scratch\scratch.lpj") 0031 fs.DeleteFolder ("c:\temp\scratch\scratch.tok") 0032 fs.DeleteFolder ("c:\temp\scratch") 0033 End Sub

46 SDL Passolo Automation E

The Basic Editor 0 The Basic Editor

SDL Passolo comes with a built in programming environment. The Sax Basic Editor is an interactive design environment for developing, testing and executing Sax Basic scripts.

In this section we will browse through the main features of this IDE. We will not be able to cover all of them, but we will return to them when it seems appropriate.

The Sax Basic Editor makes it possible for you to create, modify, and debug code behind the Passolo application. This integrated development environment exists outside the PASSOLO application window, making it possible for developers to write code in Basic and simultaneously view the results of the programming in the Passolo application. Although the Basic editor exists outside the application window, it runs in the same memory space as its host, thereby benefits from the tight integration of event handling, as well as enhanced performance.

The Sax Basic Editor also provides the following features:

• Enhanced editor with syntax checking and color-coded syntax. • Debugging tools to help track program execution and find bugs. • Object browser for browsing and searching for properties and methods across object model libraries. • Editor assistance features for instant syntax reference and object model assistance to reduce programming time.

The easiest way to enter Sax Basic Editor from Passolo is pressing the shortcut key ALT+F11. You can also enter it from the Tools menu, via Macros or Open Basic IDE.

When the Passolo application window is closed, the Sax Basic Editor is automatically closed if it had been showing.

The development tools can be accessed through the Sax Basic Editor, including the object browser, code windows, user dialog editor, and the debugger.

Below a few features often used in the Sax Basic Editor are listed:

• A macro can easily be executed from the editor, when you have made changes and want to observe the effect. This is done by placing the cursor somewhere within the code of the macro you want to execute and then press F5. • Help on a specific command or keyword in Sax Basic can be found by placing the pointer over the keyword an pressing F1. • The Object Browser can be activated by clicking on the browser icon or via the context menu. • Cut, copy, paste and general text navigation works as in normal word processors. Code window

Use the Code window to write, display, and edit Basic code. You can open as many Code windows as you have modules, so you can easily view the code in different modules, and copy and paste between them.

48 SDL Passolo Automation The Basic Editor 0

Object Box

Displays the name of the selected object. Click the arrow to the right of the list box to display a list of all objects associated with the current module.

Procedures/Events Box

Lists all the events recognized by Sax Basic for an object displayed in the Object box. When you select an event, the proper event procedure definition associated with that event name is inserted or displayed in the Code window. If "(General)" is displayed in the Object box, the Procedure box lists any declarations and all of the general procedures that have been created for the module. If you are editing module code, the Proce- dure box lists all of the general procedures in the module. In either case, the procedure you select in the Procedure box is displayed in the Code window. All the procedures in a module appear in a single, scrollable list that is sorted alphabetically by name. Selecting a procedure using the drop down list boxes at the top of the Code window moves the cursor to the first line of code in the procedure you select.

Sheet Tabs

An enumerated register tab is displayed on the left side of the Code window. Every macro or module has its own sheet tab.

• Clicking once on a tab makes that macro or module the current sheet. • Double-clicking closes that sheet. Editor assistance features

The Sax Basic Editor brings intelligent assistance technology to the developer, providing on-the-fly syntax and programming assistance and reference. The developer can access them on demand through the Edit menu in the Sax Basic editor or with keystroke combinations. The following features are available in the Code window or the Immediate window.

Complete Word

This Auto-completion function uses the object browser information to show the current object's methods and properties. To see language extensions, built-in instructions, functions, constants and user-defined procedures/variables press CTRL+SPACE on a blank line in the IDE. It also can be used to complete the word that is being typed, when enough letters are entered to make it unique or the appropriate word is selected from the list.

SDL Passolo Automation 49 0 The Basic Editor

Parameter Info

When a procedure or a method name is entered followed by a space or an opening parenthesis, a tip automatically appears under the line of code writing. The tip gives syntax information about the procedure. This function can also be invoked with the keystroke CTRL+I.

List Properties and Methods

Displays a pop-up menu listing the properties and methods available for the object that precedes the period. This function can also be invoked with the keystroke CTRL+J.

File menu

The File menu provides the normal operations on macros and modules.

New

or CTRL+N creates a new macro.

New Module

This function creates a new macro module (code, object or class).

Open...

or CTRL+O loads an existing macro or module from disk.

Close

This function closes the current macro or module.

Save

or CTRL+S saves the current macro or module to disk.

Save As...

This function saves the current macro or module to disk as a particular file.

50 SDL Passolo Automation The Basic Editor 0

Save All

saves all the macros or modules to disk.

Print

or CTRL+P prints the current macro or module.

Print Setup...

This function selects the default printer.

Exit

Exit Sax Basic Editor and returns to the SDL Passolo application.

Edit menu

The Edit menu provides the normal operations on editing macros and modules.

Undo

or CTRL+Z or CTRL+BACKSPACE reverses the last editing action, such as typing text in the Code window.

Redo

or CTRL+Y restores the last text editing if no other actions have occurred since the last Undo.

Note: These commands are unavailable at runtime, or if there was no previous edit, or if any other action has been performed after the last edit. Also, some large edits may cause low memory conditions that could prevent an Undo action.

Cut

or CTRL+X or SHIFT+DELETE removes the selected text and places it on the Clipboard. You must select at least one character for this command to be available. You can undo the Cut command.

SDL Passolo Automation 51 0 The Basic Editor

Copy

or CTRL+C or Ctrl+INSERT copies the selected text onto the Clipboard. You must select at least one character for this command to be available. You cannot undo the Copy command in the Code window.

Paste

or CTRL+V or Shift+INSERT inserts the contents of the Clipboard at the current location. Text is placed at the insertion point. You can undo the Paste command in the Code window.

Delete

Deletes the currently selected text, or expression in the Watch window or Immediate window. You can undo the Delete command in all windows. This function can also be invoked with the keystroke DEL.

Select All

Selects all of the code in the active Code window.

Indent

Shifts all lines in the selection to the next tab stop. If you place the cursor anywhere in a line and choose the Indent command, only the text a the cursor position is shifted to the next tab stop. All lines in the selection are moved the same number of spaces to retain the same relative indentation within the selected block. This function can also be invoked with the keystroke TAB. You can change the tab width with the Tab Width function in the View menu.

Outdent

Shifts all lines in the selection to the previous tab stop. If you place the cursor anywhere in a line and choose the Outdent command, the text at the cursor position is shifted to the next tab stop. All lines in the selection are moved the same number of spaces to retain the same relative indentation within the selected block. This function can also be invoked with the keystroke SHIFT+TAB. You can change the tab width with the Tab Width function in the View menu.

Tab As Spaces

If this option is checked, spaces instead of a tab character will be inserted into the code, when pressing the TAB key.

52 SDL Passolo Automation The Basic Editor 0

Find...

Searches for the specified text in the Code window specified in the Find dialog box. This function can also be invoked with the keystroke CTRL+F.

If a search is successful, the Find dialog box closes and Sax Basic selects the located text. If no match is found, Sax Basic displays a message stating that the text was not found. Direction Sets the direction of the search to Down or Up from the location of the cursor. Match case Finds all occurrences with the exact combination of uppercase and lowercase letters specified in the Find what box. Find Next Finds and selects the next occurrence of the text specified in the Find What box. Cancel Closes the dialog box without performing the search.

Replace...

Searches code in the project for the specified text and replaces it with the new text specified in the Replace dialog box. This function can also be invoked with the keystroke CTRL+R.

Find what Type or insert the information you want to find. If any text is selected or the cursor is on a word when you choose the command, this text is displayed in the Find what box. Replace with Type the text you want to use as the replacement text or paste it from the Clipboard. To delete the text in the Find what box from the document, leave the Replace with box empty. Match case Finds all occurrences with the exact combination of uppercase and lowercase letters specified in the Find what box. Find Next Finds and selects the next occurrence of the text specified in the Find what box. Replace Confirms before replacing the search text with the replacement text. Replace All Replaces all occurrences of the search text with the replacement text without stopping for confirmation.

SDL Passolo Automation 53 0 The Basic Editor

Cancel Closes the dialog box without replacing text.

Again

Finds and selects or replaces the next occurrence of the text specified in the Find What/Replace What box of the Find/Replace dialog box. This function can also be invoked with the keystroke F3.

Complete Word

This function is used to complete the word that is being typed, when enough letters are entered to make it unique or when the appropriate word is selected from the list. This function can also be invoked with the keystroke CTRL+SPACE.

Parameter Info

Shows a popup in the Code window that contains information about the parameters of the initial function or statement. If you have a function or statement that contains functions as its parameters, choosing Parameter Info provides information about the first function. The Quick Info provides information about each embedded function. This function can also be invoked with the keystroke CTRL+I. As you type a parameter it is bold until you type the comma used to delineate it from the next parameter. The Parameter Info, once activated, will not close until:

• All of the required parameters are entered. • The function is ended without using all of the optional parameters. • You press ESC.

UserDialog...

calls the user dialog editor and allows you to create a new form and add it to your macro. (see chapter User Dialog Editor).

References

Displays the References dialog box. (see chapter Project References). This dialog box allows you to add an object library or type library reference to your project. This makes another application's objects available in your code. Once a reference is set, the referenced objects are displayed in the Object Browser. Only available at design time.

54 SDL Passolo Automation The Basic Editor 0

Properties

edits the properties of object modules and class modules, when these module windows are the active sheets.

Sheet menu

The Sheet menu provides the sheet options.

Open Uses

This function opens all the '#Uses modules for the current macro or module into the code window.

Close All

This function closes all the macros or modules.

1...9

This function shows the selected macro or module and can also be invoked with the keystroke CTRL+1... CTRL+9.

View menu

The View menu provides the normal operations on Editor windows and display setting.

Macro

Displays or activates the Code window for a currently selected macro or module. This function can also be invoked with the keystroke CTRL+A.

Immediate

Displays the Immediate window and displays information resulting from debugging statements in your code or from commands typed directly into the window. This function can also be invoked with the keystroke CTRL+G. Use the Immediate window to:

• Test problematic or newly written code. • Query or change the value of a variable while running an application. While execution is halted, assign the variable a new value as you would in code. • Query or change a property value while running an application. • Call procedures as you would in code. • View debugging output while the program is running.

SDL Passolo Automation 55 0 The Basic Editor

Watch

Displays the Watch window and displays the current watch expressions. The Watch window appears automatically if watch expressions are defined in the macro. If the context of the expression isn't in scope when going to break mode, the current value isn't displayed. This function can also be invoked with the keystroke CTRL+W. Stack

Displays the Call Stack window, which lists the procedures that have started but are not completed. Available only in break mode. When Sax Basic is executing the code in a procedure, that procedure is added to a list of active procedure calls. If that procedure then calls another procedure, there are two procedures on the list of active procedure calls. Each time a procedure calls another Sub, Function, or Property procedure, it is added to the list. Each procedure is removed from the list as execution is returned to the calling procedure. This function can also be invoked with the keystroke CTRL+T. Loaded

The debugger provides a list of all the currently active macros and loaded modules. This function shows the Loaded window and can also be invoked with the keystroke CTRL+L. Toolbar

Toggles the toolbar on and off. Status Bar

Toggles the status bar on and off. Edit Buttons

Toggles the edit buttons on and off. If the edit buttons are on, 5 additional icons are displayed in the toolbar. Always Split

Toggles the split of the Code window on and off. If the split is on, the Immediate Window will always be displayed.

56 SDL Passolo Automation The Basic Editor 0

Font...

Use to change the fonts, the font size, and/or the font style you use for text and data fields. Font Lists all the fonts that you have installed for Windows. When the box first appears, the font already in use for the selected element is highlighted. Font Style Lists four additional attributes that you can assign to the font selected:

• Regular: Standard, unmodified style • Bold: Boldface • Italic: Italic • Bold Italic: Bold Italic Size Lists common point sizes for the highlighted font. When the box first appears, the point size for the font already in use for the selected element is highlighted, and the highlighted point size appears in the edit box at the top. You can select directly from the list or type the new point size in the edit box at the top (if you know that you have additional sizes installed for the currently selected printer or if you are using scalable type). Sample Displays a sample of the font you have selected. The sample shows the font, style, size, effects, and color you have specified. You can use this box to preview the results as you experiment with different formatting options. Script Displays a list of available scripts. OK Applies the font changes to the selected report element. Cancel Cancels all font changes and leaves the selected element report unchanged. Tab Width

Sets the tab width, which can range from 1 to 8 spaces; the default is 4 spaces.

SDL Passolo Automation 57 0 The Basic Editor

Object/Proc

Selects the display settings for the Object and Procedures/Events Box within the Code Window. The selectable settings are:

• Neither: None of the boxes are displayed. • Proc only: Only the Procedures/Events Box is displayed. • Both: The Object and Procedures/Events Box are displayed. Macro menu

The Macro menu provides options for starting macros, stopping macros and extending the Basic language.

Run

or F5 runs the macro. (If the macro is not active, start it). This command becomes the Continue command when you are in break mode. It resumes running the current macro.

Pause

or ESC stops execution of a macro or module while it's running and switches to break mode. Any statement being executed when you choose this command is displayed in the Code window within the Break Bar. If the application is waiting for events in the idle loop (no statement is being executed), no statement is highlighted until an event occurs. Some editing changes made in break mode may require you to restart your program for the changes to take effect.

End

terminates the macro or module. This command also clears the Call stack and clears the module level variables. Execution cannot be continued. Design Mode Turns design mode on and off per macro or module. Design mode is the time during which no code from the project is running and events from the host or project will not execute. You can leave design mode by executing a macro or using the Immediate window. This function is used to edit the System macro of SDL Passolo.

58 SDL Passolo Automation The Basic Editor 0

Help menu

The Help menu provides information about the Sax Basic Editor and the Sax Basic language.

Editor Help

Shows the table of contents for the Sax Basic Editor online help file.

Language Help

Show the table of contents for the Sax Basic language online help file. This function can also be invoked with the keystroke SHIFT-F1.

Topic Search

Shows the Sax Basic language help for the keyword under the cursor. This function can also be invoked with the keystroke F1.

About Sax Basic

Displays a dialog box with the version number and a copyright notice about the Sax Basic Editor. Object Browser

The Sax Basic Object Browser lists objects available for use in your project and gives you a quick way to navigate through your code. You can use the Object Browser to explore objects in Sax Basic and other applications, see what methods and properties are available for those objects, and paste code proce- dures into your application.

The Object Browser differentiates between built-in properties, custom properties, methods, event handlers, and user-defined procedures. It indicates globally accessible members. It shows function return types, parameter names and types, and user-defined types and constants. Hyperlink jumps to reference objects make it possible for easy navigation of the object hierarchy.

Library

Displays the currently referenced libraries for the active project. You can add libraries in the References dialog box. ( All Libraries) allows all of the libraries to be displayed at one time.

SDL Passolo Automation 59 0 The Basic Editor

Data Type

Displays all of the available classes in the library or project selected in the Library box. Methods/Properties Displays the elements of the class selected in the Data Type box alphabetically.

Properties

Shows the definition of the member. The properties are shown on the right side of the dialog and contain a jump to the class or library to which the element belongs. Some members have jumps to their parent class. For example, if the text in the properties states that Command1 is declared as a command button type, clicking on command button takes you to the Command Button class.

Paste

Allows you to copy the text from the selected object details to the Code window.

Back

Allows you to go back to the previous selection in the Data Type and Methods/Properties lists. Each time you click it you move back one selection until all of your choices are exhausted.

Follow Value/Follow Result

Allows you to repeat your original selections in the Data Type and Methods/Properties lists each time you click it, until you exhaust the list of selections.

Help

Displays the online Help topic for the item selected in the Data Type and Methods/Properties lists. User Dialog Editor

The User Dialog editor allows you to create dialog boxes in your macro. You draw and view controls on a form. After saving the dialog, the user dialog is described by a Begin Dialog ... End Dialog block in the code of the macro. Changes can be made directly within the Code window. To graphically edit a user dialog place the current selection in a user dialog block and select UserDialog from the menu Edit.

Use the buttons in the Toolbox to draw controls on the form. You can set your controls to align with the grid of your form from the Grid settings dialog box.

Note: Within the User Dialog editor, no Undo command is available.

60 SDL Passolo Automation The Basic Editor 0

Edit Item Properties

or double-clicking a control calls up a small dialog, where the position, the size, the caption and all other special properties of a control can be edited.

Delete

or DEL deletes the currently selected control.

Cut

or CTRL+X or SHIFT+DELETE removes the selected control and places it on the Clipboard. You must select at least one control for this command to be available.

Copy

or CTRL+C or Ctrl+INSERT copies the selected control onto the Clipboard. You must select at least one control for this command to be available.

Paste

or CTRL+V or Shift+INSERT inserts the contents of the Clipboard at the current location. The control is placed at the insertion point.

Move in Front

Moves the selected control up within the description of the user dialog. This causes the control to be painted on top of all other controls, described behind in the dialog block.

Move Behind

Moves the selected control down within the description of the user dialog. This causes the control to be painted behind all other controls, described above in the dialog block.

Select in Front

Selects the previous control item within the description of the user dialog.

Select Behind

Selects the next control item within the description of the user dialog.

SDL Passolo Automation 61 0 The Basic Editor

Set Grid

Selects the next control item within the description of the user dialog.

Save and Exit

Saves the user dialog within a Begin Dialog ... End Dialog block in the code of the macro and returns to the Code window.

Toolbox controls

The toolbox on the left side of the user dialog window displays the standard Sax Basic controls. Select one of the controls and click in the dialog to place the selected control.

Select

Select Objects is the only item in the Toolbox that doesn't draw a control. When you select it, you can only resize or move a control that has already been drawn on a form.

Add Groupbox

Allows you to create a graphical or functional grouping for controls. To group controls, draw the frame first, and then draw controls inside the frame.

Add Text

Allows you to have text that you do not want the user to change, such as a caption under a graphic.

Add TextBox

Holds text that the user can either enter or change.

Add CheckBox

Creates a box that the user can easily choose to indicate if something is true or false, or to display multiple choices when the user can choose more than one.

Add OptionButton

Allows you to display multiple choices from which the user can choose only one.

62 SDL Passolo Automation The Basic Editor 0

Add ComboBox

Allows you to draw a combination list box and text box. The user can either choose an item from the list or enter a value in the text box.

Add ListBox

Use to display a list of items from which the user can choose. The list can be scrolled if it has more items than can be displayed at one time.

Add MultiListBox

Use to display a list of items from which the user can choose multiple items. The list can be scrolled if it has more items than can be displayed at one time.

Add DropListBox

Allows you to draw a combination list box and text box. The user can only choose an item from the list box.

Add Picture

Displays a graphical image from a bitmap, icon, or metafile on your form. Images displayed in an Image control can only be decorative and use fewer resources than a PictureBox.

Add OKButton

Creates an OK button the user can choose to accept entries and changes in the user dialog and to leave the user dialog. Only one OKButton is available.

Add CancelButton

Creates a Cancel button the user can choose to ignore entries and changes in the user dialog and to leave the user dialog. Only one CancelButton is available.

Add PushButton

Creates a button the user can choose to carry out a command. Project references

Project references offer a way to share code among projects. The References dialog box is used to create project references. It appears when you choose the References command from the Edit menu. Open projects available as references appear in the dialog box's list of libraries. To add a reference to a project that is not open, click on the Browse button and locate the file containing the desired project.

SDL Passolo Automation 63 0 The Basic Editor

The References dialog allows you to select another application's objects that you want to be available in your code by setting a reference to that application's object library.

Available References

Lists the references available to your project. After you set a reference to an object library by selecting the check box next to its name, you can find a specific object and its methods and properties in the Object Browser. If you are not using any objects in a referenced library, you should clear the check box for that reference to minimize the number of object references Sax Basic must resolve, thus reducing the time it takes your project to compile. You can't remove a reference for an item that is used in your project. If you remove a reference to an object that your are currently using in your project, you will receive an error the next time you refer to that object. References not in use are listed alphabetically.

Note: You can't remove the Passolo object references, because they are necessary for running SDL Passolo.

Priority Buttons

Moves references up and down on the list. When you refer to an object in code, Sax Basic searches each referenced library selected in the References dialog box in the order the libraries are displayed. If two referenced libraries contain objects with the same name, Sax Basic uses the definition provided by the library listed higher in the Available References box.

Result

Displays the name and path of the reference selected in the Available References box, as well as the language version.

Browse

Displays the Add Reference dialog box so that you can search other directories for and add references to the Available Resources box for the following types:

• Type Libraries(*.olb, *.tlb, *.dll) • Executable Files (*.exe, *.dll) • ActiveX Controls (*.ocx) • All Files (*.*)

64 SDL Passolo Automation The Basic Editor 0

Debugging tools

The Sax Basic Editor includes debugging tools to help developers to identify compile errors, program logic errors, and run-time errors. These tools include an Immediate window, a Watch window, a Stack window, and a Loaded window. Code can be dragged from the editor window into the Immediate and Watch windows to speed up the debugging process.

Debug menu

The Debug menu provides the options for debugging macros and modules.

Step Into

or F8 executes the current line. If the current line is a subroutine or function call, the macro stops on the first line of that subroutine or function. (If the macro is not active, start it.)

Step Over

or SHIFT+F8 executes to the next line. If the current line is a subroutine or function call, the macro executes that subroutine or function completely.

Step Out

or CTRL+F8 steps out of the current subroutine or function call.

Step to Cursor

F7 executes until the line the cursor is on is the current line. (If the macro is not active, start it.)

Toggle Break

or F9 toggles the break point on the current line.

Clear All Breaks

SHIFT+CTRL+F9 clears all break points.

Quick Watch

or SHIFT+F9 shows the value of the expression under the cursor in the Immediate window.

SDL Passolo Automation 65 0 The Basic Editor

Add Watch

CTRL+F9 adds the expression under the cursor in the watch window.

Browse

shows the methods of the expression under the cursor. (see Object Browser)

Set Next

Sets the next statement to be executed. Only statements in the current subroutine/function can be selected.

Show Next

Shows the next statement to be executed.

Break bar

The gray area on the left side of the Code window where some indicators are displayed is the break bar. Lines with a breakpoint are indicated with a red bullet. The break bar also shows which line is next to execute with a yellow arrow.

Clicking on the break bar toggles the break point for that line.

Data Tool Tips

When the debugger is in break mode and the cursor is placed over a variable, the variable's value is displayed in a window similar to a ToolTip.

Immediate window

The Immediate window instantly evaluates any expression or statement in Sax Basic, such as a call to a Sub or Function. It can also be used to assign a variable.

• Type "?expr" to show the value of "expr". • Type "var = expr" to change the value of "var". • Type "Set var = expr" to change the reference of "var". • Type "subname args" to call a subroutine or built-in instruction. • Type "Trace" to toggle trace mode. Trace mode prints each statement in the immediate window when a macro is running.

66 SDL Passolo Automation The Basic Editor 0

Watch window

The Watch window makes it possible to monitor the value of a particular variable or expression. Code may be interrupted when a watch expression's value changes or equals a specified value.

The Watch window lists the variables, functions and expressions that are calculated and displayed.

• Each time execution pauses the value of each line in the window is updated. • The expression to the left of "->" may be edited. • Pressing ENTER updates all the values immediately. • Pressing CTRL-Y deletes the line. Stack window

The debugger provides a list of active procedure calls during the break mode.

• The first line is the current statement. The second line is the one that called the first. And so on. • Clicking on a line brings that macro/module into a sheet and highlights the line in the edit window. Loaded window

The debugger provides a list of all the currently active macros and loaded modules.

• These macros/modules are locked and can only be viewed (not edited). • Clicking on a line brings that macro/module into a sheet and activates the sheet.

SDL Passolo Automation 67 0 The Basic Editor

68 SDL Passolo Automation F

Basic programming concepts 0 Basic programming concepts

All programming languages have common features and concepts that must be understood to master programming. These common features might be a little different in the way they are put to use, but the basic concepts are still the same. This section deals with these basic programming features. Most of the information in this section could have been written for another programming language, but the examples are for Sax Basic, and some details may vary if the information were to be used with another programming language. The information in this section is important. If you do not understand it, you should read it again or find other sources to obtain the same information. Variables and constants

Definitions

Variables are an essential to any programming language. A variable is an identifier (a name) for a storage location (part of the computers memory) which holds a value of some sort. This just means that you can use the name of the variable to reference a value in the computers memory, and you can use the same name to change the value of the variable. Constants are just variables that cannot be changed.

You may choose almost any name for your variables. The rules may differ a little from programming language to programming language, in Sax Basic you must follow these rules:

• The name can consist of letters and numbers, but it must start with a letter. • You cannot use spaces or periods in the name. • Variable names are not case sensitive ("MyVar" is the same as "myvar"). • In general do not include any non-letter or non-number characters. • The name cannot be longer than 256 characters. • You cannot use words already taken up by Basic language. For instance Application. The following shows very basic use of variables:

MyVar1 = 10 MyVar5 = 20 Result = MyVar1 + MyVar5 TextVar = "Variables can contain text"

The variable Result ends with the value 30 and TextVar contains the text within the quotation marks. The variables are really not very useful here but they will be.

70 SDL Passolo Automation Basic programming concepts 0

Data Types, declarations and scope

We have already seen that a variable is a name, that contains a reference to a value. In the above example we also saw that this value does not have to be a number, it could also be some text. This means that the variables have different data types.

Some programming languages require that you declare in advance what type of data a certain variable will contain. This is an optional feature in Sax Basic, but I would recommend that you always declare the data types of your variables. This should be done for a number of reasons:

• It is good programming style to declare variables. • It makes the code easier to read for others. • If you always declare variables, Sax Basic will tell you if you have misspelled a variable. This is the kind of error it takes hours to find. • Your macro will take up less memory. • Your code will run faster. • Sax Basic will check if you are putting the right type of data into the variable. Sax Basic has a variety of built in data types. We will just mention a few of the most widely used here. Look in the help files for a complete list of data types. A table of the most common data types follows:

Data Type Description Range Byte 1-byte binary data 0 to 255 Integer 2-byte integer -32,768 to 32,767 Long 4-byte integer -2,147,483,648 to 2,147,483,647 Single 4-byte floating point number -3.4E38 to -1.4E-451.4E-45 to 3.4E38 Double 8-byte floating point number -1.79E308 to -4.9E-3244.94E-324 to 1.79E308 Currency 8-byte number with fixed 0 to approx 2 billion characters decimal point Variant Date/time, floating-point Jan 1 100 to December 31 number, integer, string or object. 9999,Numeric - same as 16 bytes, plus 1 byte for each doubleString: same as stringAlso character if the value is a string. can contain Null, False Boolean 2 bytes True or False Date 8-byte date/time value Jan 1 100 to December 31 9999 Object 4 bytes Jan 1 100 to December 31 9999 User-defined dependent on definition

To introduce a variable name in your code without any prior declaration of the variable, Sax Basic will automatically assume that this variable is of type Variant. This means that it can contain any type of data and Sax Basic will automatically change the type of the variable when needed. This may sound like a really good idea. You would not have to worry about data types and Sax Basic would do the work for you.

SDL Passolo Automation 71 0 Basic programming concepts

In reality it is a very bad idea. In the beginning of your code, you do some calculations, and the results end up in a variable. You want to use this result in a later calculation, but at this later point, you make a typing error and the name of the variable is misspelled. Sax Basic would think you are introducing a new variable. Such a new variable would not contain any useful value and your macro would fail. Errors like that are very hard to find, and for that reason alone you should always declare your variables. If it is not clear to you why you should declare your variables, you can either just accept or go back and read the above section again.

The declaration of variables is done with the Dim statement. Dim is short for Dimension, dimensioning is another word for declaring. The following shows examples of variable declaration. The declaration must be made before the code where the variable is used.

Dim MyNumber As Integer Dim theFloat As Double Dim theName As String

Once the variable has been declared it can be used in the code, and Sax Basic will give you an error message if you try to put the wrong type of data into your variable. Constants are declared with a Const statement:

Const TranslationRate As Single = 50.3 Const WordCount As Integer = 25

You may wonder what constants are good for when you can't change their values. You might as well hard code the values into the macro. But consider this. You are building a macro to do some analysis on some translation lists.

In the calculations you might use certain constants like error codes. If this value is used many times it is not a good idea to hard code the value. If you want to use the macro for another analysis with another error count, you would have to change the value in a lot of places and you might forget some of them. Using constants also makes your code more readable.

If you don't tell Sax Basic otherwise, it will allow you to implicitly declare variables in your code. This means a new variable name in the code will automatically get the type Variant if it has not been declared. As mentioned this is a bad idea, so to force yourself to declare variables you should include the statement

Option Explicit in the beginning of all modules (before declaring any Sub statements). This only effects new modules. I can highly recommend this setting.

You may already wonder if the variable keep their values even when the macro has ended. Usually they don't. The computer would eventually run out of memory if variables stayed in the memory. Variables are visible to a certain part of the Sax Basic environment. This part of the environment is known as the variables scope. Unless you tell Sax Basic differently the variable will disappear when the Sax Basic interpreter leaves the variable scope. There are in principle 3 different scopes in Sax Basic:

• Procedure • Module

72 SDL Passolo Automation Basic programming concepts 0

• Global Variables with procedure level scope have their declaration within a procedure (a Sub or macro). They disappear when the macro ends. Module level scope variables are declared at the beginning of the module before any macro code. For instance right after the Option Explicit statement. They are visible to all macros in that module, and they will keep their values even after a certain macro has ended. Don't use these unless you absolutely need them, since they take up memory even when the macros have ended. Global or public variables are visible to all modules in the project, and should be declared with a Public statement at the module level:

Public WordCount As integer

You should also use these with caution or not at all.

A special case of procedure level variables is the static variable. They are declared in the procedure (or macro) and keep their value even after the macro has ended, but they are only visible to that procedure:

Sub myMacro() Static WordCounter As integer WordCounter = WordCounter + 1 End Sub

They are useful for keeping track of the number of times a certain macro has been called.

Array declaration

Arrays are declared in a similar way to variables. You use the Private, Public, Dim or Static keywords and use integer values to specify the upper and lower bounds for the array. You use the As keyword to declare the array type.

For example:

Dim WordCounters(15) as Integer Dim Sums(20) as Double

Object variables

Variables with an object data type have their values assigned in a little different way, and they deserve special attention. Object variables are variables containing a reference to a certain object. This could be a project, a translation list etc. The object variable would have the same properties and methods as the object itself, and changing the variable affects the object. To assign an object to an object variable you need to use the Set statement. The following example illustrates the use of object variables. They are also used elsewhere in this document.

Sub ObjTest() Dim trnlst As PslTransList Set trnlst = PSL.ActiveTransList trnlst.String(1).State(pslStateBookmark) = True End Sub

SDL Passolo Automation 73 0 Basic programming concepts

Built-In constants

You are allowed to declare constants yourself as mentioned above, but SDL Passolo and Sax Basic also have a wide range of built-in constants. The purpose of these constants is the same as of the constants you declare yourself.They can be used to make the code easier to read, and they allow certain values to be changed, and the code would still work.

We have already seen an example of these built-in constants in the example with setting a bookmark to a specific text. We saw that the bookmarks of the translation list could be set with the following statement:

trnlst.String(1).State(pslStateBookmark) = True

In this case pslStateBookmark is a built-in constant in Passolo. It really holds a value. If you want to know the value of a built in constant try the following sub:

Sub ShowValue() MsgBox(Str$(pslStateBookmark)) End Sub

Running this sub should illustrate that pslStateBookmark really holds the value 8. Other built-in constants hold other values. This means, that we could also have set the bookmark with the macro:

trnlst.String(1).State(8) = True

The other version of the subroutine is much easier to read, and the built-in constants should always be preferred over hard coding the numbers. Functions and subroutines

The concepts of functions and subroutines have already been mentioned, but not properly defined. In principle all of the mentioned terms cover the same concept, but just to make things clear we will define them.

Definitions

A function is a general term used in programming. A function is a structure that requires some sort of data and based on this data, it performs a series of operations and finally returns a value. We know functions from software like Microsoft Excel. For instance the Average function takes a series of numbers (or ranges of numbers) as its arguments (we call the data needed by the function arguments) and returns the average of these values.

Some functions need several arguments, others can work without arguments, but usually they return one value and one value only. There are examples of functions that don't return values. We have already seen the MsgBox function. This function opens a dialog box and displays a message to the user.

Subroutines and procedures are the same thing. A subroutine is defined with the Sub keyword. A subroutine is a procedure, and the subroutine can be executed within a macro in SDL Passolo. So we will

74 SDL Passolo Automation Basic programming concepts 0

use the terms where they seem appropriate but they mean the same thing.

Declarations

Previous examples have illustrated how a subroutine is defined in a SDL Passolo Script Engine module. The Sub keyword declares the subroutine and it is followed by the name of the subroutine.

A list of parameters can be supplied in the parenthesis after the name of the subroutine. The statements that should be executed by the subroutine follow the sub declaration and the subroutine ends with an End Sub statement. The following shows the declaration of a subroutine:

Sub SubName() [Statements] End Sub

Functions can also be declared. As mentioned they need some arguments (in some cases none) and they return one value and one value only. Functions can be called from running subroutines or macros or can be call-back functions within Passolo. This allows you to design your own functions for some checks, that you perform often. The following example shows a declaration of a subroutine, and a function. The subroutine calls the function, and uses the return value in a display box.

Sub TryAdd() MsgBox(Str$(AddNumbers(34, 21))) End Sub Function AddNumbers(NumOne As Integer, NumTwo As Integer) AddNumbers = NumOne + NumTwo End Function

The example also illustrates how the functions return their value. An internal variable in the function with the same name as the function holds the return value. The value of this variable is returned when the function exits. Controlling program flow

One of the advantages of programming your own macros is the ability to automate tasks. You can instruct SDL Passolo to do the same task over and over again.

To do this you need to be able to control the program flow. If you want Passolo to do the same task twice you have to execute the macro twice. This might work if you want to do something two or three times, but it becomes annoying quite quickly. You may also be interested in controlling what Sax Basic does based on certain values (a classic "if something then do something else" problem). This section will illustrate how to deal with these problems in Sax Basic.

SDL Passolo Automation 75 0 Basic programming concepts

GoTo Statement

The GoTo statement is the simplest control structure in Basic. It basically allows you to jump to labels you insert in the code.

An example:

Sub GoToExample() GoTo MyLabel MsgBox("I have to execute every line of the code") MyLabel: MsgBox("I have skipped part of the code") End Sub

Running this subroutine should illustrate how the GoTo statement is used. It should also illustrate why you should avoid using the statement. Your code becomes very messy and difficult to read, and you tend to get unexplainable behavior in you macros, because you loose track of the program flow. The GoTo statement has one useful purpose. This is illustrated in the section on error handling. If you can't find an alternative for the GoTo statement, think harder!

If-Then-Else Statements

If statements are the most widely used control statements in Sax Basic. If you only learn one control statement this should be the one. In the simplest form it is very easily understood, but nested If statements can get complicated as we shall see.

The basic form of the If statements is:

If [Condition] Then [Statements] Else [Statements] End if

An example of the use of an If statement could look like this:

Sub CheckSourceListTitle() Dim Title As String Dim userTitle As String Title = PSL.ActiveProject.SourceLists.Item(1).Title userTitle = InputBox("Enter first source list name!") If Title <> userTitle Then MsgBox ("This is the wrong name: " & userTitle) Else MsgBox ("This source list name is correct.") End If End Sub

This example also illustrates other features of Sax Basic. The InputBox function is very useful for getting information from the user. It displays a string (some text) to the user and returns the information typed by the user. It also illustrates how to extract the title of a source list. It should be mentioned that this subroutine is not complete. Just try clicking cancel in the dialog box.

76 SDL Passolo Automation Basic programming concepts 0

If statements can be nested. This means that you can have an If statement inside another If statement. The general form would be:

If [Condition] Then If [Other condition] Then [Statements] Else [Statements] End If Else [Statements] End if

You can nest as many If statements inside each other as you please, but it gets complicated and you might loose track of what you are doing. Generally avoid more than three or four nested If statements. You can also modify the If statements with an ElseIf. It's much harder to explain than to understand. The general form is:

If [Condition] Then [Statements] ElseIf [Condition] Then [Statements] Else [Statements] End if

The following example illustrates the use of the structure:

Sub Season() Dim TodaysMonth As Integer TodaysMonth = Month(Now) If TodaysMonth < 3 Then MsgBox "Winter" ElseIf TodaysMonth < 6 Then MsgBox "Spring" ElseIf TodaysMonth < 9 Then MsgBox "Summer" ElseIf TodaysMonth < 11 Then MsgBox "Autumn" Else MsgBox "Winter" End If End Sub

Look for other examples of If statements in this documents, and play around with the structure until you feel you are comfortable with it. As mentioned this is a very important control structure.

Select-Case Structure

The If-Then-Else statements can as mentioned be nested and make is possible to choose between many different possibilities. They tend to get a bit complicated and the code tends to look messy if you use to many nested If statements. When you need Basic to choose between lots of different options, the Select Case structure is a better solution.

The general form is:

SDL Passolo Automation 77 0 Basic programming concepts

Select Case [Expression] Case [Expression] [Statements] Case [Expression] [Statements] Case Else [Statements] End Select

In a practical example it could look like this.

Sub Season() Dim TodaysMonth As Date TodaysMonth = Month(Now)

Select Case TodaysMonth Case 1 To 2 MsgBox "Winter" Case 3 To 5 MsgBox "Spring" Case 6 To 8 MsgBox "Summer" Case 9 To 10 MsgBox "Autum" Case Else MsgBox "Winter" End Select End Sub

You should use the Select Case structure when making choices based on more than three or four possibilities. It makes the code easier to read, and prevents errors. Select Case structures can also be nested, and you can have If structures nested inside the Select Case structures.

With Statement

Subroutines often need to perform several different actions on the same object.

One way is to use several statements:

PSL.Projects(1).SourceLists(1).String(1).State(pslStateReadOnly) = True PSL.Projects(1).SourceLists(1).String(1).Comment = "Set to read only"

This is easier to read, and more efficient, using the With statement:

With PSL.Projects(1).SourceLists(1).String(1) .State(pslStateReadOnly) = True .Comment = "Set to read only" End With

The object reference can be a reference to a collection.

78 SDL Passolo Automation Basic programming concepts 0

For-Each Loop

There are several different ways in which you can loop on a collection, however the recommended method is to use a For-Each loop, in which Sax Basic automatically sets an object variable to return every object in the collection. This structure is very powerful and allows you to loop through all the elements in an array, too.

One of the benefits of this structure is that you don't need to know in advance how many elements have been filled in the array. Its real power, however, is in the manipulation of collections of objects:

Sub ExampleForEach() Dim prj As PslProject Set prj = PSL.ActiveProject Dim lng As PslLanguage For Each lng In prj.Languages prj.LogMessage( lng.LangCode) Next lng End Sub

In this example, all languages within the active SDL Passolo project are listed in the output windows.

Note: PslSourceList and PslTransList are arrays and not collections and you must use the property String to access the data. For-each can not be used with these two objects.

ӍObjectPslSourceList.String PslSourceListPslTransList Ӎ Ӎ

For-Next Loop

Sax Basic provides a number of different loop structures. The loop structure allows you to ask Basic to repeat the same task for a certain number of times. The first and perhaps the most widely used of these loop structures is the For-Next loop. This structure uses a counter to determine the number of times a certain set of statements have been executed.

The general form is seen below:

For counter = startValue To endValue [Step stepValue] [Statements] Next counter

The step value is optional. If no step value is provided, the counter value is incremented by one on each run through the loop. A practical example:

Sub SetReadOnly() Dim cnt As Integer Dim srclst As PslSourceList Set srclst = PSL.ActiveSourceList For cnt = 1 To srclst.StringCount srclst.String(cnt).State(pslStateReadOnly) = True Next cnt End Sub

In this example, all strings of the active source list are set to read only. If statements, Select Case statements etc. can be nested in the loops. This way decisions can be made on each run through the

SDL Passolo Automation 79 0 Basic programming concepts

loop. If for some reason you want to exit the loop based on a decision include an Exit For statement.

Do-While And Do-Until Loop

Another example for a loop structure is the Do-While and Do-Until. The Do-While structure repeats a block of statements while a condition is True.

Do While [Condition] [Statements] [Exit Do] [Statements] Loop Do [Statements] [Exit Do] [Statements] Loop Until [Condition]

Again a practical example:

Sub ExampleWhile() Do While PSL.Glossaries.Count > 0 PSL.Glossaries.Remove(1) Loop End Sub

The above example could have been made with a Do-Until structure:

Sub ExampleUntil() Do PSL.Glossaries.Remove(1) Loop Until PSL.Glossaries.Count = 0 End Sub

The example deletes the glossaries from the project. The difference between those two loops structures is, that the Do-Until loop first executes the statements before the condition is checked. Under special conditions, this can cause problems. So use the Do-Until loop only if you are sure, that the statements within the loop should be executed at least one time.

Error Handling

It was mentioned that the GoTo statement can be used in a constructive fashion to handle errors. The errors in question are the so-called intentional errors.

The principle is as follows. You ask Sax Basic to perform a loop, knowing that sooner or later it will fail for some reason. When that happens you use a GoTo statement to exit the loop without the whole macro failing. The code for such an error handling could look like this:

Sub CopyFiles(SrcName As String, DstName As String) On Error GoTo FileNotFound FileCopy SrcName, DstName FileNotFound:

80 SDL Passolo Automation Basic programming concepts 0

MsgBox "File not found: " & SrcName End Sub

This example copies a file named SrcName to a new file named DstName. If the file SrcName is not present, this causes and error. This error leads to a GoTo statement, and we can handle the error in a suitable way. Code optimization

Sax Basic is very flexible - there are usually several ways to accomplish the same task. When you are writing macros you will probably be happy enough to get one that does what is required; when writing one that will be used many times, or will be used by a group of users, you will probably want to ensure that the most efficient coding is used. The following techniques describe ways in which you can make your macros smaller and faster.

Minimizing OLE references

Every Sax Basic method or property call requires one or more OLE calls, each of which takes time. Minimize the number of such calls.

Use Object Variables

If you find you are using the same object reference many times, set a variable for the object and use that instead.

Use the With Statement

Use the With statement to avoid unnecessary repetition of object references without setting an explicit object variable.

Use a For-Each Loop

Using a For-Each loop to iterate through a collection or array is faster than using an indexed loop. In most cases it is also more convenient and makes your macro smaller and easier to debug.

Keeping Properties and Methods Outside Loops

Your code can get variable values faster than it can get property values. You should therefore assign a variable to the property of an object outside the loop and use that within a loop, rather than obtaining the property value each time within the loop. For example:

For i = 2 To 50 srclst.String(i).Comment = srclst.String(1).Comment Next counter this is inefficient and should be replaced by:

SDL Passolo Automation 81 0 Basic programming concepts

Dim comment as string comment = srclst.String(1).Comment For i = 2 To 50 srclst.String(i).Comment = comment Next counter

If you're using an object accessor inside a loop, try moving it outside the loop:

For i = 1 to 50 PSL.ActiveSourceList.String(i).Comment = "Remark" Next should be replaced by:

With PSL.ActiveSourceList For i = 1 To 50 .String(i).Comment = "Remark" Next i End With

Using Collection Index Numbers

Most object accessor methods allow you to specify an individual object in a collection whether by name or by index number. Using the number is much faster than using the name. Set against this, however, is the fact that using the name makes your code easier to read, and will specify the object uniquely (the number could change).

Minimizing the Use of Variant Variables

Although you may find it convenient to use variant types in your code, it is a waste of storage and slower to process such variables. Declare your variables explicitly wherever possible.

Use Specific Object types

If you declare object variables with the Object generic type, Sax Basic may have to resolve their references at run-time; if you use the specific object declaration Sax Basic can resolve the reference at compile-time.

Use Constants

Using declared constants in an application makes it run faster, since it evaluates and stores the constant once when the code is compiled.

82 SDL Passolo Automation G

Reference 0 Reference

This graph shows all objects and their relationships. Click on a box to jump to the object reference.

Object PassoloApp

PassoloApp is the root object. All other SDL Passolo objects are created through method calls of PassoloApp. PassoloApp is the only Passolo object that fires events. Event Handlers can be imple- mented to handle these events.

Methods

PassoloApp.ConvertASCII2Unicode

The SAX Basic Engine uses Unicode to store text. If you read text from an ASCII file, the current system codepage is used to convert the text to Unicode. In case that the text is based on a different codepage, the text needs to be converted to Unicode using the correct codepage with ConvertASCII2Unicode.

Syntax Expression.Convert ASCII2Unicode (Text as String, CodePage as Long) as String Expression Required. Object of type PassoloApp Text The text to be converted CodePage The codepage to be used for the conversion

Example

' This text file has been written with codepage 1256 (Arabic) Open "c:\Sample.txt" For Input As #1 Dim s As String Line Input #1,s s = PSL.ConvertASCII2Unicode(s, 1256) ...

PassoloApp.ConvertUnicode2ASCII

PassoloApp.ConvertUnicode2ASCII

The SAX Basic Engine uses Unicode to store text. If you write text to an ASCII file, the current system codepage is used to convert the text. In case that the text is based on a different codepage, the text needs to be converted from Unicode using the correct codepage with ConvertUnicode2ASCII before writing to the file.

84 SDL Passolo Automation Reference 0

Syntax Expression.ConvertUnicode2ASCII (Text as String, CodePage as Long) as String Expression Required. Object of type PassoloApp Text The text to be converted CodePage The codepage to be used for the conversion

Example

Sub main ' Creates a glossary from the current translation list Dim trn As PslTransList Set trn = PSL.ActiveTransList If trn Is Nothing Then Exit Sub stringcount = trn.StringCount Open "c:\MyGlossary.txt" For Output As #1 Print #1,trn.SourceList.LangID;Chr(9);trn.Language.LangID codepage1 = trn.SourceList.Option(pslOptionActualCodepage) codepage2 = trn.Language.Option(pslOptionActualCodepage) For i = 1 To stringcount Dim t As PslTransString Set t = trn.String(i) If t.State(pslStateTranslated) Then Dim s1 As String s1 = PSL.ConvertUnicode2ASCII(t.SourceText, codepage1) s2 = PSL.ConvertUnicode2ASCII(t.Text, codepage2) Print #1,s1;Chr(9);s2 End If Next i End Sub

PassoloApp.ConvertASCII2Unicode

PassoloApp.GetConcordances

Returns a list of concordances for one string. The function will search through all concordance providers as set up in the SDL Passolo options. But, in contrast to the Passolo application this function only uses translation providers that are capable of return synchronous results.

Syntax Expression.TranslateText (Text as String ,LanguageFrom as Variant, LanguageTo as Variant, MinMatch as Variant, MaxCount as Variant) as PslTranslations Expression Required. Object of type PslTransList Text String, Required. Concordances of this string are searched. LanguageFrom Required. The source language for the translation. Specify the language by its ID (1033 for English(USA)) or by its name ("enu") LanguageTo Required. The source language for the translation MinMatch Variant, optional. Specifies the minimum match required. The default value is 100, so that the function searches for exact matches by default. MaxCount Variant, optional. Specifies the maximum number of segments to be returned.

SDL Passolo Automation 85 0 Reference

Note: The list of concordances will be returned as an PslTranslations object which contains all concor- dances found.

Example

Sub Main ' Clear the output window PSL.OutputWnd(pslOutputWndMessages).Clear Dim ts As PslTranslations Dim t As PslTranslation ' Concordances PSL.Output("Concordances------") Set ts = PSL.GetConcordances("Open", 1033, 1031, 100) For Each t In ts PSL.Output t.TransString & " (" & t.Origin & ")" Next End Sub

Object PslTranslations Object PslTransList

PassoloApp.GetDefaultCodePage

Returns the default code page of a language.

Syntax Expression.GetDefaultCodePage (LangID as Integer) as Long Expression Required. Object of type PassoloApp LangID Integer, Language ID as defined in the appendix of the SDL Passolo Reference Manual and used in Passolo to define source and target languages.

Example

... Dim lang as Integer ... Dim codepage As Integer codepage = rd.SourceCodePage If codepage = 0 Then codepage = PSL.GetDefaultCodePage(lang) End If

86 SDL Passolo Automation Reference 0

PassoloApp.GetLangCode

Returns a language or region/country code as string.

Syntax Expression.GetLangCode (LangID as Integer, Type as Variant) as String Expression Required. Object of type PassoloApp LangID Integer, Language ID as defined in the appendix of the SDL Passolo Reference Manual and used in Passolo to define source and target languages. Type Variant, optional. pslCodeWin (default) (Value = 0):return language code as used by Windows. See appendix of the Passolo Reference Manual ("deu") pslCode639_2B (Value = 1): return language code as ISO 639 3-letter code (Bibliography) ("ger") pslCode639_2T (Value = 2): return language code as ISO 639 3-letter code (Terminology) ("deu") pslCode639_1 (Value = 3): return language code as ISO 639 2-letter code ("de") pslCodeISO (Value = 4): return language code as ISO 639 3-letter code or ISO 639 2-letter code if available ("de") pslCode3166_2(Value = 5): returns region/country code as ISO 3166 2 3-letter code ("deu") pslCode3166_1 (Value = 6): returns region/country code as ISO 3166 2 2-letter code ("DE") pslCodeWinRgn (Value = 7): returns region/country code as Windows 3-letter code ("DEU") pslCodeLangRgn (Value = 8): returns combined ISO language - region/country code ("de-DE") pslCodeHex (Value = 9): returns a the language code as hex values. If the region is the default region, only the primary language is returned. E.g. pslLangEnglishUSA returns "09", but pslLangEnglishCana- da returns "0904" pslCodeHex2 (Value = 10): returns a the language code as hex values. In contrast to pslCodeHex the secondary language is returned with default regions. E.g. pslLangEnglishUSA returns "0901" pslCodeText (Value = 11): return the localized name of the language (country/region) ("German (Germany)"). This depends of the language of the Passolo user interface. pslCodeEnglishText (Value = 12): return the English name of the language (country/region) ("German (Germany)") pslCodeDecimal (Value = 13): return the language code as decimal value, i.e. LangID as string pslCodeSDLX (Value = 14): return the language code used for SDLX ("DE") pslCodeTrados (Value = 15): return the language code used for SDL Trados ("DE-DE")

SDL Passolo Automation 87 0 Reference

Example

Sub main Dim msg As String msg = "The language codes for basque are" & vbCrLf msg = msg & PSL.GetLangCode(pslLangBasque, pslCode639_2B) & " in pslCode639_2B" & vbCrLf msg = msg & PSL.GetLangCode(pslLangBasque, pslCode639_2T) & " in pslCode639_2T" & vbCrLf msg = msg & PSL.GetLangCode(pslLangBasque, pslCodeWin) & " in pslCodeWin" MsgBox(msg) End Sub

PassoloApp.GetLangID

Returns a language id as integer. If the id is not defined the return value is -1.

Syntax Expression.GetLangID (LangCode as String, Type as Variant) as Integer Expression Required. Object of type PassoloApp LangCode String, Language code Type Variant, optional. pslCodeUnknown (default, Value = -1): interprets LangCode as any of the codes below pslCodeWin (Value = 0): interprets LangCode as used by Windows. See appendix of the SDL Passolo Reference Manual. pslCode639_2B (Value = 1): interprets LangCode as ISO 639 3-letter code (Bibliography) pslCode639_2T (Value = 2): interprets LangCode as ISO 639 3-letter code (Terminology) pslCode639_1 (Value = 3): interprets LangCode as ISO 639 2-letter code pslCodeISO (Value = 4): interprets LangCode as ISO 639 3-letter code or ISO 639 2-letter code if available pslCode3166_2 (Value = 5): interprets LangCode as ISO 3166 2 3-letter code pslCode3166_1 (Value = 6): interprets LangCode as ISO 3166 2 2-letter code pslCodeWinRgn (Value = 7): interprets LangCode as Windows 3-letter code pslCodeLangRgn (Value = 8): interprets LangCode as combined ISO language - region/country code pslCodeHex (Value = 9): interprets LangCode as hex values. If LangCode defines only the primary language id, the default region is returned. E.g. "09" returns 1033 (pslLangEnglishUSA) pslCodeHex2 (Value = 10): interprets LangCode as hex values. If LangCode defines only the primary language id, no region is returned. E.g. "09" returns 9 (Language id for English without region) pslCodeText (Value = 11): interprets LangCode as localized name of the language (country/region). This depends of the language of the Passolo user interface. pslCodeEnglishText (Value = 12): interprets LangCode English name of the language (country/region)

88 SDL Passolo Automation Reference 0

pslCodeDecimal (Value = 13): interprets LangCode as decimal value of the LangID pslCodeSDLX (Value = 14): interprets LangCode as SDLX language code pslCodeTrados (Value = 15): interprets LangCode as SDL Trados language code

Example

Dim msg As String msg = "The language id of german is" & vbCrLf msg = msg & PSL.GetLangID("deu") MsgBox(msg)

PassoloApp.GetLastOutput

Returns the text that has been written to the Passolo Message Window during the last command.

Syntax Expression.GetLangOutput() as String Expression Required. Object of type PassoloApp

Example

Dim prj As PslProject Set prj = PSL.ActiveProject If prj Is Nothing Then Exit Sub If (Not prj.Import("PASSOLO text format", "c:\test_de.txt")) Then MsgBox PSL.GetLastOutput End If

PassoloApp.GetTerminology

Returns a list of terminology items for one string. The function will search through all terminology providers as set up in the SDL Passolo options. But, in contrast to the Passolo application this function only uses translation providers that are capable of return synchronous results.

Syntax Expression.TranslateText (Text as String, LanguageFrom as Variant, LanguageTo as Variant, MinMatch as Variant, MaxCount as Variant) as PslTranslations Expression Required. Object of type PslTransList Text String, Required. This term to look for.

Note: this is a single term, not a segment containing several terms.

LanguageFrom Required. The source language for the translation. Specify the language by its ID (1033 for English(USA)) or by its name ("enu")

SDL Passolo Automation 89 0 Reference

LanguageTo Required. The source language for the translation MinMatch Variant, optional. Specifies the minimum match required. The default value is 100, so that the function searches for exact matches by default.

Note: The list of terminology will be returned as an PslTranslations object which contains all terms found.

Example

Sub Main ' Clear the output window PSL.OutputWnd(pslOutputWndMessages).Clear Dim ts As PslTranslations Dim t As PslTranslation ' Terminology PSL.Output("Terminology------") Set ts = PSL.GetTerminology("Open", 1033, 1031, 100) For Each t In ts PSL.Output t.TransString & " (" & t.Origin & ")" Next End Sub

Object PslTransList

PassoloApp.GetTextCounts

Counts Words, letters and characters in a string. The count results are stored in the returned PslString- Counter object.

Syntax Expression.GetTextCounts (Text as String) as PslStringCounter Expression Required. Object of type PassoloApp Text String. Words, letter and characters in this string are counted.

Example

Sub main Dim s As String, msg As String Dim sc As PslStringCounter s = "This text contains 7 words, 41 letters and 57 characters." Set sc = PSL.GetTextCounts(s) msg = "The text contains " & CStr(sc.WordCount) & " words, " msg = msg & CStr(sc.LetterCount) & " and " msg = msg & CStr(sc.CharCount) & " characters." MsgBox(msg) End Sub

Object PslStringCounter

90 SDL Passolo Automation Reference 0

PassoloApp.Import

Imports data from an external file and returns the updated PslTransList.

Syntax Expression.Import (Format as String, FileName as String, [optional] Flags as Variant) as PslTranslist Expression Required. Object of type PassoloApp Format Identifier of the add-in which is used for import. The add-in list in SDL Passolo displays the identifier of each add-in. These are the add-ins that are shipped with Passolo and be used for import: "Passolo translation bundle" "Passolo text format" "Passolo Customizable Text Export" "Passolo Customizable Text Export" "Passolo XML Export/Import" "Trados Text Export" FileName Name of the file to be imported Flags Some options to control the import. To combine flags, add the values: psl ImportValidate (Value = 256):Text-based imports only: The strings will be validated after importing the translation. psl ImportMerge (Value = 512): Translation bundles only: The translations in the bundle are merged with the existing translations in the project. If you are importing a licensed translation bundle, you can merge only if you use an unlimited Team Edition of Passolo. psl ImportRelease (Value = 1024): Translation bundles only: Imported string lists are released after import. If this flag is not set, the translation list in the project remains marked as "exported". Object PslTransList

PassoloApp.ImportOptions

Imports options from a profile or an options file.

Syntax Expression.ImportOptions (ProfileOrPath as String, optional] Content as Variant) as Boolean Expression Required. Object of type PassoloApp ProfileOrPath An profile name or the path to an option file. To create an profile or an option file use the Export command in the SDL Passolo options dialog. Content optional, Specifies the options to be loaded. It is a comma-separated list of values corresponding to the pages of the Options dialog:view, filter, toolbars, listops, transdlg, languages, leverage, pretrans,

SDL Passolo Automation 91 0 Reference

fuzzy, concordances, terminology, replicates, assistant, check, spellcheck, binaries, simulation, sytem- macro, batch, users, system, system2, folders. If the parameter is missing all options available in the profile or options file are loaded . Text The message string

Example

' Creates a translation bundle for each language Sub Main PSL.ImportOptions("MyOptions", "pretrans,fuzzy") End Sub

PassoloApp.Output

Prints a message to the output windows of SDL Passolo.

Syntax Expression.OutputText as String Expression Required. Object of type PassoloApp Text The message string

PassoloApp.Quit

Quits SDL Passolo. Cannot be used in an internal script.

Syntax Expression.Quit Expression Required. Object of type PassoloApp

PassoloApp.SelectFile

Calls a dialog where the user can select a file

Syntax Expression.SelectFile(Path as String, Open as Boolean, Filter as Variant, Title as Variant) as Boolean Expression Required. Object of type PassoloApp Path Returns the path of the selected file Open Set to True to use the "File Open" dialog. Set to False to open the "File Save As" dialog. Filter optional, The filter string, e.g. "TextFiles(*.txt)|*.txt|All Files(*.*)|*.*||"

92 SDL Passolo Automation Reference 0

Title optional, The caption for the dialog box

Example

Sub Main Dim path As String PSL.SelectFile(path, True,,"Please select a file") PSL.Output "The selected file is at " & path End Sub

PassoloApp.SelectFolder

Calls a dialog where the user can select a folder

Syntax Expression.SelectFolder (Path as String, [optional] Title as Variant) as Boolean Expression Required. Object of type PassoloApp Path The initial path for the selector dialog Title The caption of the selector dialog

PassoloApp.SendAddInMessage

Sends an arbitrary message to an add-in. The parameters ar send using the PAIFN_OnMacroMessage function.

Syntax Expression.SendAddInMessage (AddIn as String, LPar as long, StrPar as String) Expression Required. Object of type PassoloApp AddIn Identifies the add-in. The add-in list in the SDL Passolo options pages displays the identifier of each add-in. LPar A integer parameter StrPar A string parameter

PassoloApp.ShowAppStatus

Creates a status display in the status bar of the main window. This can be a simple text line or a progress bar.

SDL Passolo Automation 93 0 Reference

Syntax Expression.ShowAppStatus (Type as Long, Text as Variant) as PslAppStatus Expression Required. Object of type PassoloApp Type The type of the status display. Combine these values by adding them: pslAppStatusText (Value = 0) The status displays a text line only pslAppStatusBusy (Value = 1) A red dot is displayed to indicate that SDL Passolo is busy pslAppStatusAbort (Value = 2) A hint is displayed to indicate that the operation can be aborted by pressing the Pause key. pslAppStatusProgress (Value = 4) A progress bar is displayed. Use PslAppStatus.ProgressMin, PslAppStatus.ProgressMax and PslAppStatus.ProgressPos to adjust the display of the progress bar. Text The initial text of the status display Object PslAppStatus PslAppStatus.Aborted PslAppStatus.ProgressMin PslAppStatus.ProgressMax PslAppStatus.ProgressPos

PassoloApp.TranslateText

Returns a list of translations for one string. Depending on MinMatch it looks for pre-translations or fuzzy matches. The function will search through all translation providers as set up in the SDL Passolo options. But, in contrast to the Passolo application this function only uses translation providers that are capable of return synchronous results

Syntax Expression.TranslateText (Text as String, LanguageFrom as Variant, LanguageTo as Variant, MinMatch as Variant, MaxCount as Variant) as PslTranslations Expression Required. Object of type PslTransList Text String, Required. This string will be translated. LanguageFrom Required. The source language for the translation. Specify the language by its ID (1033 for English(USA)) or by its name ("enu") LanguageTo Required. The source language for the translation MinMatch Variant, optional. Specifies the minimum match required. The default value is 100, so that the function searches for pre-translations. A value less then 100 will look for fuzzy matches. MaxCount Variant, optional. Specifies the maximum number of translations to be returned. The default value ist 10.

Note: The list of translation will be returned as an PslTranslations Object which contain all translations found.

94 SDL Passolo Automation Reference 0

Example

Sub Main ' Clear the output window PSL.OutputWnd(pslOutputWndMessages).Clear Dim ts As PslTranslations Dim t As PslTranslation ' Pretranslation PSL.Output("Pre-Translation------") Set ts = PSL.TranslateText("Resources: ", 1033, 1031, 100) For Each t In ts PSL.Output t.TransString & " (" & t.Origin & ")" Next ' Fuzzy Matches PSL.Output("Fuzzy Matches------") Set ts = PSL.TranslateText("&File", 1033, 1031, 80) For Each t In ts PSL.Output t.TransString & " (" & t.Origin & ")" Next End Sub

Object PslTransList Object PslTranslations

PassoloApp.TransLists

This function is obsolete and must not be used anymore. It's not possible to load .trx files anymore.

Properties

PassoloApp.ActiveProject

Returns the current PslProject object, this means the project of which the window is just active. If a string list is activated, the accompanying project is returned. Otherwise Nothing is returned.

Syntax Expression.ActiveProject as PslProject Expression Required. Object of type PassoloApp

Example

Dim prj As PslProject Set prj = PSL.ActiveProject If prj Is Nothing Then PSL.Output "No active project found." Else PSL.Output prj.Name End If

Object PslProject

SDL Passolo Automation 95 0 Reference

PassoloApp.ActiveSourceDisplay

Returns the current PslSourceDisplay object, this means the source list window that is just active.

Syntax Expression.ActiveSourceList as PslSourceList Expression Required. Object of type PassoloApp

Example

Dim sdisp As PslSourceDisplay Set sdisp = PSL.ActiveSourceDisplay If sdisp Is Nothing Then PSL.Output "No active source list window found." Else PSL.Output "Strings in active source list window: " & sdisp.StringCount End If

Object PslSourceDisplay

PassoloApp.ActiveSourceList

Returns the current PslSourceList object, this means the source string list whose window is just active. If a project window is activated and exactly one source string list is selected, this source string list will be returned. Otherwise Nothing is returned.

Syntax Expression.ActiveSourceList as PslSourceList Expression Required. Object of type PassoloApp

Example

Dim src As PslSourceList Set src = PSL.ActiveSourceList If src Is Nothing Then PSL.Output "No active source list found." Else PSL.Output src.SourceFile End If

Object PslSourceLists

96 SDL Passolo Automation Reference 0

PassoloApp.ActiveTransDisplay

Returns the current PslTransDisplay object, this means the source list window that is just active.

Syntax Expression.ActiveSourceList as PslSourceList Expression Required. Object of type PassoloApp

Example

Dim tdisp As PslTransDisplay Set tdisp = PSL.ActiveTransDisplay If tdisp Is Nothing Then PSL.Output "No active translation list window found." Else PSL.Output "Strings in active translation list window: " & tdisp. StringCount End If

Object PslTransDisplay

PassoloApp.ActiveTransList

Returns the current PslTransList object, this means the translation list whose windows is just active. If a project window is activated and exactly one translation list is selected, this translation list will be returned. Otherwise Nothing is returned.

Syntax Expression.ActiveTransList as PslTransList Expression Required. Object of type PassoloApp

Example

Dim trn As PslTransList Set trn = PSL.ActiveTransList If trn Is Nothing Then PSL.Output "No active translation list found." Else PSL.Output trn.TargetFile End If

Object PslTransList

SDL Passolo Automation 97 0 Reference

PassoloApp.Build

Returns the build number of the current SDL Passolo application. This is the third part of the version string. For example for Passolo 4.1.003 this returns 3.

Syntax Expression.Build as Short Expression Required. Object of type PassoloApp

Example

PSL.Output Str(PSL.Build)

PassoloApp.DisplayAlerts

Defines the behaviour of message boxes during macro execution. DisplayAlerts can have one of these values pslAlertsDefault (Value = 0) Message boxes are displayed, if the corresponding flag in the batch options is set. pslAlertsNone (Value = 1) No message boxes are displayed. The macro continues execution with the default reply of the message box. pslAlertsAll (Value = 2) All message boxes are displayed. pslAlertsMessageBox (Value = 3) Only error message boxes are displayed

Syntax Expression.DisplayAlerts as Long Expression Required. Object of type PassoloApp

Example

' Always display message boxes PSL.DisplayAlerts = pslAlertsAll

98 SDL Passolo Automation Reference 0

PassoloApp.FreeExportLicenses

The SDL Passolo Team Edition returns the number of free license slots, that can be used to create licensed translation bundles. All other editions return 0.

Syntax Expression.FreeExportLicenses as Long Expression Required. Object of type PassoloApp

Example

Sub main ' Write a licensed translation bunde that contains ' the currently selected translation list If PSL.FreeExportLicenses = 0 Then MsgBox "No free export licenses." Exit Sub End If Dim prj As PslProject Set prj = PSL.ActiveProject If prj Is Nothing Then Exit Sub Dim trn As PslTransList Set trn = PSL.ActiveTransList If trn Is Nothing Then Exit Sub ' Define the translation bundle Dim bundle As PslTransBundle Set bundle = prj.PrepareTransBundle bundle.AddTransList trn bundle.License("By automation") prj.ExportTransBundle bundle, "c:\test.tba" End Sub

PassoloApp.Glossaries

Returns the PslGlossaries object that contains all global glossaries.

Syntax Expression.Glossaries as PslGlossaries Expression Required. Object of type PassoloApp Object PslGlossaries

PassoloApp.License

Returns a value greater 0, if the license is ok, i.e. the dongle is attached or another runtime license is available. If no license is found the value is 0. If all available licenses are in use, the value is -1.

The license can be checked after using CreateObject, if SDL Passolo is externally automated, e.g. in a Visual Basic application. If no license is available, the object is created, but no other functions can be used.

There is no need to check the license in a Passolo macro, because Passolo can not be started without a license.

SDL Passolo Automation 99 0 Reference

Syntax Expression.License as Long Expression Required. Object of type PassoloApp

Example

Dim psl16 As Object Set psl16 = CreateObject("Passolo.Application.16") If psl16.License = -1 Then MsgBox "All licenses are in use" psl6.Quit Set psl6 = Nothing Exit Sub End If If psl16.License = 0 Then MsgBox "No license found" psl16.Quit Set psl16 = Nothing Exit Sub End If ...

PassoloApp.Option

Returns or sets a setting from the PASSOLO Options Dialog.

Syntax Expression.Option( Name as long) as VARIANT Expression Required. Object of type PassoloApp Name Specifies which option to return or set. See tables

Description

These tables contain all valid option names

Name (Value) Option Content pslOptionViewColor (-100) Display items in resource editor boolean with status color pslOptionViewCoord (-101) Display coordinates as 0 = Dialog Units 1 = Pixels pslOptionViewSortResource Sort Resources 0 = Original Order 1 = Sort by ID (-106) 2 = Sort by info text pslOptionViewNames (-102) Display IDs 0 = Display ID names if available 1 = Display ID values 2 = Display both pslOptionViewState (-107) Display State 0 = Symbol and Text 1 = Symbol only 2 = Symbol only, in different columns

100 SDL Passolo Automation Reference 0

Name (Value) Option Content pslOptionViewEmpty (-103) Display empty strings in boolean translation list pslOptionViewSyncResTree Synchronizes the resource tree boolean (-108) selection with the current string. pslOptionViewRestoreDisplay Restore last string list display boolean (-109) when opening a project.

Name (Value) Option Content pslOptionOpRecycleSource Move deleted source strings to boolean (-150) recycle bin pslOptionOpRecycleTrans Move deleted translation strings boolean (-151) to recycle bin pslOptionOpSourceChanged When the source of a translated 0 = Set string to "untranslated" 1 (-152) string has been changed = Set string to "for review" pslOptionOpCom- When the source comment of a 0 = Don't change status 1 = Set mentChanged (-153) translated string has been string to "for review" changed

Name (Value) Option Content pslOptionDlgTooltips (-200) Show tooltips boolean pslOptionDlgLongLines (-201) Long lines 0 = Word Wrap 1 = Scroll Horizontally 2 = Scroll Horizontally with Scrollbar pslOptionDlgZoom (-202) Font Zoom 10 - 300 (%) pslOptionDlgEnter (-203) Behaviour of ENTER key 0 = Select next string 1 = Inserts line feed pslOptionDlgSpaces (-204) Keep white spaces at beginning boolean and end of strings pslOptionDlgValidate (-205) Validate strings when edited boolean pslOptionDlgDirectEdit (-206) Allow direct editing of stirngs in boolean the list box pslOptionDlgTerminology Emphasize terminology items boolean (-207) pslOptionDlgSpelling (-208) Check spelling as you type boolean

Name (Value) Option Content pslOptionTagsMode (-180) How to edit tagged strings 0 = No tagging, edit original text 1 = Normal tags with short caption 2 = Small tags without caption 3 = Long tags with content

SDL Passolo Automation 101 0 Reference

Name (Value) Option Content pslOptionLevListLanguage Read string lists with same boolean (-220) languages pslOptionLevListPrimLanguage Read string lists with same boolean (-221) primary languages pslOptionLevListSourceFile Read string lists with same boolean (-222) source file pslOptionLevListSourceName Read string lists with same boolean (-223) source file name pslOptionLevIdentStringID Get data from strings with same boolean (-224) string ID pslOptionLevIdentParentID Get data from strings with same boolean (-238) string ID of the parent control pslOptionLevIdentResID (-225) Get data from strings with same boolean resource ID pslOptionLevIdentResType Get data from strings with same boolean (-226) resource type pslOptionLevIdentSourceString Get data from strings with same boolean (227) source string pslOptionLevIdentCategory Get data from strings with same boolean (-228) category pslOptionLevSrcFlags (-229) Source Lists: Flags boolean pslOptionLevSrcProp (-230) Source Lists: Properties boolean pslOptionLevSrcComments Source Lists: Comments boolean (-231) pslOptionLevSrcCustomProp Source Lists: User-defined boolean (-239) properties pslOptionLevTrnText (-232) Translation Lists: Translated text boolean pslOptionLevTrnCoord (-233) Translation Lists: Coordinates boolean pslOptionLevTrnProp (-234) Translation Lists: Properties boolean pslOptionLevTrnCustomProp Translation Lists: Custom boolean (-235) properties pslOptionLevTrnState (-236) Translation Lists: State boolean pslOptionLevTrnBin (-237) Translation Lists: Translated boolean binary resources pslOptionLevTrnComment Translation Lists: Translation boolean (-240) Comment pslOptionLevNoDelete (-240) Flag: Don't overwrite exiting boolean values when leveraging empty values

102 SDL Passolo Automation Reference 0

Name (Value) Option Content pslOptionPreMulti (-250) If multiple matches are found 0 = take first match 1 = don't translate the string 2 = set a bookmark 3 = display all matches pslOptionPreUseFuzzy (-251) If no matches are found - use boolean best fuzzy match pslOptionPreFuzzyMin (-252) Minimum match for 30 - 100 (%) pslOptionPreUseFuzzy pslOptionPreAllowAuto (-253) If no matches are found - allow boolean automatic translation pslOptionPreFind (-260) Find strings 0 = with exact match pslIgnoreCase (256) pslIgnoreAmpersand (512) pslIgnoreSpaces (1024) pslIgnorePunctuation (2048) pslIgnoreAll (3840) (add values for combination) pslOptionPreRetranslate (-261) Retranslate strings that are boolean already translated pslOptionPreValidate (-262) Validate translated strings boolean pslOptionPreAmpersand (-263) Insert unique ampersand if boolean source string has an ampersand. pslOptionPreKeepSpaces Keep white-spaces at beginning boolean (-264) and end of a string pslOptionPreKeepPoint (-265) Keep points (.) at beginning and boolean end of a string pslOptionPreKeepComma Keep commas (,) at beginning boolean (-266) and end of a string pslOptionPreKeepColon (-267) Keep colons (:) at beginning and boolean end of a string pslOptionPreKeepExclamation Keep exclamation marks (!) at boolean (-268) beginning and end of a string pslOptionPreKeepQuestion Keep question marks (?) at boolean (-268) beginning and end of a string pslOptionPreKeepMore (-270) Additional characters to keep at String beginning and end of a string

Name (Value) Option Content pslOptionFuzzyMin (-280) Minimum match 30 - 100 (%) pslOptionFuzzyNumber (-281) Max. number of displayed 1 - 50 matches

SDL Passolo Automation 103 0 Reference

Name (Value) Option Content pslOptionConcMin (-290) Minimum match 30 - 100 (%) pslOptionConcNumber (-291) Max. number of displayed 1 - 50 matches

Name (Value) Option Content pslOptionReplMode (-350) Mode 0 = Don't tranlate replicates 1 = Translate replicates in current translation list 2 = Translate replicates in all translation lists of current project pslOptionReplNoPrompt (-351) Translate replicates boolean automatically without prompt pslOptionReplFind (-360) Find strings 0 = with exact match 1 = ignore case 2 = ignore ampersand 3 = ignore spaces 4 = ignore puntuation (add values for combination) pslOptionReplRetranslate Retranslate stirngs that are boolean (-361) already translated pslOptionReplValidate (-362) Validate translated strings boolean pslOptionReplAmpersand Insert unique ampersand if boolean (-363) source string has an ampersand. pslOptionReplKeepSpaces Keep white-spaces at beginning boolean (-364) and end of a string pslOptionReplKeepPoint (-365) Keep points (.) at beginning and boolean end of a string pslOptionReplKeepComma Keep commas (,) at beginning boolean (-366) and end of a string pslOptionReplKeepColon Keep colons (:) at beginning and boolean (-367) end of a string pslOptionReplKeepExclamation Keep exclamation marks (!) at boolean (-368) beginning and end of a string pslOptionReplKeepQuestion Keep question marks (?) at boolean (-369) beginning and end of a string pslOptionReplKeepMore (-370) Additional characters to keep at String beginning and end of a string

104 SDL Passolo Automation Reference 0

Name (Value) Option Content pslOptionAssistUse (-380) Use translation assistant boolean pslOptionAssistJump (-381) CTRL+Down and CTRL+Up and 0 = next / previous string 1 = cursor buttons jump to next / previous untranslated string 2 = next / previous "for review" string 3 = next / previous untranslated or "for review" string pslOptionAssistUntranslated When selecting an untranslated 0 = do nothing 1 = find fuzzy (-382) string translations 2 = translate automatically 3 = find fuzzy translations and use best match pslOptionAssistTranslated When selecting a translated 0 = do nothing 3 = find fuzzy (-383) string translations and use best match pslOptionAssistMinMatch Min match 80 - 100 (%) (-384)

Name (Value) Option Content pslOptionLayoutFromSource Start auto-layout from source boolean (-900) coordinates pslOptionLayoutLimit (-901) Limit the extension of controls 0 = off, 100 - 400 (%) pslOptionLayoutMultiline Set multiline flag if needed boolean (-902) pslOptionLayoutAllowSmaller Allow reduction in control width boolean (-903) pslOptionLayoutAddIn (-904) The identifier of the add-in used String for Auto-Layout

Name (Value) Option Content pslOptionCheckNumtabs Different number of tabulators boolean (-400) pslOptionCheckMnemonic1 Missing access key in translated boolean (-401) string pslOptionCheckMnemonic2 Translated string has access key, boolean (-402) but source string has none pslOptionCheckEmpty1 (-403) Missing translation text boolean pslOptionCheckEmpty2 (-404) Empty source string has boolean non-empty translation pslOptionCheckSpaces (-406) Different number of white boolean spaces at beginning or end of string pslOptionCheckMnemonic3 Access key out of valid range boolean (-407)

SDL Passolo Automation 105 0 Reference

Name (Value) Option Content pslOptionCheckTextLength Text too long boolean (-408) pslOptionCheckSpelling (-409) Spelling error boolean pslOptionCheckCodePage Character not in target code boolean (-410) page pslOptionCheckTerminology Missing term in translation boolean (-411) pslOptionCheckTabooWord Taboo word found boolean (-412) pslOptionCheckConsistency Inconsistant translation boolean (-413) pslOptionCheckPrintf (-414) Inconsistent printf formats boolean (check for all resource types) pslOptionCheckFormatMessage Inconsistent FormatMessage() boolean (-415) formats (check for all resource types) pslOptionCheckMenuAcc Duplicate Access key in menu boolean (-450) pslOptionCheckCtrlSize (-500) Text does not fit to control size boolean pslOptionCheckCtrlOverlap Control overlaps other control boolean (-501) pslOptionCheckCtrlOutside Control is not within the dialog boolean (-502) borders pslOptionCheckCtrlMnemonic Duplicate access key boolean (-503) pslOptionCheckCheckSrc Ignore the control size error if it boolean (-504) appears already in the source file pslOptionCheckAccInvalid Invalide accelerator boolean (-550) pslOptionCheckAccDuplicate Duplicate accelerator boolean (-551) pslOptionCheckPrintf (-600) Inconsistent printf formats boolean pslOptionCheckFormatMessage Inconsistent FormatMessage() boolean (-607) formats

Name (Value) Option Content pslOptionDlgSpelling (-208) Check spelling as you type boolean pslOptionSpellIgnoreUp- Ignore words in UPPERCASE boolean percase (-700) pslOptionSpellIgnoreNumbers Ignore words with numbers boolean (-701)

106 SDL Passolo Automation Reference 0

Name (Value) Option Content pslOptionBatchMessageBox Display message boxes boolean (-750) pslOptionBatchDelete (-751) Allow deletion of more than 20 boolean strings when updating

Name (Value) Option Content pslOptionUsersRequested User log in requested on startup boolean (-800) pslOptionUsersWindows (-801) Get user name from Windows boolean log in

Name (Value) Option Content pslOptionSystemLanguage Language long (-850) pslOptionSystemMacroPath Macros Path string (-851)

PassoloApp.OutputWnd

Returns the PslOutputWnd object, which represents a single page in the output docking window.

Syntax Expression.OutputWnd (Type as Variant) as PslOutputWnd Expression Required. Object of type PassoloApp Type Variant, optional. Specifies which page to return psl OutputWndMessages (Value = 0, default) :Returns the messages page psl OutputWndCheck (Value = 1) :Returns the check page psl OutputWndFind (Value = 2) :Returns the find page Object PslOutputWnd

PassoloApp.Projects

Returns the PslProjects object that contains all loaded projects, read-only property.

SDL Passolo Automation 107 0 Reference

Syntax Expression.Projects as PslProjects Expression Required. Object of type PassoloApp Object PslProjects

PslProject.Tasks

Returns a collection of the common tasks.

Syntax Expression.Tasks as PslTasks Expression Required. Object of type PassoloApp Object PslTasks

PassoloApp.Unicode

Returns True, if PassoloApp is the unicode version. Since SDL Passolo 6 only a unicode version is available, so this property is always True.

Syntax Expression.Unicode as Boolean Expression Required. Object of type PassoloApp

PassoloApp.User

Returns information of the current SDL Passolo user.

Syntax Expression.User (Field as Variant) as String Expression Required. Object of type PassoloApp Field Variant, optional. Specifies which field to return psl UserName (Value = 0, default) :Returns the name of the user. psl UserFullName (Value = 1) :Returns the full name of the user psl UserComment (Value = 2) :Returns the comment.

108 SDL Passolo Automation Reference 0

Example

MsgBox "Hello " & PSL.User(pslUserName) & "!"

PassoloApp.Version

Returns the version number of the current SDL Passolo application. The value is calculated as 100 * Majorversion + Minorversion. For example for Passolo 4.1.003 this returns 401.

Syntax Expression.Version as Short Expression Required. Object of type PassoloApp

Example

PSL.Output Str(PSL.Version)

PassoloApp.Visible

True, if main window of SDL Passolo is visible.

Syntax Expression.Visible as Boolean Expression Required. Object of type PassoloApp

Events

PassoloApp.AfterAlignTarget

Event handler for the event AfterAlignTarget. This event is raised, after a transation list has been aligned by scanning the target file.

SDL Passolo Automation 109 0 Reference

Syntax AfterAlignTarget (TransList as PslTransList, ByVal Error as Boolean) as void TransList The translation list that has been aligned Error Set to True, if an error occurred during the operation.

PassoloApp.AfterCheckTransList

This event handler is called, after a translation list has been checked.

Syntax AfterCheckTransList (TransList as PslTransList, ByVal Count as Long) as void TransList the translation updated Count Number of errors found during check

PassoloApp.AfterGenerateTarget

Event handler for the after generate target file event.

Syntax AfterGenerateTarget (TransList as PslTransList, ByVal Error as Boolean) as void TransList The translation list of the target generation Error Set to True, if an error occurred during the operation.

Example

Dim stored_size As Long Public Sub PSL_BeforeGenerateTarget(TransList As PslTransList, Abort As Boolean) stored_size = 0 On Error Resume Next ' Maybe the file does not exist yet stored_size = FileLen(TransList.TargetFile) End Sub Public Sub PSL_AfterGenerateTarget(TransList As PslTransList, ByVal Error As Boolean) If Not Error And stored_size <> 0 Then diff = FileLen(TransList.TargetFile) - stored_size

If diff = 0 Then PSL.Output "Size of target file did not change." ElseIf diff > 0 Then PSL.Output "Target file increased by " & Str(diff) & " bytes." Else PSL.Output "Target file decreased by " & Str(-diff) & " bytes." End If End If End Sub

110 SDL Passolo Automation Reference 0

PassoloApp.AfterUpdateSourceList

Event handler for the after update source list event.

Syntax AfterUpdateSourceList (SourceList as PslSourceList, ByVal Error as Boolean) as void SourceList the source list updated before Error Set to True, if an error occurred during the operation.

Example

Public Sub PSL_BeforeUpdateSourceList(SourceList As PslSourceList, Abort As Boolean) PSL.Output "Number of strings before update: " & Str(SourceList. StringCount) End Sub Public Sub PSL_AfterUpdateSourceList(SourceList As PslSourceList, ByVal Error As Boolean) PSL.Output "Number of strings after update: " & Str(SourceList. StringCount) End Sub

PassoloApp.AfterUpdateTransList

Event handler for the after update trans list event.

Syntax AfterUpdateTransList (SourceList as PslTransList, ByVal Error as Boolean) as void TransList the translation updated Error Set to True, if an error occurred during the operation.

Example

Public Sub PSL_BeforeUpdateTransList(TransList As PslTransList, Abort As Boolean) PSL.Output "Number of strings before update: " & Str(TransList. StringCount) End Sub Public Sub PSL_AfterUpdateTransList(TransList As PslTransList, ByVal Error As Boolean) PSL.Output "Number of strings after update: " & Str(TransList.StringCount) End Sub

SDL Passolo Automation 111 0 Reference

PassoloApp.BeforeAlignTarget

Event handler for the event BeforeAlignTarget. This event is raised, before a transation list is aligned by scanning the target file.

Syntax BeforeAlignTarget (TransList as PslTransList, Abort as Boolean) as void TransList the translation list that is currently aligned Abort Setting this value to True aborts the current operation.

PassoloApp.BeforeCheckTransList

This event handler is called, before translation list is checked.

Syntax BeforeCheckTransList (TransList as PslTransList, Abort as Boolean) as void TransList The translation list to be checked Abort Setting this value to True aborts the current operation.

PassoloApp.BeforeGenerateTarget

Event handler for the before generate target file event.

Syntax BeforeGenerateTarget (TransList as PslTransList, Abort as Boolean) as void TransList the translation list to be used for generating the target file Abort Setting this value to True aborts the current operation.

Example

Dim stored_size As Long Public Sub PSL_BeforeGenerateTarget(TransList As PslTransList, Abort As Boolean) stored_size = 0 On Error Resume Next ' Maybe the file does not exist yet stored_size = FileLen(TransList.TargetFile) End Sub Public Sub PSL_AfterGenerateTarget(TransList As PslTransList, ByVal Error As Boolean) If Not Error And stored_size <> 0 Then diff = FileLen(TransList.TargetFile) - stored_size If diff = 0 Then PSL.Output "Size of target file did not change." ElseIf diff > 0 Then PSL.Output "Target file increased by " & Str(diff) & " bytes." Else

112 SDL Passolo Automation Reference 0

PSL.Output "Target file decreased by " & Str(-diff) & " bytes." End If End If End Sub

PassoloApp.BeforeUpdateSourceList

Event handler for the before update source list event.

Syntax BeforeUpdateSourceList (SourceList as PslSourceList, Abort as Boolean) as void SourceList The source list to be updated Abort Setting this value to True aborts the current operation.

Example

Public Sub PSL_BeforeUpdateSourceList(SourceList As PassoloA.PslSourceList, Abort As Boolean) PSL.Output "Number of strings before update: " & Str(SourceList. StringCount) End Sub Public Sub PSL_AfterUpdateSourceList(SourceList As PslSourceList, ByVal Error As Boolean) PSL.Output "Number of strings after update: " & Str(SourceList. StringCount) End Sub

PassoloApp.BeforeUpdateTransList

Event handler for the before update trans list event.

Syntax BeforeUpdateTransList (TransList as PslTransList, Abort as Boolean) as void TransList The translation list to be updated Abort Setting this value to True aborts the current operation.

Example

Public Sub PSL_BeforeUpdateTransList(TransList As PslTransList, Abort As Boolean) PSL.Output "Number of strings before update: " & Str(TransList. StringCount) End Sub Public Sub PSL_AfterUpdateTransList(TransList As PslTransList, ByVal Error As Boolean) PSL.Output "Number of strings after update: " & Str(TransList.StringCount)

SDL Passolo Automation 113 0 Reference

End Sub

PassoloApp.OnAutoTranslate

This event handler is called when a string needs to be auto-translated. PslTranslations.SourceString contains the string to be translated. PslTranslations.Add can be used to add translations for PslTranslations.SourceString.

Syntax OnAutoTranslate (Translations as PslTranslations, MinMatch as long, MaxCount as long) as void Translations The PslTranslations object. MinMatch Specifies the minimum percent match required. A value of 100 stands for an exact match. MaxCount Specifies the maximum number of translations to be returned.

Example

Public Sub PSL_OnAutoTranslate(Translations As PslTranslations, ByVal MinMatch As Long, ByVal MaxCount As Long) ' Always translate "OK" to "OK" If Translations.SourceString = "OK" Then Translations.Add("OK", "OK",100, "System Macro") End If End Sub

PslTranslation.SourceString PslTranslations.Add Object PslTranslations

PassoloApp.OnCheckString

This event handler is called for every string in a translation list when a list get checked. The event handler should validate the TransString and calls the PslTransString.OutputError method to output an error to the log window of SDL Passolo. Internal errors and error issued by OnCheckString will occur in sequence.

Syntax OnCheckString (TransString as PslTransString) as void TransString A PslTransString to be checked PslTransString.OutputError Object PslTransString

114 SDL Passolo Automation Reference 0

PassoloApp.OnCloseProject

Event handler for the close project event

Syntax OnCloseProject (Project as PslProject) as void Project the project closed.

PassoloApp.OnCloseSourceList

Event handler for the close source list event

Syntax OnCloseSourceList (SourceList as PslSourceList) as void SourceList the source list closed

PassoloApp.OnCloseTransList

Event handler for the close translation list event.

Syntax OnCloseTransList (TransList as PslTransList) as void TransList the translation list closed

PassoloApp.OnEditSourceString

This event handler is called when a source string has been modified.

Syntax OnEditSourceString (SourceString As PslSourceString) SourceString The sourced string that has been modified

PassoloApp.OnEditTransString

This event handler is called when a source string has been modified.

SDL Passolo Automation 115 0 Reference

Syntax OnEditTransString (TransString As PslTransString) TransString The translation string that has been modified

PassoloApp.OnEndScript

This event handler is called when the script ends.

PassoloApp.OnFilterSourceString

When filtering the display of a source list, this handler is called once for each source string. The handler can decide if the source string should be in the filtered view or not.

Syntax OnFilterSourceString (SourceString As PslSourceString, ByVal FilterString As String, Display As Boolean) SourceString The sourced string to be examined FilterString The filter string from the Filter dialog Display Set to True if SourceString should be in the filter. Set to False otherwise.

Note:

To use this additional filter, the user has to check "Filter strings that pass custom filter check" in the filter dialog.

Strings are displayed only if they meet at least one of the standard conditions and pass the custom filter check

Example

REM This filters all strings that include a search text. REM The search text is entered in the Filter dialog. Public Sub PSL_OnFilterSourceString(SourceString As PslSourceString, ByVal FilterString As String, Display As Boolean) If InStr(1, SourceString.Text, FilterString) > 0 Then Display = True Else Display = False End If End Sub

116 SDL Passolo Automation Reference 0

PassoloApp.OnFilterTransString

When filtering the display of a translation list, this handler is called for each translation string. The handler can decide if the translation string should be in the filtered view or not.

Syntax OnFilterTransString (TransString As PslTransString, ByVal FilterString As String, Display As Boolean) Trans String The translation string to be examined FilterString The filter string from the Filter dialog Display Set to True if TransString should be in the filter. Set to False otherwise.

Note:

To use this additional filter, the user has to check "Filter strings that pass custom filter check" in the filter dialog.

Strings are displayed only if they meet at least one of the other conditions and pass the custom fiter check

Example

REM This filters all strings that include a search text. REM The search text is entered in the Filter dialog. Public Sub PSL_OnFilterTransString(TransString As PslTransString, ByVal FilterString As String, Display As Boolean) If InStr(1, TransString.Text, FilterString) > 0 Then Display = True Else Display = False End If End Sub

PassoloApp.OnHotkey[n]

This event handler is called when 1-9 has been pressed.

Syntax OnHotkey1 as void

SDL Passolo Automation 117 0 Reference

PassoloApp.OnOpenProject

Event handler for the open project event

Syntax OnOpenProject (Project as PslProject) as void Project the project opened

PassoloApp.OnOpenSourceList

Event handler for the open source list event

Syntax OnOpenSourceList (SourceList as PslSourceList) as void SourceList the source list opened

PassoloApp.OnOpenTransList

Event handler for the open translation list event.

Syntax OnOpenTransList (TransList as PslTransList) as void TransList the translation list opened

PassoloApp.OnProcessUserFile

This handler is called in order to process file formats which are not supported by SDL Passolo itself. Implementing this handler, makes it possible to process text files like Java Property files or databases. The object ResData is used to exchange data with Passolo.

In the Programmers Reference you find a complete example which demonstrates the processing of INI-files. For further information refer to object PslResData.

Syntax OnProcessUserFile (ResData as PslResData) ResData This object is used to exchange data with the Passolo application. Object PslResData

118 SDL Passolo Automation Reference 0

PassoloApp.OnSimulateTranslation

This event handler is called when a string needs to be pseudo-translated.

Syntax OnSimulateTranslation (SourceString as PslSourceString, Text as String, X as Long, Y as Long, Cx as Long, Cy as Long, Handled as Long) as void SourceString String of type PslSourceString to be pseudo-translated Text Destination string Text. To contain the pseudo translation to Text X The new X coordinate for the simulated translation (for dialog controls) Y The new Y coordinate for the simulated translation (for dialog controls) Cx The new Cx coordinate for the simulated translation (for dialog controls) Cy The new Cy coordinate for the simulated translation (for dialog controls) Handled Set to True, if OnAutoTranslate has handled the translation. If not set, the SDL Passolo algorithm for pseudo-translation will be used. Object PslSourceString

PassoloApp.OnSizeToContent

SDL Passolo fires this event after a "size to content" operation on a dialog control.

Syntax OnSizeToContent (TransString as PslTransString, PrevWidth as Long, PrevHeight as Long) TransString The translation string, which is resized PrevWidth The width of the control before it has been resized PrevHeight The height of the control before it has been resized

Example

Public Sub PSL_OnSizeToContent(TransString As PslTransString, PrevWidth As Long, PrevHeight As Long) ' Get the current position Dim x1 As Long, y1 As Long, cx1 As Long, cy1 As Long Dim x2 As Long, y2 As Long, cx2 As Long, cy2 As Long TransString.GetSourceRect(x1,y1,cx1,cy1) TransString.GetRect(x2,y2,cx2,cy2) ' Prevent the control from beeing resized smaller ' than the orignal size If cx2 < cx1 Then cx2 = cx1 If cy2 < cy1 Then cy2 = cy1 TransString.SetRect(x2,y2,cx2,cy2) End Sub

SDL Passolo Automation 119 0 Reference

PassoloApp.OnStartScript

This event handler is called when the script is started. Object PslAppStatus

This object displays a status text in the lower left of the application window. The display can also contain a progress bar and an abort hint.

The object is created with PassoloApp.ShowAppStatus. PassoloApp.ShowAppStatus

Methods

PslAppStatus.Step

If the status displays has a progress bar, use this function to increase the current progress position by 1.

Syntax Expression.Step Expression Object of type PslAppStatus

Properties

PslAppStatus.Aborted

Returns True, if the status display offers an abort feature and the user has clicked the Pause key.

Syntax Expression.Aborted as Boolean Expression Object of type PslAppStatus

120 SDL Passolo Automation Reference 0

PslAppStatus.ProgressMax

Returns the maximum value of the value range in the progress bar.

Syntax Expression.ProgressMax as Long Expression Object of type PslAppStatus

PslAppStatus.ProgressMin

Returns the maximum value of the value range in the progress bar.

Syntax Expression.ProgressMin as Long Expression Object of type PslAppStatus

PslAppStatus.ProgressPos

Returns the current position of the progress bar. This is always between ProgressMin and ProgressMax.

Syntax Expression.ProgressPos as Long Expression Object of type PslAppStatus PslAppStatus.ProgressMin PslAppStatus.ProgressMax

PslAppStatus.Text

Returns the current text of the status display.

Syntax Expression.Text as String Expression Object of type PslAppStatus Object PslGlossaries

This object contains a list of glossaries.

SDL Passolo Automation 121 0 Reference

Methods

PslGlossaries.Add

Adds a glossary to the collection of glossaries. If successful the function returns the glossary as a PslGlossary object.

Syntax Expression.Add (FileName as String) as PslGlossary Expression Object of type PslGlossaries Filename file name of the glossary Object PslGlossary

PslGlossaries.Item

Item returns a PslGlossary contained in the collection. The glossary can be specified by its index or its title. Item is the standard function, so the Name can also be omitted.

Syntax Expression.Item (Index as Variant) as PslGlossary Expression Object of type PslGlossaries Index Index of glossary Object PslGlossary

PslGlossaries.Remove

Removes a glossary. The glossary can be specified by its index or its filename.

Syntax Expression.Remove (Index as Variant) as void Expression Object of type PslGlossaries Index Index of the translation

122 SDL Passolo Automation Reference 0

Properties

PslGlossaries.Application

Returns the Application Object

Syntax Expression.Application as IDispatch Expression Object of type PslGlossaries

PslGlossaries.Count

Returns the number of glossaries.

Syntax Expression.Count as Long Expression Object of type PslGlossaries

PslGlossaries.Parent

Returns the Parent Object.

Syntax Expression.Parent as IDispatch Expression Object of type PslGlossaries Object PslGlossary

This object represents a glossary used in SDL Passolo either globally or for a specific project.

Methods

SDL Passolo Automation 123 0 Reference

PslGlossary.CreateQuickIndex

Creates the glossary's QuickIndex.

Syntax Expression. CreateQuickIndex (Wait as Boolean) Expression Object of type Psl Glossary Wait True = the functions returns after the index has been created. False = the function return immedi- ately and the index is created in background. PslGlossary.QuickIndexState

Properties

PslGlossary.Application

Returns the Application Object

Syntax Expression.Application as IDispatch Expression Object of type PslGlossary

PslGlossary.Disabled

Returns or sets the 'disabled' state of the glossary.

Syntax Expression.Disabled as Boolean Expression Required. Object of type PslGlossary

Example

' Disable all global glossaries Dim gloss As PslGlossary For Each gloss In PSL.Glossaries gloss.Disabled = True Next gloss

124 SDL Passolo Automation Reference 0

PslGlossary.FileName

Contains the file name of the glossary.

Syntax Expression.FileName as String Expression Required. Object of type PslGlossary

PslGlossary.IsEmbedded

Returns True the glossary is embedded in a translation bundle, read-only property.

Syntax Expression.IsEmbedded as Boolean Expression Required. Object of type PslGlossary

PslGlossary.Parent

Returns the PSLGlosssaries object, which is the parent of this glossary.

Syntax Expression.Parent as IDispatch Expression Object of type PslGlossary Object PslGlossaries

PslGlossary.QuickIndexState

Returns the state of th is glossary's quick index. Read-only property.

Syntax Expression. QuickIndexState as PslQuickIndexState Expression Required. Object of type Psl Glossary

Return Values pslQuickIndexNoIndex value = 1, no index is available pslQuickIndexIndexing value = 2, the index is currently being created pslQuickIndexIndexedOK value = 3, the index is available and valid pslQuickIndexIndexedInvalid value = 4, the index is available but outdated pslQuickIndexError value = 5, the index could not be created

SDL Passolo Automation 125 0 Reference

Object HistoryItem

This object represents a single entry in the history list of a string.

Methods

PslHistoryItem.GetRect

Returns the coordinates of the history item (if it is a dialog control). The coordinates are always returned in dialog units.

Syntax Expression.GetRect (X as LONG, Y as LONG, Cx as LONG, Cy as LONG) as Boolean Expression Object of type PslHistoryItem Xx coordinate Yx coordinate Cx width Cy height

Properties

PslHistoryItem.Comment

Returns the translation comment of this history item. The comment is only set, if it has been changed at this history item.

Syntax Expression.Comment as String Expression Object of type PslHistoryItem

126 SDL Passolo Automation Reference 0

Example

Sub HandleTransString(t As PslTransString) Dim item As PslHistoryItem For Each item In t.History If item.State(pslHistoryCommentChanged) Then PSL.Output "At " & CStr(item.Date) & " " & item.UserName _ & " changed the comment to """ & item.Comment & """" End If Next item End Sub

PslHistoryItem.Date

Returns the date of this history item.

Syntax Expression.Date as Date Expression Object of type PslHistoryItem

Example

Sub HandleTransString(t As PslTransString) Dim item As PslHistoryItem For Each item In t.History If item.State(pslHistoryTextChanged) Then PSL.Output "At " & CStr(item.Date) & " " & item.UserName _ & " changed the text to """ & item.Text & """" End If Next item End Sub

PslHistoryItem.Property

Returns a custom property of the history item.

Syntax Expression.Property (Name as Variant) as Variant Expression Object of type PslHistoryItem Name Name of the property PslTransString.Property

SDL Passolo Automation 127 0 Reference

PslHistoryItem.State

Returns a status bit of the history item.

Syntax

Expression.State (Name as Variant) as Boolean Expression Object of type PslHistoryItem Name Name of the status value. The following values are possible: pslHistoryTextChanged (Value = 1): The text of the translation string has been changed pslHistoryStateChanged (Value = 2): A status bit (translated, for review...) has been changed pslHistoryCoordChanged (Value = 4): The coordinates of a dialog control have been changed pslHistoryCommentChanged (Value = 8): The translation comment has been changed pslHistoryPropertiesChanged (Value = 32): The custom properties have been changed pslHistoryFromCreate (Value = 4096): This history item marks the creation of the string pslHistoryFromUpdate (Value = 8192): This history item is from an update of the string list pslHistoryFromAlign (Value = 16384): This history item is from an alignment operation pslHistoryFromLeverage (Value = 32768): This history item is from a leverage operation pslHistoryFromImport (Value = 256): This history item is from an import operation pslHistoryFromEdit (Value = 512): This history item is from editing the string (or has been changed from a macro) Example

Sub HandleTransString(t As PslTransString) Dim item As PslHistoryItem For Each item In t.History If item.State(pslHistoryTextChanged) Then PSL.Output "At " & CStr(item.Date) & " " & item.UserName _ & " changed the text to """ & item.Text & """" End If Next item End Sub

PslHistoryItem.Text

Returns the string text of this history item.

128 SDL Passolo Automation Reference 0

Syntax Expression.Text as String Expression Object of type PslHistoryItem

Example

Sub HandleTransString(t As PslTransString) Dim item As PslHistoryItem For Each item In t.History If item.State(pslHistoryTextChanged) Then PSL.Output "At " & CStr(item.Date) & " " & item.UserName _ & " changed the text to """ & item.Text & """" End If Next item End Sub

PslHistoryItem.UserName

Returns the name of the user who caused this history item.

Syntax Expression.UserName as String Expression Object of type PslHistoryItem

Example

Sub HandleTransString(t As PslTransString) Dim item As PslHistoryItem For Each item In t.History If item.State(pslHistoryTextChanged) Then PSL.Output "At " & CStr(item.Date) & " " & item.UserName _ & " changed the text to """ & item.Text & """" End If Next item End Sub

Object HistoryItems

This object represents an collection of history items of a string.

SDL Passolo Automation 129 0 Reference

Properties

PslHistoryItems.Count

Returns the number of entries in this PslHistoryItems collection.

Syntax Expression.Count as Integer Expression Object of type PslHistoryItems

Example

Sub HandleTransString(t As PslTransString) Dim count As Integer count = t.History.Count Dim i As Integer For i = 1 To count Dim item As PslHistoryItem Set item = t.History(i) If item.State(pslHistoryTextChanged) Then PSL.Output "At " & CStr(item.Date) & " " & item.UserName _ & " changed the text to """ & item.Text & """" End If Next i End Sub

Note: You can also us a For Each statement.

PslHistoryItem.Text

PslHistoryItems.Item

Item returns an entry contained in the PslHistoryItems collection. The item is indicated by its index (1,...) or a date. Item is the standard function, so the name can be omitted.

Syntax Expression.Item (Index as Variant )as PslHistoryItem Expression Object of type PslHistoryItems Index The index of the task. The first task has the index 1. Index can also be a DATE object. Then the function returns the last history before this date.

130 SDL Passolo Automation Reference 0

Example

Sub HandleTransString(t As PslTransString) Dim d As Date d = DateSerial(2008, 11, 10) + TimeSerial(12, 0, 0) Dim item As PslHistoryItem Set item = t.History(d) If Not item Is Nothing Then PSL.Output "At " & CStr(d) & " the text was " _ & """" & item.Text & """" End If End Sub

Object PslLanguage

PslLanguage represents a language in SDL Passolo.

Properties

PslLanguage.GetStatistics

Returns statistical information about the all translation lists in the project that belong to this target language. The data is returned as a PslStatistics object. The returned numbers are not necessarily the same as the sums of PslTransList.GetStatistics, because the replicates are calculated over the whole project.

Synax Expression.GetStatistics as PslStatistics Expression Required. Object of type PslLanguage Object PslStatistics PslTransList.GetStatistics

PslLanguage.LangCode

Returns the corresponding language code.

Syntax

Expression.LangCode as String Expression Required. Object of type PslLanguage

SDL Passolo Automation 131 0 Reference

PslLanguage.LangID

Returns the corresponding language ID.

For a full list of the language IDs, consult the Online Help.

Syntax Expression.LangID as Integer Expression Required. Object of type PslLanguage

PslLanguage.Option

Returns or changes some options of the target language.

Syntax Expression.Option (Name as Long) as Variant Expression Required. Object of type PslLanguage Name Specifies the option to read or change. It can be one of these values: pslOptionActualCodepage (Value = 4): The codepage for converting strings from unicode to DBCS. pslOptionCodepage (Value = 2): The codepage for converting strings from unicode to DBCS. If the default codepage of the language is used, this option returns 0. pslOptionFont (Value = 3): Returns the font which is used to display the translation strings. This has the format ",", i.e. "Arial,9". An empty font string stands for the system (default) font. pslOptionLangID (Value = 1): Returns the language ID of the language. Same as PslLanguage. LangID

PslLanguage.Project

Returns the corresponding PslProject object, read-only property.

Syntax Expression.Project as PslProject Expression Required. Object of type PslLanguage Object PslProject

132 SDL Passolo Automation Reference 0

PslSourceList.Properties

Returns the PslProperties object that contains all custom properties of this PslLanguage.

Syntax Expression.Properties as PslProperties Expression Object of type PslLanguage Object PslProperties

PslSourceList.Property

Returns a custom property of the language. Custom properties are defined by add-ins or macros.

Syntax Expression.Property (Name as Variant) as Variant Expression Object of type PslLanguage Name Name of the property. If the macro sets a new value, the property name must be between 10000 and 19999 or start with "M:" (see below)

Custom Properties

Custom Properties can be defined by parser add-ins, a macro or the user. All properties are in the same list, so they all can be accessed. To distinguish the types, different property names are used. When setting a property the macro is responsible for using the correct name, otherwise the property may be removed when updating string lists.

Type Integer Name String Name Add-In properties 1 - 9999 No prefix Macro properties 10000 - 19999 Uses prefix "M:" User-defined properties 20000 - 30000 Uses prefix "U:"

Example

Dim lang As PslLanguage Set lang = PSL.ActiveTransList.Language If not lang Is Nothing Then lang.Property(10001) = "Hello!" psl.Output(lang.Property(10001)) End If

SDL Passolo Automation 133 0 Reference

PslLanguage.StringCount

Returns the sum of strings for all translation lists of that language.

Syntax Expression.StringCount (optional Type as VARIANT) as Long Expression Object of type PslLanguage Type Can be one of the following values: pslTotal (Value = 100): Returns the total number of strings. pslToTranslate (Value = 101): Returns that number of strings that need to be translated. This is pslTotal minus empty strings and strings that don't need to be translated, e.g. hidden or read-only strings. pslTranslated (Value = 102): Returns that number of strings that are translated, including pre-translated and for-review strings (green, blue, black). pslForReview (Value = 103): Returns that number of strings that are pre-translated or marked for-review (green, blue). pslUntranslated (Value = 104): Returns that number of strings that are not translated (red). pslValidated (Value = 105): Returns that number of strings that are translated and validated (black).

PslLanguage.WordCount

Returns the sum of words for all translation lists of that language.

Syntax Expression.WordCount (optional Type as VARIANT) as Long Expression Object of type PslLanguage Type Can be one of the following values: pslTotal (Value = 100): Returns the total number of words. pslToTranslate (Value = 101): Returns that number of words that need to be translated. This is pslTotal minus empty strings and strings that don't need to be translated, e.g. hidden or read-only strings. pslTranslated (Value = 102): Returns that number of words that are translated, including pre-translated and for-review strings (green, blue, black). pslForReview (Value = 103): Returns that number of words that are pre-translated or marked for-review (green, blue). pslUntranslated (Value = 104): Returns that number of words that are not translated (red). pslValidated (Value = 105): Returns that number of words that are translated and validated (black).

134 SDL Passolo Automation Reference 0

Object PslLanguages

PslLanguages contains the list of target languages used in a project.

Methods

PslLanguages.Add

This method adds a new target language to the project.

Syntax Expression.Add (LangID as Variant) as PslLanguage Expression Object of type PslLanguages LangID Specifies the new language. It can be either the language ID or the language code.

PslLanguages.AddLangCode

This method adds a new target language to the project. Unlike PslLanguages.Add the language is given by a defined language code type.

Syntax Expression.Add (Code as String, Type as Variant) as PslLanguage Expression Object of type PslLanguages Code String, Language code Type Variant, pslCodeUnknown (default, Value = -1): interprets LangCode as any of the codes below pslCodeWin (Value = 0): interprets LangCode as used by Windows. See appendix of the PASSOLO Reference Manual. pslCode639_2B (Value = 1): interprets LangCode as ISO 639 3-letter code (Bibliography) pslCode639_2T (Value = 2): interprets LangCode as ISO 639 3-letter code (Terminology) pslCode639_1 (Value = 3): interprets LangCode as ISO 639 2-letter code pslCodeISO (Value = 4): interprets LangCode as ISO 639 3-letter code or ISO 639 2-letter code if available pslCode3166_2 (Value = 5): interprets LangCode as ISO 3166 2 3-letter code pslCode3166_1 (Value = 6): interprets LangCode as ISO 3166 2 2-letter code pslCodeWinRgn (Value = 7): interprets LangCode as Windows 3-letter code

SDL Passolo Automation 135 0 Reference

pslCodeLangRgn (Value = 8): interprets LangCode as combined ISO language - region/country code pslCodeHex (Value = 9): interprets LangCode as hex values. If LangCode defines only the primary language id, the default region is returned. E.g. "09" returns 1033 (pslLangEnglishUSA) pslCodeHex2 (Value = 10): interprets LangCode as hex values. If LangCode defines only the primary language id, no region is returned. E.g. "09" returns 9 (Language id for English without region) pslCodeText (Value = 11): interprets LangCode as localized name of the language (country/region). This depends of the language of the SDL Passolo user interface. pslCodeEnglishText (Value = 12): interprets LangCode English name of the language (country/region) pslCodeDecimal (Value = 13): interprets LangCode as decimal value of the LangID pslCodeSDLX (Value = 14): interprets LangCode as SDLX language code pslCodeTrados (Value = 15): interprets LangCode as SDL Trados language code PslLanguages.Add

PslLanguages.FindLangCode

This method finds a PslLanguage in the project. The language is given by a defined language code type.

Syntax Expression.FindLangCode (Code as String, Type as Variant, Index as Integer) as PslLanguage Expression Object of type PslLanguages Code String, Language code Type Variant, pslCodeUnknown (default, Value = -1): interprets LangCode as any of the codes below pslCodeWin (Value = 0): interprets LangCode as used by Windows. See appendix of the SDL Passolo Reference Manual. pslCode639_2B (Value = 1): interprets LangCode as ISO 639 3-letter code (Bibliography) pslCode639_2T (Value = 2): interprets LangCode as ISO 639 3-letter code (Terminology) pslCode639_1 (Value = 3): interprets LangCode as ISO 639 2-letter code pslCodeISO (Value = 4): interprets LangCode as ISO 639 3-letter code or ISO 639 2-letter code if available pslCode3166_2 (Value = 5): interprets LangCode as ISO 3166 2 3-letter code pslCode3166_1 (Value = 6): interprets LangCode as ISO 3166 2 2-letter code pslCodeWinRgn (Value = 7): interprets LangCode as Windows 3-letter code pslCodeLangRgn (Value = 8): interprets LangCode as combined ISO language - region/country code pslCodeHex (Value = 9): interprets LangCode as hex values. If LangCode defines only the primary language id, the default region is returned. E.g. "09" returns 1033 (pslLangEnglishUSA) pslCodeHex2 (Value = 10): interprets LangCode as hex values. If LangCode defines only the primary language id, no region is returned. E.g. "09" returns 9 (Language id for English without region)

136 SDL Passolo Automation Reference 0

pslCodeText (Value = 11): interprets LangCode as localized name of the language (country/region). This depends of the language of the Passolo user interface. pslCodeEnglishText (Value = 12): interprets LangCode English name of the language (country/region) pslCodeDecimal (Value = 13): interprets LangCode as decimal value of the LangID pslCodeSDLX (Value = 14): interprets LangCode as SDLX language code pslCodeTrados (Value = 15): interprets LangCode as SDL Trados language code Index Integer, If the project contains more than one matching language, the Index defines which matching language should be returned. 1 finds the first matching language. Object PslLanguage

PslLanguages.FindLangID

This method finds a PslLanguage in the project. The language is given by a language ID.

Syntax Expression.Add (LangID as Integer, Index as Integer) as PslLanguage Expression Object of type PslLanguages LangID Integer, Language ID as defined in the appendix of the SDL Passolo Reference Manual and used in Passolo to define source and target languages. Index Integer, If the project contains more than one matching languages, the Index defines which matching language should be returned. 1 finds the first matching language. Object PslLanguage

PslLanguages.Item

Item returns a language contained in the PslLanguages collection. The language can be specified by the index (1,...), the language ID or the language code. Item is the default method, so the name can be omitted.

Syntax Expression.Item (Index as Variant) PslLanguage Expression Required. Object of type PslLanguages Index Variant, Required. Specifies the index (1, 2,...), the language code ("enu", "deu",...), or an object of type PslLanguage

SDL Passolo Automation 137 0 Reference

Example

Dim lan As PslLanguages Set lan = PSL.Projects(1).Languages("deu")

PslLanguages.Remove

This method deletes a target language from the project. Additionally all corresponding translation lists will be deleted.

Syntax Expression.Remove (Index as VARIANT) Expression Required. Object of type PslLanguages Index Variant, Required. Specifies the language to delete. It can be either the index of the language (1,2,...), the language code ("enu", "deu", ...) or an object of type PslLanguage

Properties

PslLanguages.Application

Returns the PassoloApp-Object, read-only property.

Syntax Expression.Application as PassoloApp Expression Required. Object of type PslLanguages Object PassoloApp

PslLanguages.Count

Returns the number of target languages of the project.

Syntax Expression.Count as Long Expression Object of type PslLanguages

138 SDL Passolo Automation Reference 0

Example

Dim prj As PslProject Set prj = PSL.Projects(1) PSL.Output "The project has got " & Str(prj.Languages.Count) & " target languages."

PslLanguages.Parent

Returns the corresponding PslProject object, read-only property.

Syntax Expression.Parent as PslProject Expression Required. Object of type PslLanguages Object PslProject Object PslOutputWnd

This object accesses the messages, check or find page in the SDL Passolo output window. PassoloApp. OutputWnd

Methods

PslOutputWnd.Clear

Clears the Output window.

Syntax Expression.Clear Expression Object of type PslOutputWnd

Properties

SDL Passolo Automation 139 0 Reference

PslOutputWnd.JumpError

If the type of a text line is pslOutputJump, this property returns the associated error number.

Syntax Expression.JumpError (Line as Long) as Long Expression Object of type PslOutputWnd Line The line number, the first line has the number 1

Syntax

Dim trn As PslTransList Dim trn As PslTransList Set trn = PSL.ActiveTransList If trn Is Nothing Then Exit Sub ' Perform check on active translation list trn.Check Dim checkwnd As PslOutputWnd Set checkwnd = PSL.OutputWnd(pslOutputWndCheck) Dim Line As Long For Line = 1 To checkwnd.LineCount If checkwnd.Type(Line) = pslOutputJump And _ checkwnd.JumpError(Line) = 301 Then ' Mark translation string Dim t As PslTransString Set t = trn.String(checkwnd.JumpNumber(Line), pslNumber) t.TransComment = "TODO: Resize" End If Next Line trn.Save

PslOutputWnd.JumpNumber

If the type of a text line is pslOutputJump, this property returns the number of the refered string.

Syntax Expression.JumpNumber (Line as Long) as String Expression Object of type PslOutputWnd Line The line number, the first line has the number 1

140 SDL Passolo Automation Reference 0

Example

Dim trn As PslTransList Dim trn As PslTransList Set trn = PSL.ActiveTransList If trn Is Nothing Then Exit Sub ' Perform check on active translation list trn.Check Dim checkwnd As PslOutputWnd Set checkwnd = PSL.OutputWnd(pslOutputWndCheck) Dim Line As Long For Line = 1 To checkwnd.LineCount If checkwnd.Type(Line) = pslOutputJump And _ checkwnd.JumpError(Line) = 301 Then ' Mark translation string Dim t As PslTransString Set t = trn.String(checkwnd.JumpNumber(Line), pslNumber) t.TransComment = "TODO: Resize" End If Next Line trn.Save

PslOutputWnd.JumpTarget

If the type of a text line is pslOutputJump, this property returns the PslSourceList or the PslTransList which contains the referred string.

Syntax Expression.JumpTarget (Line as Long) as Object Expression Object of type PslOutputWnd Line The line number, the first line has the number 1. Object PslSourceList Object PslTransList

PslOutputWnd.LineCount

Returns the number of lines in the output window.

Syntax Expression.LineCount as Long Expression Object of type PslOutputWnd

SDL Passolo Automation 141 0 Reference

Example

Dim trn As PslTransList Dim trn As PslTransList Set trn = PSL.ActiveTransList If trn Is Nothing Then Exit Sub ' Perform check on active translation list trn.Check Dim checkwnd As PslOutputWnd Set checkwnd = PSL.OutputWnd(pslOutputWndCheck) Dim Line As Long For Line = 1 To checkwnd.LineCount If checkwnd.Type(Line) = pslOutputJump And _ checkwnd.JumpError(Line) = 301 Then ' Mark translation string Dim t As PslTransString Set t = trn.String(checkwnd.JumpNumber(Line), pslNumber) t.TransComment = "TODO: Resize" End If Next Line trn.Save

PslOutputWnd.Text

Returns the text of a line in the output window.

Syntax Expression.Text (Line as Long) as String Expression Object of type PslOutputWnd Line The line number, the first line has the number 1

PslOutputWnd.Type

Returns the type of a line in the output window. pslOutputText (value = 0) The line contains a simple text output pslOutputError (value = 1) The line contains an error message pslOutputJump (value = 2) The line contains text with a 'jump', i.e. the user can doubleclick the line to select a string.

Syntax Expression.Type (Line as Long) as Long Expression Object of type PslOutputWnd Line The line number, the first line has the number 1

142 SDL Passolo Automation Reference 0

Example

Dim trn As PslTransList Dim trn As PslTransList Set trn = PSL.ActiveTransList If trn Is Nothing Then Exit Sub ' Perform check on active translation list trn.Check Dim checkwnd As PslOutputWnd Set checkwnd = PSL.OutputWnd(pslOutputWndCheck) Dim Line As Long For Line = 1 To checkwnd.LineCount If checkwnd.Type(Line) = pslOutputJump And _ checkwnd.JumpError(Line) = 301 Then ' Mark translation string Dim t As PslTransString Set t = trn.String(checkwnd.JumpNumber(Line), pslNumber) t.TransComment = "TODO: Resize" End If Next Line trn.Save

Object PslProject

PslProject represents a project in SDL Passolo with its source string lists, translation lists, languages and glossaries.

Methods

PslProject.AddTargetPathRule

Adds a new target path rule to the project. Use PslSourceList. SetTargetPathRule and PslTransList. SetTargetPathRule to assign the rule to string lists.

Syntax Expression.AddTargetPathRule (Name as String, Path as String, SubPath as String, FileName as String, [optional] Description as String) as Long Expression Object of type PslProject Name Name of the target path rule Path Base path of the target path rule SubPath Sub path, this is appended to the base path RelSrcPath Relative source path builds a folder structure for the target files according to the relation of the source file to a reference folder. FileName Target file name Description optional, a description of the target path rule

SDL Passolo Automation 143 0 Reference

Returns the ID of the new target path rule. The parameters Name, SubPath, RelSrcPath and FileName can use these placeholders:

Placeholder Description Example Numerical language ID, "0C" hexadecimal Numerical language ID, decimal 1036 Windows language code "fra" Language/region code "fr-FR" ISO 639-1 code "fr" ISO 639-2 code, bibliographic "fre" ISO 639-2 code, terminological "fra" Language name in current "Französisch (Frankreich)" Passolo language English Language Name "French (France)" Project folder "c:\MyProject" Source file folder "c:\Sources" Source file name "Example.exe" Source file title (source file name "Example" without extension) Source file extension "exe"

Example

Sub Main ' Create a new project Dim prj As PslProject Set prj = PSL.Projects.Add("scribble", "c:\projects") ' Add a source list Dim src As PslSourceList Set src = prj.SourceLists.Add("c:\projects\scribble.exe") ' Add a target path rule for creating resource DLLs Const SubDir As String = \..\..\> Dim idRule As Long idRule = prj.AddTargetPathRule("Resource DLL", "", "", ".dll") ' Assign the rule to the source list src.SetTargetPathRule(idRule, True, "") ' Add a target language, the new translation list ' will use the rule that has been asigned to the source list prj.Languages.Add(pslLangGerman) End Sub

PslSourceList.SetTargetPathRule PslTransList.SetTargetPathRule

144 SDL Passolo Automation Reference 0

PslProject.BaseLanguage

If this project is cascaded BaseLanguage returns the target language id in the base project file. This property can only be set, if the project is cascaded.

Syntax Expression.BaseLanguage as Integer Expression Required. Object of type PslProject PslProject.BaseProject

PslProject.BaseProject

If this project is cascaded BaseProject returns the path of base project file. This property can only be set, if the project is cascaded or it does not already contain source files.

Syntax Expression.BaseProject as String Expression Required. Object of type PslProject

PslProject.Close

Closes the project. After the project is closed most functions of the project object will return an error message.

Syntax Expression.Close (Savechanges as Variant) Expression Required. Object of type PslProject Savechanges Variant, optional. Specifies the method of handling string lists, which were changed but not yet saved. The following values are possible: pslSaveChanges (default, Value = 0) : All changed string lists will be saved pslPromptToSaveChanges (Value = 1): Messages will be displayed, so that the user can decide, if he wants to save a string list or not. pslPromptWithCancel (Value = 2): Messages will be displayed similar to pslPromptToSaveChanges. Additionally the messages will contain a [Cancel]-Button, so that the User can stop closing the project. pslDoNotSaveChanges (Value = 3): The string lists will be closed without saving the changes.

SDL Passolo Automation 145 0 Reference

Example

Dim prj As PslProject Set prj = PSL.Projects(1) prj.Close PSL.Output("The first project was closed")

PslProject.CreateQuickIndex

Creates the project QuickIndex.

Syntax Expression. CreateQuickIndex (Wait as Boolean) Expression Object of type PslProject Wait True = the functions returns after the index has been created. False = the function retunrn immediately and the index is created in background.

PslProject.Export

Exports one or more string lists to a specified file. If the export functions has options, the last options set manually will be used for the export. Returns True, if the operation was successful. False indicates an error.

This function does not create translation bundles. It uses a PslTransBundle object only to collect multiple string lists for export. Use PslProject.ExportTransBundle to export a translation bundle.

Syntax Expression.Export (Format as String, TransBundle as PslTransBundle, FileName as String, Range as Variant) as Boolean Expression Required. Object of type PslTransList Format Identifier of the add-in which is used for export. The add-in list in SDL Passolo displays the identifier of each add-in. These are the add-ins that are shipped with Passolo: "Glossary Export" "PASSOLO Glossary Maker" "TMX Export" "STAR TermStar Export" "TRADOS MultiTerm" "TRADOS MultiTerm iX" "PASSOLO Customizable Text Export" "SDL Passolo XML Export/Import"

146 SDL Passolo Automation Reference 0

"Trados Text Export" TransBundle Translation bundle object, which contains the string lists FileName Name of the export file Range One of these values expAll (default) - export all (undeleted) strings expAllDeleted - exports all strings including the deleted strings expDisplay - exports only displayed strings expSelected - exports only selected strings

Example

' Creates a text export file for each language Sub main Dim prj As PslProject Set prj = PSL.ActiveProject If prj Is Nothing Then Exit Sub Dim lang As PslLanguage For Each lang In prj.Languages ' Create the translation bundle Dim bundle As PslTransBundle Set bundle = prj.PrepareTransBundle Dim trn As PslTransList dim i as Integer For i = 1 to prj.TransLists.Count set trn = prj.TransLists(i) If trn.Language Is lang Then bundle.AddTransList(trn) End If Next i

' Make filename "test.tba/tbu" Dim filename As String filename = "c:\test\test" & lang.LangCode & ".txt" prj.Export "PASSOLO text format", bundle, filename Next lang End Sub

PslProject.ExportTransBundle

PslProject.ExportTransBundle

Creates translation bundle.

Syntax Expression.ExportTransBundle (TransBundle as PslTransBundle, FileName as String) as Boolean Expression Object of type PslProject TransBundle Translation bundle object, which contains the translation lists, glossaries and macros FileName Path and name of the exported translation bundle. SDL Passolo ensures that the file name has the right file extension:

SDL Passolo Automation 147 0 Reference

.tbu Translation bundle from Passolo .tbulic700 Licensed translation bundle from Passolo 2007

Note: If the bundle is split multiple files will be created. Passolo will add "_Part1","_Part2",... or "_Dialogs", "_NoDialogs" to the file title, depending on the split mode. E.g. if you split the bundle to 2 parts and FileName is "c:\test\test.tbu", Passolo will create "c:\test\test_Part1.tbu" and "c:\test\test_Part2.tbu".

Example

' Creates a translation bundle for each language Sub main Dim prj As PslProject Set prj = PSL.ActiveProject If prj Is Nothing Then Exit Sub Dim lang As PslLanguage For Each lang In prj.Languages ' Create the translation bundle Dim bundle As PslTransBundle Set bundle = prj.PrepareTransBundle Dim trn As PslTransList dim i as Integer For i = 1 to prj.TransLists.Count set trn = prj.TransLists(i) If trn.Language Is lang Then bundle.AddTransList(trn) End If Next i

' Add glossaries bundle.AddGlossary("c:\Glossaries\myglossary.glo") bundle.AddGlossary(PSL.Glossaries(1)) ' AddMacro bundle.AddMacro("PslCheckCPP.bas"); ' Make filename "test.tba/tbu" Dim filename As String filename = "c:\test\test" & lang.LangCode prj.ExportTransBundle bundle, filename Next lang End Sub

PslTransBundle.SplitBundle

PslProject.FindTargetPathRule

Returns the ID of a target path rule with a given name. With this function you cannot find target path rules, that are defined by parser add-ins.

Syntax Expression.FindTargetPathRule (Name as String) as Long Expression Object of type PslProject Name Name of the target path rule Returns the ID of the target path rule or 0 if now rule has been found.

148 SDL Passolo Automation Reference 0

Example

Sub Main End Sub

PslProject.Import

Imports data from an file that has been exported with PslProject.Export or PslTransList. Export.

Syntax Expression.Import(Format as String, FilePath as String, [optional] Flags as Variant) as PslTranslist Expression Required. Object of type PassoloApp Format Identifier of the add-in which is used for import. The add-in list in SDL Passolo displays the identifier of each add-in. These are the add-ins that are shipped with Passolo and be used for import: "PASSOLO translation bundle" (You can also use ImportTransBundle) "PASSOLO text format" "PASSOLO Customizable Text Export" "PASSOLO Customizable Text Export" "SDL Passolo XML Export/Import" "Trados Text Export" FilePath Path of the file to be imported Flags Some options to control the import. To combine flags, add the values: psl ImportValidate (Value = 256):Text-based imports only: The strings will be validated after importing the translation. psl ImportMerge (Value = 512): Translation bundles only: The translations in the bundle are merged with the existing translations in the project. If you are importing a licensed translation bundle, you can merge only if you use an unlimited Team Edition of Passolo. psl ImportRelease (Value = 1024): Translation bundles only: Imported string lists are released after import. If this flag is not set, the translation list in the project remains marked as "exported".

Example

Dim prj As PslProject Set prj = PSL.ActiveProject If prj Is Nothing Then Exit Sub If (Not prj.Import("PASSOLO text format", "c:\test_de.txt")) Then MsgBox PSL.GetLastOutput End If

PslProject.Export PslTransList.Export PslProject.ImportTransBundle

SDL Passolo Automation 149 0 Reference

PslProject.ImportBinaryResource

Imports a binary file (e.g a bitmap or icon) to its matching resource. The file to import must have a special name with internal numbers to find the matching translation list and resource. This file name is created when the resource has been exported, using ExportBinary without an explicit file name.

Syntax Expression.ImportBinaryResource (Path as String) as Boolean Expression Object of type PslProject Path Path of the file to import. This path can contain wildcards like in "*.*" or "*.bmp" to import multiple files in one go. Returns TRUE, if successful.

Example

' Imports all bitmaps from a folder to the current project Sub Main Dim prj As PslProject Set prj = PSL.ActiveProject If prj Is Nothing Then Exit Sub prj.ImportBinaryResource("c:\ExportedImages\*.bmp") End Sub

PslResource.ExportBinary

PslProject.ImportTransBundle

Imports data from an file that has been exported with PslProject.ExportTransBundle

Syntax Expression.Import (FilePath as String, [optional] Flags as Variant) as PslTranslist Expression Required. Object of type PassoloApp FilePath Path of the file to be imported Flags Some options to control the import. To combine flags, add the values: pslImportMerge (Value = 512): Translation bundles only: The translations in the bundle are merged with the existing translations in the project. If you are importing a licensed translation bundle, you can merge only if you use an unlimited Team Edition of SDL Passolo. pslImportRelease (Value = 1024): Translation bundles only: Imported string lists are released after import. If this flag is not set, the translation list in the project remains marked as "exported".

150 SDL Passolo Automation Reference 0

Example

Dim prj As PslProject Set prj = PSL.ActiveProject If prj Is Nothing Then Exit Sub If (Not prj.ImportTransBundle("c:\test_de.tbu")) Then MsgBox PSL.GetLastOutput End If

PslProject.ExportTransBundle

PslProject.IsTransBundle

Returns True, if the project is a translation bundle. Read-only property.

Syntax Expression.IsTransBundle as Boolean Expression Required. Object of type PslProject

PslProject.LogMessage

Writes a message into the log window and into the log file of the project

Syntax Expression.LogMessage (Text as String) Expression Object of type PslProject text The text to be logged

Example

Dim prj As PslProject set prj = PSL.Projects(1) prj.LogMessage("The text will appear in the log file.")

PslProject.Maintenance

Performs a project maintenance operation. I.e. it calculates project-wide references and relations.

SDL Passolo Automation 151 0 Reference

Syntax Expression.Maintenance (Mode as long) as Boolean Expression Object of type PslProject Mode Currently these maintenance operations are defined pslMaintenanceCalcUnifiedReplicates Calculates unified replicates pslMaintenanceCalcTransCounters Corrects the display in the project window, If an operation did not update the columns "Si ze" and "Translation" Returns TRUE, if successful.

Example

' Imports all bitmaps from a folder to the current project Sub Main Dim prj As PslProject Set prj = PSL.ActiveProject If prj Is Nothing Then Exit Sub prj.Maintenance(pslMaintenanceCalcUnifiedReplicates) End Sub

PslProject.PrepareTransBundle

Creates a PslTransBundle object to collect translation lists, glossaries and macros, that are exported to a translation bundle.

Syntax Expression.PrepareTransBundle() as PslTransBundle Expression Object of type PslProject Object PslTransBundle PslProject.ExportTransBundle

PslProject.Properties

Returns the PslProperties object that contains all custom properties of this PslProject.

Syntax Expression.Properties as PslProperties Expression Object of type PslProject Object PslProperties

152 SDL Passolo Automation Reference 0

PslSourceList.Property

Returns a custom property of the project. Custom properties are defined by add-ins or macros.

Syntax Expression.Property (Name as Variant) as Variant Expression Object of type PslProject Name Name of the property. If the macro sets a new value, the property name must be between 10000 and 19999 or start with "M:" (see below)

Custom Properties

Custom Properties can be defined by parser add-ins, a macro or the user. All properties are in the same list, so they all can be accessed. To distinguish the types, different property names are used. When setting a property the macro is responsible for using the correct name, otherwise the property may be removed when updating string lists.

Type Integer Name String Name Add-In properties 1 - 9999 No prefix Macro properties 10000 - 19999 Uses prefix "M:" User-defined properties 20000 - 30000 Uses prefix "U:"

Example

Dim prj As PslProject Set prj = PSL.ActiveProject If not prj Is Nothing Then prj.Property(10001) = "Hello!" psl.Output(prj.Property(10001)) End If

PslProject.ResumeSaving

You must call ResumeSaving for each call to SuspendSaving to have you project data saved again.

Syntax Expression.ResumeSaving() Expression Object of type PslProject PslProject.SuspendSaving

SDL Passolo Automation 153 0 Reference

PslProject.SuspendSaving

When a macro changes data in a project, the project file is saved immediately. If your project has many string lists, this can take a long time. You can speed up your operation by suppressing the saving of the project. For each call to SuspendSaving you must call ResumeSaving after the operation.

Syntax Expression.SuspendSaving() Expression Object of type PslProject

Example

Dim prj As PslProject Set prj = PSL.ActiveProject prj.SuspendSaving For Each src In prj.SourceLists ' do someting with src Next src For Each trn In prj.TransLists ' do something with trn Next trn prj.ResumeSaving

PslProject.UpdateSourceLists

Updates all source lists in this project.

Syntax Expression.UpdateSourceLists (optional ReportPath as Variant) as Boolean Expression Object of type PslProject ReportPath Variant, optional. The filename for the report. Returns TRUE, if all source lists have been updated successfully. PslSourceList.Update

PslProject.UpdateTransLists

Updates all translation lists in this project.

154 SDL Passolo Automation Reference 0

Syntax Expression.UpdateTransLists (optional ReportPath as Variant) as Boolean Expression Object of type PslProject ReportPath Variant, optional. The filename for the report. Returns TRUE, if all translation lists have been updated successfully. PslTransList.Update

Properties

PslProject.Comment

Returns the comment of the project. The project comment can be used to display a message to the user, when opening the project.

Syntax Expression.Comment as String Expression Required. Object of type PslProject

Example

Dim prj As PslProject Set prj = PSL.ActiveProject If prj Is Nothing Then PSL.Output "No active project found." Else prj.Comment = "Hello!" prj.DisplayComment = true End If

PslProject.DisplayComment

PslProject.DisplayComment

Set to True, if the project comment is displayed when opening the project.

Syntax Expression.DisplayComment as Boolean Expression Required. Object of type PslProject

SDL Passolo Automation 155 0 Reference

Example

Dim prj As PslProject Set prj = PSL.ActiveProject If prj Is Nothing Then PSL.Output "No active project found." Else prj.Comment = "Hello!" prj.DisplayComment = True End If

PslProject.Comment

PslProject.Glossaries

Returns the PslGlossaries object of the specified SDL Passolo project. PslGlossaries is a collection of PslGlossary objects with additional support functions.

Syntax Expression.Glossaries as PslGlossaries Expression Object of type PslProject Object PslGlossaries Object PslGlossary

PslProject.Languages

Returns a collection of the target languages of the project.

Syntax Expression.Languages as PslLanguages Expression Required. Object of type PslProject

Example

Dim prj As PslProject Set prj = PSL.Projects(1) PSL.Output "The project contains " & Str(prj.Languages.Count) & " target languages"

Object PslLanguages

156 SDL Passolo Automation Reference 0

PslProject.Location

Returns the location of the project file. Read-only property.

Syntax Expression.Location as String Expression Required. Object of type PslProject

PslProject.Name

Returns the name of the project. Read-only property.

Syntax Expression.Name as String Expression Required. Object of type PslProject

Example

Dim prj As PslProject Set prj = PSL.ActiveProject If prj Is Nothing Then PSL.Output "No active project found." Else PSL.Output prj.Name End If

PslProject.QuickIndexState

Returns the state of the project QuickIndex. Read-only property.

Syntax Expression. QuickIndexState as PslQuickIndexState Expression Required. Object of type PslProject

Return values pslQuickIndexNoIndex value = 1, no index is available pslQuickIndexIndexing value = 2, the index is currently being created pslQuickIndexIndexedOK value = 3, the index is available and valid pslQuickIndexIndexedInvalid value = 4, the index is available but outdated pslQuickIndexError value = 5, the index could not be created

SDL Passolo Automation 157 0 Reference

PslProject.SourceLists

Returns a collection of all source string lists of the project.

Syntax Expression.SourceLists as PslSourceLists Expression Required. Object of type PslProject

Example

Dim prj As PslProject Set prj = PSL.Projects(1) PSL.Output "The project contains " & Str(prj.SourceLists.Count) _ & " source string lists"

Object PslSourceList

PslProject.SynchronizeExports

Synchronizes all exports to translation bundles or the exporting project. Same as menu command File/Synchronize Exports.

Syntax Expression.SynchronizeExports() as PslProject Expression Object of type PslProject Returns TRUE, if successful.

Note:

When reading update files during synchronization, it's possible that the project is closed and re-opened again. This causes that the PslProject object is not valid anymore.

Use the return value of SynchronizeExports to re-assign the project pointer.

Example

Dim prj As PslProject Set prj = PSL.ActiveProject If prj Is Nothing Then Exit Sub // Synchronize exports and re-asign object Set prj = prj.SynchronizeExports

PslTransList.Update

158 SDL Passolo Automation Reference 0

PslProject.Tasks

Returns a collection of the tasks of the project.

Syntax Expression.Tasks as PslTasks Expression Required. Object of type PslProject Object PslTasks

PslProject.TransLists

Returns a collection of the translation lists of the project. See also: PslTransLists.

Syntax Expression.TransLists as PslTransLists Expression Required. Object of type PslProject

Example

Dim prj As PslProject Set prj = PSL.Projects(1) PSL.Output "The project contains " & Str(prj.TransLists.Count) _ & " translation lists"

Object PslTransLists

PslProject.UserFiles

Returns a collection of the user files that are embedded in the project.

Syntax Expression.UserFiles as PslUserFiles Expression Required. Object of type PslProject Object PslUserFile Object PslProjects

PslProjects is the container that contains all the SDL Passolo projects currently loaded into Passolo.

SDL Passolo Automation 159 0 Reference

Methods

PslProjects.Add

A new empty project is generated. If the project already exists, an error message will be displayed.

Syntax Expression.Add (Name as VARIANT, Location as VARIANT) as PslProject Expression Required. Object of type PslProjects Name Name of the new project. If Location is not entered, the Name must contain the path of the project file. Location If Name only contains the project name, Location must contain the path, in which the project will be generated.

Example

Dim prj As PslProject Set prj = PSL.Projects.Add("Test", "c:\temp") prj.LogMessage("Project generated by Automation");

PslProjects.Close

Closes all open projects.

Syntax Expression.Close (Savechanges as Variant) Expression Object of type PslProjects Savechanges Specifies the method of handling string lists, which were changed but not yet saved. The following values are possible: pslSaveChanges (Value = 0) : All changed string lists will be saved pslPromptToSaveChanges (Value = 1): Messages will be display, so that the user can decide, if he wants to save a string list or not. pslPromptWithCancel (Value = 2): Messages will be displayed simular to pslPromptToSaveChanges. Additionally the messages will contain a [Cancel]-Button, so that the user can stop closing the projects. pslDoNotSaveChanges (Value = 3): The string lists will be closed without saving the changes

160 SDL Passolo Automation Reference 0

Example

PSL.Projects.Close PSL.Output("All Project Windows were closed")

PslProjects.Item

Item returns a project contained in the PslProjects collection. The project can be specified by its index or its title. Item is the standard function, so the Name can also be omitted.

Syntax Expression.Item (Index as VARIANT) as PslProject Expression(Index) Expression Required. Object of type PslProjects Index Index (1,...) or title of a project.

Example

Dim prj As PslProject Set prj = PSL.Projects("test") If prj Is Nothing Then MsgBox("Project test not found") End If

PslProjects.Open

Opens an existing project. If the project is already open, it will just be returned.

Syntax Expression.Open (Path as Variant) as PslProject Expression Object of type PslProjects Path Path of the project, which is loaded. Mode Variant, optional. Specifies the mode for opening the project. This value is ignored, if the project is already open. The following values are possible: pslOpenNormal (default, Value = 1) : The project is opened in the normal, exclusive mode. pslSharedSetup (Value = 20) : The project is opened in Shared Mode. The user can modify project settings and edit string lists. Only one user at a time can work in this mode. pslSharedTranslation (Value = 36) : The project is opened in Shared Mode. The user can edit string lists. pslSharedReadOnly (Value = 52) : The project is opened in Shared Mode. The user can view the string lists but cannot make changes.

SDL Passolo Automation 161 0 Reference

Example

Dim prj As PslProject Set prj = PSL.Projects.Open("c:\temp\Test.lpj")

Properties

PslProjects.Application

Returns the PassoloApp object, read-only property.

Syntax Expression.Application as PassoloApp Expression Required. Object of type PslProjects Object PassoloApp

PslProjects.Count

Returns the number of projects loaded in SDL Passolo.

Syntax Expression.Count as Long Expression Required. Object of type PslProjects

Example

Dim n As Integer n = PSL.Projects.Count If n = 1 Then MsgBox("One project is open") Else MsgBox(CInt(n) & " projects are open.") End If

PslProjects.Parent

Returns the PassoloApp object, read-only property.

162 SDL Passolo Automation Reference 0

Syntax Expression.Parent as PassoloApp Expression Required. Object of type PslProjects Object PassoloApp Object PslProperties

PslProperties is a container for custom properties that are included in a PslSourceString or a PslTransString. Object PslSourceString Object PslTransString

Methods

PslProperties.Find

Returns an index if the property Name exists.

Syntax Expression.Find (Name as Variant) as Long Expression Required. Object of type PslProperties Name Name of the custom property. Valid names are arbitrary integers between 1 and 30000 or strings.

PslProperties.RemoveAll

Removes all custom properties in this PslProperties object.

Syntax Expression.RemoveAll as void Expression Required. Object of type PslProperties

Example

Dim t As PslTransString ... t.Properties.RemoveAll

SDL Passolo Automation 163 0 Reference

Properties

PslProperties.Count

Returns the number of custom properties.

Syntax Expression.Count as Long Expression Required. Object of type PslProperties

Example

Rem Dump properties of a TransString Dim t As PslTransString ... propcount = t.Properties.Count For i = 1 To propcount Dim propname As Variant Dim propval As Variant propname = t.Properties.Name(j) propval = t.Properties.Value(j) PSL.Output propname & " = " & propval Next j

PslProperties.Name

Returns the name of a custom property. Valid names are arbitrary integers between 1 and 30000 or strings.

Syntax Expression.Name (Index as Long) as Variant Expression Required. Object of type PslProperties Index Index of the property. A value between 1 and PslProperties. Count

Example

Rem Dump properties of a TransString Dim t As PslTransString ... propcount = t.Properties.Count For i = 1 To propcount Dim propname As Variant Dim propval As Variant propname = t.Properties.Name(j) propval = t.Properties.Value(j) PSL.Output propname & " = " & propval

164 SDL Passolo Automation Reference 0

Next j

PslProperties.Count

PslProperties.Value

Returns the value of a custom property.

Syntax Expression.Value (Index as Long) as Variant Expression Required. Object of type PslProperties Index Index of the property. A value between 1 and PslProperties. Count

Example

Rem Dump properties of a TransString Dim t As PslTransString ... propcount = t.Properties.Count For i = 1 To propcount Dim propname As Variant Dim propval As Variant propname = t.Properties.Name(j) propval = t.Properties.Value(j) PSL.Output propname & " = " & propval Next j

PslProperties.Count Object PslResData

PslResData is the interface object to exchange data between SDL Passolo and the event handler OnProcessUserFile. In OnProcessUserFile the handling of other file formats like data bases or java property files can be implemented.

In the Programmers Reference you find a complete example how to use PslResData.

Methods

SDL Passolo Automation 165 0 Reference

PslResData.AddFileExtension

Add a file extension to the list of supported file extensions.

Syntax Expression.AddFileExtension (FileDescription as String, FileExtension as String) as void Expression Object of type PslResData FileDescription A description of the file type FileExtension The extension of the file type

Note

A sample how to use AddFileExtensions.

If rd.Action = pslResUpdGetFileExtensions Then ' We support text files with extension *.txt and *.asc rd.AddFileExtension("Text file (*.txt;*.asc)", "*.txt;*.asc") ' And we support DOS-Text too. rd.AddFileExtension("DOS Text file (*.dos)", "*.dos") Exit Sub End If

PslResData.AddLanguage

Call this function for each language contained in the source file.

Syntax Expression.AddLanguage (LangID as Integer) as void Expression Object of type PslResData LangID A language id.

Note: If the language in the source file is given as a string like ENU for English USA, you can use the method PassoloApp.GetLangID to convert the language to the numerical value needed. If you can get a language information from the source file use 0 (Neutral Language) as LangID.

PslResData.GetEntryData

Get data of resource string. After calling ProcessEntry, you can obtain the resource text in the target language.

166 SDL Passolo Automation Reference 0

Syntax Expression.GetEntryData (DataID as Integer) as String Expression Object of type PslResData DataID Indicates, what kind of data you want to retrieve: pslResUpdId (Value = 0): Get the id of the resource entry. pslResUpdText (Value = 1): Get the resource text of the resource entry. pslResUpdCtrl (Value = 2): Get additional information about the resource entry. PslResUpdTranslated (Value=3): Returns "1" if the resource entry is translated, otherwise the return value is "0".

Note: The following example demonstrates how a simple text file can be processed. After reading and processing the source text with PslResData.ProcessEntry, the translated target text can be obtained by calling PslResData.GetEntryData.

Function TxtUpdate(rd As PslResData) As Long Dim fso As Scripting.FileSystemObject, tsi As Scripting.TextStream Dim tso As Scripting.TextStream Dim s As String, i As Integer, delimiterpos As Integer Set fso = New Scripting.FileSystemObject Set tsi = fso.OpenTextFile(rd.SourceFile) ' Generating target file If rd.Action = pslResUpdGenerate Then Set tso = fso.CreateTextFile(rd.TargetFile) End If rd.ProcessResource "Text File", "Textlist" TxtUpdate = 0 On Error GoTo finish While True s = tsi.ReadLine delimiterpos = InStr(s, "=") If delimiterpos > 0 Then rd.SetEntryData(pslResUpdId, Trim(Left(s, delimiterpos - 1))) rd.SetEntryData(pslResUpdText, Trim(Mid(s, delimiterpos + 1))) rd.SetEntryData(pslResUpdCtrl, "") rd.ProcessEntry ' Generate changed line If rd.Action = pslResUpdGenerate Then s = CStr(rd.GetEntryData(pslResUpdId)) & " = " & _ rd.GetEntryData(pslResUpdText) End If End If ' Write data to target file If rd.Action = pslResUpdGenerate Then tso.WriteLine(s) End If Wend finish: End Function

PslResData.ProcessEntry

SDL Passolo Automation 167 0 Reference

PslResData.ListResource

For each resource contained in the source file call this method.

Syntax Expression.ListResource (ResType as Variant, ResName as String, LangID as Integer) as void Expression Object of type PslResData ResType Type of resource ResName Name of resource LangID ID of the language

Note: If the file does not contain resources like a simple text file just call this method with some useful static value like:rd.ListResource "Text File", "Textlist", 0

PslResData.ProcessEntry

Let SDL Passolo process a new resource string. Before you can process any resource texts you must call PslResData.ProcessResource to create a resource, in which the resource string can be stored.

Before calling PslResData.ProcessEntry you must set the resource entry data by calling PslResData.SetEntryData.

Syntax Expression.ProcessEntry as void Expression Object of type PslResData

Note: The following example show how PslResData.ProcessResource should be used. See PslResData. GetEntryData for an complete example. In the Programmers Reference you find a complete example how to use PslResData.

' Set the id of the resource entry rd.SetEntryData(pslResUpdId, Trim(Left(s, delimiterpos - 1))) ' Set the text of the resource entry rd.SetEntryData(pslResUpdText, Trim(Mid(s, delimiterpos + 1))) ' No control values defined yet, must be called with an empty string rd. SetEntryData(pslResUpdCtrl, "") ' Let PASSOLO process the entry rd.ProcessEntry

PslResData.ProcessResource PslResData.SetEntryData PslResData.GetEntryData

168 SDL Passolo Automation Reference 0

PslResData.ProcessResource

Let PASSOLO process a new resource. This method must be called before processing resource string with ProcessEntry.

If the file does not contain resources like a simple text file just call this method with some useful static value like:

rd.ProcessResource "Text File", "Textlist"

See PslReasData.GetEntryData for an complete example. In the Programmers Reference you find a complete example how to use PslResData.

Syntax Expression.ProcessResource (ResType as Variant, ResID as Variant) as void Expression Object of type PslResData ResType Type of the resource ResID ID of the resource PslResData.GetEntryData

PslResData.SetEntryData

Set the data for a resource entry before calling PslResData.ProcessEntry. See PslReasData.GetEntryData for an complete example. In the Programmers Reference you find a complete example how to use PslResData.

Syntax

Expression.SetEntryData (DataID as Integer, DataValue as String) as void Expression Object of type PslResData DataID pslResUpdId (Value = 0): Set the id of the resource entry. pslResUpdText (Value = 1): Set the resource text of the resource entry. pslResUpdCtrl (Value = 2): Set additional information about the resource entry. No additional data is defined up to now. Before you call PslResData.ProcessEntry you must call PslResData.SetEntry with the DataID pslResUpdCtrl and an empty string: pslResTranslated (Value = 3) Checks if the translation string is translated. Use only when generating target file. pslResComment (Value = 4): Sets a comment for the entry.

rd.SetEntryData(pslResUpdCtrl, "") rd.ProcessEntry

SDL Passolo Automation 169 0 Reference

DataValue The new value of the resource data. PslResData.ProcessEntry PslResData.GetEntryData

Properties

PslResData.Action

Action to be performed when OnProcessUserFile is called by SDL Passolo.

Syntax Expression.Action as Long pslResUpdScanData (Value = 0): Passolo calls OnProcessUserFile to read a source file. pslResUpdGenerate (Value = 1): Passolo calls OnProcessUserFile to generate the target file. pslResUpdListContent (Value = 2): Passolo calls OnProcessUserFile to obtain the list of resources contained in a source file. pslResUpdCheckSourceTarget (Value = 3): Passolo calls OnProcessUserFile to check if the source and/or target file is valid. pslResUpdGetLanguages (Value =4): Passolo calls OnProcessUserFile to obtain the list of languages contained in a source file. pslResUpdGetFileExtensions (Value = 5): Passolo calls OnProcessUserFile to get a list of file extension supported by this handler. PslResUpdScanTarget (Value = 6): Passolo calls OnProcessUserFile to read a source file for alignment (Passolo function: Scan target file). In most cases this event can be handled like pslResUpdScanData. Expression Object of type PslResData

PslResData.Error

Errorcode for SDL Passolo.

Syntax Expression.Error as Long Expression Object of type PslResData

Note: Set Error to 0 if no error happened during the operation. Any other value indicates an error and Passolo will not process the received data.

170 SDL Passolo Automation Reference 0

PslResData.SourceLanguage

Contains the source language.

Syntax Expression.SourceLanguage as Long Expression Object of type PslResData

PslResData.SourceFile

Contains the source file to be scanned.

Syntax Expression.SourceFile as String Expression Object of type PslResData

PslResData.SourceCodePage

When parsing the source file this property returns the code page for converting from ASCII to Unicode. 0 is returned if the default code page of the current language should be used. Call PassoloApp. GetDefaultCodePage to obtain the default code page for a language.

Syntax Expression.SourceCodePage as Long Expression Object of type PslResData

PslResData.TargetCodePage

When generating or parsing the target file this property returns the code page for converting from ASCII to Unicode. 0 is returned if the default code page of the current language should be used. Call PassoloApp.GetDefaultCodePage to obtain the default code page for a language.

Syntax Expression.TargetCodePage as Long Expression Object of type PslResData PassoloApp.GetDefaultCodePage

SDL Passolo Automation 171 0 Reference

PslResData.TargetFile

Contains the target file to be generated.

Syntax Expression.TargetFile as String Expression Object of type PslResData

PslResData.TargetLanguage

Contains the target language.

Syntax Expression.TargetLanguage as Long Expression Object of type PslResData Object PslResource

This object represents a resource like a menu or a dialog.

Methods

PslResource.AutoLayout

Performs an auto-layout operation on this resource. Currently this works only with dialogs from WIN32 and RC files.

Syntax Expression.AutoLayout (Path as String) as Boolean Expression Object of type PslResource Path Path of the file to import. Returns TRUE, if successful.

172 SDL Passolo Automation Reference 0

PslResource.ChangeID

Changes the ID of the resource. This ID identifies the resource both in the source file and the target file. If the ID is changed the resource may no longer be relatable. So be careful using this function.

The function can only change the ID of on Resource in a source string list (PslSourceList). If it is called from a translation list (PslTransList) it will return False.

Syntax Expression.ChangeID (ID as Variant) as Boolean Expression Object of type PslResource ID New ID for the resource. This can either be a numerical value or a string. Object PslSourceList Object PslTransList

PslResource.ExportBinary

Writes a binary resource (bitmap, icon, ...) to a file.

Syntax Expression.ExportBinary (Folder as String , optional FileName as Variant) as String Expression Object of type PslResource Folder Target folder for the binary file. FileName Name of the file to be written. If you omit this parameter or if it is an empty string, SDL Passolo creates a file name with the correct extension. This file name contains internal numbers of the resource, that make it possible to import this file with Returns the full path of the file, that has been written.

Example

' Exports all bitmaps and icons in the current project Sub Main Dim prj As PslProject Set prj = PSL.ActiveProject If prj Is Nothing Then Exit Sub Dim trn As PslTransList ' Loop all translation lists For Each trn In prj.TransLists ' Loop all resources For i = 1 To trn.ResourceCount Dim res As PslResource Set res = trn.Resource(i) If res.IsBinary And (res.Type = "Bitmap" Or res.Type = "IconGroup") Then res.ExportBinary("c:\ExportedImages", "") End If Next i Next trn End Sub

SDL Passolo Automation 173 0 Reference

PslResource.ImportBinary

If this resource is binary (e.g. a bitmap or icon) and part of a translation list, then you can import a file of the same type.

Syntax Expression.ImportBinary (Path as String) as Boolean Expression Object of type PslResource Path Path of the file to import. Returns TRUE, if successful.

PslResource.OpenResourceEditor

Opens the resource editor for this resource.

Syntax Expression.OpenResourceEditor ([optional] idDisplay as String) as PslResourceEditor Expression Object of type PslResource idDisplay optional, the name of the resource display to show. The names are depending on the parser and the add-ins, that provide the source display. Valid names are "Translation" shows the 'normal' resource used for translation "Source" shows the original resource from the source file "Source Text" shows a text display of the source file (e.g. HTML parser, Java parser) "Text Renderer" shows the rendered text, if the project is prepared for text rendering Returns the PslResourceEditorobject, if successful. Object PslResourceEditor

Properties

PslResource.Attribute

Returns the attribute of the resource.

Syntax Expression.Attribute (Name as String) as Variant Expression Object of type PslResource Name Attribute string

174 SDL Passolo Automation Reference 0

PslResource.FirstStringIndex

Returns the index of the first string of this resource.

Syntax Expression.FirstStringIndex as Long Expression Object of type PslResource

PslResource.ID

Returns the ID of the resource This can either be a numerical value or a string.

Syntax Expression.ID as Variant Expression Object of type PslResource

Note: The ID of strings from resource type StringTable is a combination of the resource id and the item id. To calculate the string id use this formula:

Dim s As PslSourceString ... Dim id as Long id = s.ID If s.Resource.Type = "StringList" Then id = 16 * (s.Resource.ID - 1) + s.ID Else id = s.ID End If

PslResource.IDName

Returns the IDName of the resource. The IDName is used in header files to substitute numercal IDs with a more meaningful symbolic representation. If this information is not available an empty string will be returned.

Syntax Expression.IDName as String Expression Object of type PslResource

SDL Passolo Automation 175 0 Reference

PslResource.IsBinary

Returns TRUE, if this resource is a binary resource, i.e a bitmap, icon or cursor. Or other custom binary data, that is not parsed.

Syntax Expression.IsBinary as Boolean Expression Object of type PslResource

PslResource.Number

Returns the number of the resource.

Syntax Expression.Number as long Expression Object of type PslResource

PslResource.State

Returns she status bits of the resource.

Syntax Expression.State (State as Variant) as Boolean Expression Object of type PslResource State Name of the status value. The following values are possible: pslStateChanged (Value = 2): The resource was changed during one of the previous updates. Can only be changed for resources of the source string list. pslStateDeleted (Value = 9): The resource has been deleted and is stored in the recycle bin. pslStateHidden (Value = 3): The resource is not visible for the translator. Can only be changed for resources of the source string list. pslStateInvisible (Value = 31):The resource is never shown, not in the source list and not in the translation list (read-only) pslStateNew (Value = 3): The resource is new, it was added by one of the previous updates. Can only be changed for resources of the source string list. pslStateReadOnly (Value = 1): The resource may not be modified by the translator. Can only be changed for resources of the source string list.

176 SDL Passolo Automation Reference 0

PslResource.StringCount

Returns the number of strings contained in this resource.

Syntax Expression.StringCount as Long Expression Object of type PslResource

PslResource.Type

Returns the type of the resource (eg. Dialog). A list of all possible types can be found in the Appendix.

Syntax Expression.Type as String Expression Object of type PslResource Appendix Object PslResourceEditor

This object represents a currently opened resource editor.

Methods

PslResourceEditor.FlipLayout

If the current resource editor is a dialog editor: Flips the layout of all controls, i.e. it toggles the direction from right to left.

Syntax Expression.FlipLayout (Type as Variant) as Boolean Expression Object of type PslResource Type Variant, optional. Specifies the method of flipping the dialog. The following values are possible: pslFlipModeToggle (Value = 0) : Changes the coordinates of all controls and toggles right-to-left styles. pslFlipModeMirror (default, Value = 1): Mirrors the complete dialog.

Note: The Type is not supported by all parser. E.g. the .NET parser ignores this value, because there's only one type of flipping the layout.

SDL Passolo Automation 177 0 Reference

PslResourceEditor.ResetLayout

If the current resource editor is a dialog editor: Resets the layout of all controls.

Syntax Expression.ResetLayout() as Boolean Expression Object of type PslResource Returns TRUE, if successful. Object PslSourceDisplay

PslSourceDisplay represents the display of one or more source lists in the SDL Passolo string window.

Methods

PslSourceDisplay.String

Returns a PslSourceString object from this string list window. This string belongs to any of the string lists that are currently opened.

Syntax Expression.String (Index as VARIANT, optional Type as VARIANT) as PslSourceString Expression Object of type PslSourceDisplay Index Depending on the Type this is either an index or a number. Type Can be one of the following values: pslIndex (default, Value = 0): An arbitrary string is returned. Index is the Index of the string, correspond- ing to all existing undeleted strings. The first string has got the Index 1. pslIndexDeleted (Value = 4): Works like pslIndex but returns deleted strings from the recycle bin. pslDisplay (Value = 1): A string from the current display is returned. Index is the Index of the string, corresponding to all displayed strings. The first string has got the Index 1. pslSelection (Value = 2): A selected string from the current display is returned. Index is the Index of the string, corresponding to all selected strings. The first selected string has got the Index 1. Object PslSourceString

178 SDL Passolo Automation Reference 0

PslSourceDisplay.StringCount

Returns the number of strings in the source list window. The number refers to all string lists, that are currently opened.

Syntax Expression.StringCount (optional Type as VARIANT) as Long Expression Object of type PslSourceDisplay Type Can be one of the following values: pslIndex (default, Value = 0): The total number of (undeleted) strings will be returned. pslIndexDeleted (Value = 4): The total number of deleted strings in the recycle bins will be returned. pslDisplay (Value = 1): The number of displayed strings will be returned. pslSelection (Value = 2): The number of selected strings will be returned. Object PslSourceList

PslSourceList represents a source string list. It offers methods to perform operations on the list and attributes to access each resource string.

Methods

PslSourceList.Close

Closes a string list, if it is open.

Syntax Expression.Close (Savechanges as Variant) as Boolean Expression Required. Object of type PslSourceList Savechanges Variant, optional. Specifies the method of handling the string list, if it was changed but not yet saved. The following values are possible: pslSaveChanges (default, Value = 0) : The string list will be saved pslPromptToSaveChanges (Value = 1): Message will be displayed, so that the user can decide, if he wants to save the string list or not. pslPromptWithCancel (Value = 2): A message will be displayed similar to pslPromptToSaveChanges. Additionally the message will contain a [Cancel]-Button, so that the user can stop closing the string list. pslDoNotSaveChanges (Value = 3): The string list will be closed without saving the changes.

SDL Passolo Automation 179 0 Reference

PslSourceList.Open

Opens the string list.

Syntax Expression.Open as Boolean Expression Required. Object of type PslSourceList

PslSourceList.Save

Saves the source string list if it was changed.

Syntax Expression.Save as Boolean Expression Required. Object of type PslSourceList

PslSourceList.SetTargetPathRule

Assigns a target path rule to the source list.

If you add target languages to a project, all new translation lists will use the target path rule of the source list.

Syntax Expression.Leverage (Id as Long, bLink as Boolean, [optional] Parser as String) as Boolean Expression Object of type PslSourceList Id ID of the target path rule as returned by PslProject.AddTargetPathRule or index if this is a rule from a parser add-in bLink True, if the source list should be linked to the target path rule, i.e. the target path will be calculated automatically and cannot be changed manually. Parser optional, if set, the target path rule is from a parser and ID is the index. Parser has the format "Addin :", see table below.

Standard Add-In defined Target Path Rules

Parser ID (Index) Rule Name Description AddIn:Java File Parser 0 Java Lang_Region Naming conventions for Java file types *.class, *.java, *properties 1 Multilingual Java Naming conventions for archive Java *.jar files

180 SDL Passolo Automation Reference 0

Parser ID (Index) Rule Name Description "AddIn:Borland 0 Borland Language DLLs Naming conventions for Delphi/C++ Builder" Borland Language DLLs 1 Borland .NET Language Naming conventions for DLLs Borland .NET Language DLLs "AddIn:Microsoft .NET 0 .NET Assemblies Naming conventions for Parser" .NET Satellite Assemblies 1 .NET Resources Naming conventions for .NET resx-files 2 .NET Satellite Naming conventions for Assemblies translation of .NET Satellite Assemblies

Example

Sub Main ' Create a new project Dim prj As PslProject Set prj = PSL.Projects.Add("scribble", "c:\projects") ' Add a source list Dim src As PslSourceList Set src = prj.SourceLists.Add("c:\projects\scribble.exe") ' Add a target path rule for creating resource DLLs Dim idRule As Long idRule = prj.AddTargetPathRule("Resource DLL", "", "", ".dll") ' Assign the rule the the source list src.SetTargetPathRule(idRule, True, "") ' Add a target language, the new translation list ' will use the rule that has been asigned to the source list prj.Languages.Add(pslLangGerman) End Sub

PslProject.AddTargetPathRule

PslSourceList.Update

Creates or updates the source list. Returns True, if the update was successful and False, if the update failed.

Syntax Expression.Update as Boolean Expression Object of type PslSourceList

SDL Passolo Automation 181 0 Reference

PslSourceList.UnExport

Releases the string list if is currently exported to a translation bundle. After that the string list cannot be imported anymore. Returns True, if the un-export was successful and False, if the string list has not been exported.

Syntax Expression.UnExport as Boolean Expression Object of type PslSourceList

Properties

PslSourceList.IsOpen

True, if the string list is currently opened.

Syntax Expression.IsOpen as Boolean Expression Required. Object of type PslSourceList

PslSourceList.ExtLang

Returns the id of an extracted language, read-only property.

Syntax Expression.ExtLang (Index as Long) as Integer Expression Required. Object of type PslSourceList Index Index of the extracted language. Value from 1 to PslSourceList.ExtLangCount

Example

Sub ShowExtractLanguages(src As PslSourceList) PSL.Output src.Title & " extracts " Dim i As Integer For i = 1 To src.ExtLangCount Dim langid As Integer langid = src.ExtLang(i) PSL.Output PSL.GetLangCode(langid, pslCodeText) Next i End Sub

182 SDL Passolo Automation Reference 0

PslSourceList.ExportDate

If the source list has been exported as part of a translation bundle, this property returns the time of the export.

Syntax Expression.ExportDate as Date Expression Required. Object of type PslSourceList

PslSourceList.ExportFile

If the source list has been exported as part of a translation bundle, this property returns the path of the translation bundle.

Syntax Expression.ExportFile as String Expression Required. Object of type PslSourceList

Example

' Update all string lists that are not exported Dim src As PslSourceList For Each src In PSL.ActiveProject.SourceLists If src.ExportFile <> "" Then src.Update End If Next src

PslSourceList.ExtLangCount

Returns the number of extracted languages, read-only property.

Syntax Expression.ExtLangCount as Long Expression Required. Object of type PslSourceList

SDL Passolo Automation 183 0 Reference

Example

Sub ShowExtractLanguages(src As PslSourceList) PSL.Output src.Title & " extracts " Dim i As Integer For i = 1 To src.ExtLangCount Dim langid As Integer langid = src.ExtLang(i) PSL.Output PSL.GetLangCode(langid, pslCodeText) Next i End Sub

PslSourceList.Extract

The Get-Property checks, if a language from the source file will be extracted.

The Set-Property adds or removes a language to the list of extracted languages.

Syntax Expression.Extract (LangID as Integer) as Boolean Expression Required. Object of type PslSourceList LangID A language id or one of these values : pslLangAll (Value = 255): stands for all languages pslLangAllExceptNeutral (Value = 1279): stands for all languages, except Neutral

Example 1

' Adds a source file to the current project ' and sets extract language to "all" Dim prj As PslProject Set prj = PSL.ActiveProject If prj Is Nothing Then Exit Sub Dim src As PslSourceList Set src = prj.SourceLists.Add("c:\test.exe", "Test", pslLangEnglishUSA) src.Extract(pslLangAll) = True

Example 2

' Displays all source files, that ' extract German resources Dim prj As PslProject Set prj = PSL.ActiveProject If prj Is Nothing Then Exit Sub Dim src As PslSourceList For Each src In prj.SourceLists If src.Extract(pslLangGerman) Then PSL.Output src.Title End If Next src

184 SDL Passolo Automation Reference 0

PslSourceList.FileDate

Returns the time stamp of the source file.

Syntax Expression.FileDate as Date Expression Required. Object of type PslSourceList

Example

' Update all string lists that need to be updated Dim src As PslSourceList For Each src In PSL.ActiveProject.SourceLists If src.FileDate > src.LastUpdate Then src.Update End If Next src

PslSourceList.FindID

Returns a PslSourceString with a given ID.

Syntax Expression.FindID (ID as VARIANT, Index as Long) as PslSourceString Expression Object of type PslSourceList ID The ID you're looking for Index Set to 1 to find the first token with ID. Increase the number to find following tokens with that ID.

Example

' Find all source strings with the ID 100 Dim src As PslSourceList Set src = PSL.ActiveSourceList If Not src Is Nothing Then Dim s As PslSourceString Dim index As Long index = 1 While True Set s = src.FindID(100, index) If s Is Nothing Then Exit While PSL.Output Str(s.Number) index = index + 1 Wend End If

Object PslSourceString

SDL Passolo Automation 185 0 Reference

PslSourceList.LangID

Contains the language ID of the source list.

Syntax Expression.LangID as Integer Expression Required. Object of type PslSourceList

PslSourceList.LastChange

Returns the the date and the time when this source list has last been changed by editing tokens or resources.

Syntax Expression.LastChange as Date Expression Required. Object of type PslSourceList

Example

' Update all translation lists that need to be updated For Each trn In PSL.ActiveProject.TransLists If trn.SourceList.LastChange > trn.LastUpdate Then trn.Update End If Next trn

PslSourceList.LastUpdate

Returns the the date and the time when this source list has last been updated.

Syntax Expression.LastUpdate as Date Expression Required. Object of type PslSourceList

Example

' Update all string lists that need to be updated Dim src As PslSourceList For Each src In PSL.ActiveProject.SourceLists If src.FileDate > src.LastUpdate Then src.Update End If Next src

186 SDL Passolo Automation Reference 0

PslSourceList.Leverage

Performs a leverage operation for this source list. The current leverage options are used.

Syntax Expression.Leverage (ProjectFile as String) as Boolean Expression Object of type PslSourceList ProjectFile Path of the project file that is the source for the leverage. SDL Passolo opens this project and - if it finds a matching source list - it transfers data from this project.

PslSourceList.ListID

Returns the numerical ID that SDL Passolo uses to identify a string list.

Syntax Expression.ListID as Long Expression Required. Object of type PslSourceList

PslSourceList.Option

Returns or changes some options of the source list.

Syntax Expression.Option (Name as Long) as VARIANT Name Specifies the option to read or change. It can be one of these values: pslOptionActualCodepage (Value = 4): The codepage for converting strings from unicode to DBCS. pslOptionCodepage (Value = 2): The codepage for converting strings from unicode to DBCS. If the default codepage of the source language is used, this option returns 0. pslOptionFont (Value = 3): Returns the font which is used to display the source strings. This has the format ",, i.e. "Arial,9". An empty font string stands for the system (default) font. pslOptionLangID (Value = 1): Returns the language ID of the source list. Same as PslSourceList.LangID

PslSourceList.Parser

Returns the parser used for parsing the source file.

SDL Passolo Automation 187 0 Reference

Syntax Expression.Parser as String Expression Required. Object of type PslSourceList

Note: The parser is defined by a string with this format:

Name Comment Example "Win32" Internal parser for Win32 .exe "Win32" and .dll files. "Addin:" Uses a parser addin. The add-in "AddIn:Borland Delphi/C++ list in the PASSOLO options Builder" "AddIn:Text Parser" pages displays the identifier of each add-in. "Macro: Uses a macro. is "Macro:PslIniScan" the file name of the macro file without extension.

PslSourceList.Properties

Returns the PslProperties object that contains all custom properties of this PslSourceList.

Syntax Expression.Properties as PslProperties Expression Object of type PslSourceList Object PslProperties

PslSourceList.Property

Returns a custom property of the string list. Custom properties are defined by add-ins or macros.

Syntax Expression.Property (Name as Variant) as Variant Expression Object of type PslSourceList Name Name of the property. If the macro sets a new value, the property name must be between 10000 and 19999 or start with "M:" (see below)

188 SDL Passolo Automation Reference 0

Custom Properties

Custom Properties can be defined by parser add-ins, a macro or the user. All properties are in the same list, so they all can be accessed. To distinguish the types, different property names are used. When setting a property the macro is responsible for using the correct name, otherwise the property may be removed when updating string lists.

Type Integer Name String Name Add-In properties 1 - 9999 No prefix Macro properties 10000 - 19999 Uses prefix "M:" User-defined properties 20000 - 30000 Uses prefix "U:"

Example

Dim src As PslSourceList Set src = PSL.ActiveSourceList If not src Is Nothing Then src.Property(10001) = "Hello!" psl.Output(src.Property(10001)) End If

PslSourceList.Resource

Returns a PslResource object from this list. If the list is still closed, it will be opened.

Syntax Expression.Resource (Index as VARIANT, optional Type as VARIANT) as PslSourceString Expression Object of type PslSourceList Index Depending on the Type this is either an index or a number. Type Can be one of the following values: pslIndex (default, Value = 0): An arbitrary resource is returned. Index is the Index of the resource, corresponding to all existing undeleted resources. The first resource has got the Index 1. pslIndexDeleted (Value = 4): Works like pslIndex but returns deleted resources from the recycle bin. pslNumber (Value = 3): An arbitrary resource is returned. Index is the Number of the string. Object PslResource

SDL Passolo Automation 189 0 Reference

PslSourceList.ResourceCount

Returns the number of resources in this list. If the list is still closed, it will be opened.

Syntax Expression.ResourceCount (optional Type as VARIANT) as Long Expression Object of type PslSourceList Type Can be one of the following values: pslIndex (default, Value = 0): The total number of (undeleted) resources will be returned. pslIndexDeleted (Value = 4): The total number of deleted resources in the recycle bin will be returned.

Note: Each string list resource in a Win32 files contains max. 16 strings. SDL Passolo displays all string list resources as a single resource, but with this function you access the original string list resources.

PslSourceList.Project

Returns the corresponding PslProject object, read-only property.

Syntax Expression.Project as PslProject Expression Required. Object of type PslSourceList Object PslProject

PslSourceLists.Remove

Removes a source string list from the project. The corresponding translation lists will also be removed.

Syntax Expression.RemoveIndex as Variant Expression Required. Object of type PslSourceLists Index Variant, Required. Identifies the source string list to be deleted. It can be either the index in the list (1,2,...), the title or an object of type PslSourceList

190 SDL Passolo Automation Reference 0

Example

PSL.ActiveProject.SourceLists.Remove("Notepad")

PslSourceList.Selected

Returns or sets the selected state of this source string list in the project window.

Syntax Expression.Selected as Boolean Expression Required. Object of type PslSourceList

Example

' Print title and language of each selected source string list ' and reset selection Dim src As PslSourceList Dim i As Integer For i = 1 to PSL.ActiveProject.SourceLists.Count set src = PSL.ActiveProject.SourceLists(i) If src.Selected Then PSL.Output src.Title src.Selected = False End If Next i

PslSourceList.Size

Returns the size (string count) of this source list as it's displayed in the project window.

Syntax Expression.Size as Long Expression Required. Object of type PslSourceList

PslSourceList.SourceFile

Contains the name of the source file for the source list.

SDL Passolo Automation 191 0 Reference

Syntax Expression.SourceFile as String Expression Required. Object of type PslSourceList

Example

Dim src As PslSourceList Set src = PSL.ActiveSourceList If src Is Nothing Then PSL.Output "No active source list found." Else PSL.Output src.SourceFile End If

PslSourceList.State

Returns the status bits of the source string list.

Syntax Expression.State (State as Variant) as Boolean Expression Required. Object of type PslSourceList State Name of the status value. The following values are possible: pslListStateBookmark (Value = 100):The string list has a bookmark in the project window pslSourceListStateVirtual (Value = 212): Read-Only, the source string list has a virtual source file, e.g. a database.

PslSourceList.String

Returns a PslSourceString object from this list. If the list is still closed, it will be opened.

Syntax Expression.String (Index as VARIANT, optional Type as VARIANT) as PslSourceString Expression Object of type PslSourceList Index Depending on the Type this is either an index or a number. Type Can be one of the following values: pslIndex (default, Value = 0): An arbitrary string is returned. Index is the Index of the string, correspond- ing to all existing undeleted strings. The first string has got the Index 1. pslIndexDeleted (Value = 4): Works like pslIndex but returns deleted strings from the recycle bin. pslDisplay (Value = 1): A string from the current display is returned. Index is the Index of the string, corresponding to all displayed strings. The first string has got the Index 1. This value is supported for backward compatibility only. See the note below.

192 SDL Passolo Automation Reference 0

pslSelection (Value = 2): A selected string from the current display is returned. Index is the Index of the string, corresponding to all selected strings. The first selected string has got the Index 1. This value is supported for backward compatibility only. See the note below. pslNumber (Value = 3): An arbitrary string is returned. Index is the Number of the string.

Note: With SDL Passolo 6 multiple string lists are displayed in a single window if they have the same languages. To access displayed or selected strings with pslDisplay or pslSelection you should use PslSourceDisplay instead of PslSourceList. If you use PslSourceList then pslDisplay and pslSelection return only strings, if exactly one string list is displayed in the window.

Object PslSourceString

PslSourceList.StringCount

Returns the number of strings in this list. If the list is still closed, it will be opened.

Syntax Expression.StringCount (optional Type as VARIANT) as Long Expression Object of type PslSourceList Type Can be one of the following values: pslIndex (default, Value = 0): The total number of (undeleted) strings will be returned. pslIndexDeleted (Value = 4): The total number of deleted strings in the recycle bin will be returned. pslDisplay (Value = 1): The number of displayed strings will be returned. This value is supported for backward compatibility only. See the note below. pslSelection (Value = 2): The number of selected strings will be returned. This value is supported for backward compatibility only. See the note below. The following values use the stored counters in the project. The string list does not need to be loaded, which makes the call much faster. pslTotal (Value = 100): Returns the total number of strings. Same as pslIndex pslToTranslate (Value = 101): Returns that number of strings that need to be translated. This is pslTotal minus empty strings and strings that don't need to be translated, e.g. hidden or read-only strings.

Note: Multiple string lists are displayed in a single window if they have the same languages. To access displayed or selected strings with pslDisplay or pslSelection you should use PslSourceDisplay instead of PslSourceList. If you use PslSourceList then pslDisplay and pslSelection return only strings, if exactly one string list is displayed in the window.

Object PslSourceDisplay

SDL Passolo Automation 193 0 Reference

PslSourceList.Title

Syntax Expression.Title as String Expression Required. Object of type PslSourceList

PslSourceList.WordCount

Returns the number of words in this list.

Syntax Expression.WordCount (optional Type as VARIANT) as Long Expression Object of type PslSourceList Type Can be one of the following values: pslTotal (Value = 100): Returns the total number of strings. Same as pslIndex pslToTranslate (Value = 101): Returns that number of strings that need to be translated. This is pslTotal minus empty strings and strings that don't need to be translated, e.g. hidden or read-only strings. Object PslSourceLists

PslSourceLists contains all source files/source string lists of a project.

Methods

PslSourceLists.Add

Adds a new source file to the project.

Syntax Expression.Add (FileName as Variant, optional Title as Variant, optional LangID as Variant) as Psl- SourceList Expression Required. Object of type PslSourceLists FileName Name of the new source file path. The path can be indicated absolutely or relative to the directory of the project file Title Title of the source string list. If it is omitted, the title will be generated from the FileName.

194 SDL Passolo Automation Reference 0

LangID Language-ID of the strings in the source file. It can be either the LanguageID or the LanguageCode. If this argument is omitted, SDL Passolo will try to detect the language from the resources of the source file.

PslSourceLists.AddWithParser

Adds a new source file to the project and defines the parser that is to be used.

Syntax Expression.AddWithParser (FileName as Variant, Parser as String, optional Title as Variant, optional LangID as Variant) as PslSourceList Expression Required. Object of type PslSourceLists FileName Name of the new source file path. The path can be indicated absolutely or relative to the directory of the project file Parser Defines the parser. Title Title of the source string list. If it is omitted, the title will be generated from the FileName. LangID Language-ID of the strings in the source file. It can be either the LanguageID or the LanguageCode. If this argument is omitted, SDL Passolo will try to detect the language from the resources of the source file.

Example

PSL.ActiveProject.SourceLists.AddWithParser("c:\winnt\system32\notepad.exe", "Win32", _ "Notepad", pslLangEnglishUSA)

PslSourceList.Parser

Properties

PslSourceLists.Application

Returns the PassoloApp-Object, read-only property.

Syntax Expression.Application as PassoloApp Expression Required. Object of type PslSourceLists Object PassoloApp

SDL Passolo Automation 195 0 Reference

PslSourceLists.Count

Returns the number of source files of the project.

Syntax Expression.Count as Long Expression Required. Object of type PslSourceLists

Example

Dim prj As PslProject Set prj = PSL.Projects(1) PSL.Output "The project contains " & Str(prj.SourceLists.Count) & " source files"

PslSourceLists.Item

Item returns a source list contained in the PslSourceLists collection. The source list can be indicated by its index (1,...) or its title. Item is the standard function, so the name can be omitted.

Syntax Expression.Item (Index as PslTransList, LangID as VARIANT) as PslTransList Expression Required. Object of type PslTransLists Index Variant, Required. Either the index (1,...) of the source list or its title

Example

' Opens all source lists of the current project Dim prj As PslProject Set prj = PSL.ActiveProject Dim src As PslSourceList count = prj.SourceLists.Count For i = 1 To count Set src = prj.SourceLists(i) src.Open Next i

PslSourceLists.Parent

This property returns the parent object of type PslProject.

196 SDL Passolo Automation Reference 0

Syntax Expression.Parent as PslProject Expression Required. Object of type PslSourceLists Object PslProject Object PslSourceString

This object contains the data of an entry in the source string list.

Methods

PslSourceString.ChangeID

Modifies the ID of a string.

Syntax Expression.ChangeID (ID as VARIANT) as String Expression Object of type PslSourceString ID New ID of the String. It be either a numerical value or a string.

Note:

The ID identifies the string both in the source file and the target file. If the ID is changed, the string may no longer be relatable. So be careful using this function.

Changes in the string lists will not be saved automatically. To save the changes, one of the functions PslSourceList.Save or PslSourceList.Close has to be called.

PslSourceList.Save PslSourceList.Close

PslSourceString.GetOldRect

Returns the old coordinates (before last update) of the string object.

Syntax Expression.GetOldRect (X as LONG, Y as LONG, Cx as LONG, Cy as LONG, [optional] Type as Variant) as Boolean Expression Object of type PslSourceString Xx coordinate Yx coordinate

SDL Passolo Automation 197 0 Reference

Cx width Cy height Type One of these values: pslDlgUnits (default, Value = 0) returns coordinates in dialog units pslPixels (Value = 1) returns coordinates in pixels

PslSourceString.GetRect

Returns the current coordinates of the string object

Syntax Expression.GetRect (X as LONG, Y as LONG, Cx as LONG, Cy as LONG, [optional] Type as Variant) as Boolean Expression Object of type PslSourceString Xx coordinate Yx coordinate Cx width Cy height Type One of these values: pslDlgUnits (default, Value = 0) returns coordinates in dialog units pslPixels (Value = 1) returns coordinates in pixels

PslSourceString.GetTextCounts

Counts words, letters and characters in the text of this source string. The count results are stored in the returned PslStringCounter object.

Syntax Expression.GetTextCounts() as PslStringCounter Expression Required. Object of type PslSourceString

Example

Sub CompareWordCount(s As PslSourceString) Dim srccount As PslStringCounter Set srccount = t.GetSourceTextCounts() PSL.Output "Word count : " & CStr(srccount.WordCount) End Sub

Object PslStringCounter

198 SDL Passolo Automation Reference 0

Properties

PslSourceString.Attribute

This property is obsolete. Please use PslSourceString.Property. PslSourceString.Property

PslSourceString.Comment

Returns the comment of the string. The property can both be read and written.

Syntax Expression.Comment as String Expression Object of type PslSourceString

Note: Changes in the string lists will not be saved automatically. To save the changes, one of the functions PslSourceList.Save or PslSourceList.Close has to be called.

PslSourceList.Save PslSourceList.Close

PslSourceString.DateChanged

Returns the the date and the time when this source string has last been changed.

Syntax Expression.DateChanged as Date Expression Object of type PslSourceString

PslSourceString.DateCreated

Returns the the date and the time when this source string has first been read to the source string list.

Syntax Expression.DateCreated as Date Expression Object of type PslSourceString

SDL Passolo Automation 199 0 Reference

PslSourceString.Description

Returns a description of the string like "Editfield 1024 in Dialog 12"

Syntax Expression.Description as String Expression Object of type PslSourceString

PslSourceString.ID

Returns the ID of the string. The ID can either be a numerical value or a string.

Syntax Expression.ID as Variant Expression Object of type PslSourceString

Note: The ID of strings from resource type StringTable is a combination of the resource id and the item id. To calculate the string id use this formula:

Dim s As PslSourceString ... Dim id as Long id = s.ID If s.Resource.Type = "StringList" Then id = 16 * (s.Resource.ID - 1) + s.ID Else id = s.ID End If

Example

REM This example hides all strings with an id > 65000 Dim i As Long, count As Long, id As Long Dim src As PslSourceList Set src = PSL.ActiveSourceList If src Is Nothing Then MsgBox("Run this macro with an opened source list") Exit Sub End If count = src.StringCount For i = 1 To count With src.String(i) If(src.String(i).ResType = "StringTable") Then ' Calculate real ID id = 16 * (.Resource.ID - 1) + .ID If (id > 65000) Then .State(pslStateHidden) = True End If End If End With Next

200 SDL Passolo Automation Reference 0

PslSourceString.IDName

Returns the IDName of the string. The IDName is used in header files to substitute numerical IDs with a more meaningful symbolic representation. If this information is not available an empty string will be returned.

Syntax Expression.IDName as String Expression Object of type PslSourceString

PslSourceString.Number

Returns the number of the string, read-only property. The number is assigned when adding strings to the source list and will not be changed during further updates.

Syntax Expression.Number as long Expression Object of type PslSourceString

PslSourceString.OldText

Returns the old text (before last update) of the string.

Syntax Expression.OldText as String Expression Object of type PslSourceString

PslSourceString.OutputError

Outputs an error message to the log window. The user can jump to the source string with F4 or by double clicking on the error message.

Syntax Expression.OutputError( Text as String) as void Expression Object of type PslSourceString Text Text to be sent

SDL Passolo Automation 201 0 Reference

PslSourceString.ParserComment

Returns the comment extracted by the parser from the source file. The property is read-only.

Syntax Expression.ParserComment as String Expression Object of type PslSourceString

PslSourceString.Properties

Returns the PslProperties object that contains all custom properties of this PslSourceString.

Syntax Expression.Properties as PslProperties Expression Object of type PslSourceString Object PslProperties

PslSourceString.Property

Returns an internal or a custom property of the string.

Syntax Expression.Property (Name as Variant) as Variant Expression Object of type PslSourceString Name Name of the property. One of the predefined values below or a custom name. If the macro sets a new value, the property name must be between 10000 and 19999 or start with "M:" (see below) Predefined values are: pslPropClass (Value = -7): Class of the string pslPropExstyle (Value = -9): Extended style bits. pslPropStyle (Value = -8): Style bits. pslPropMaxLength (Value = -33): Max. length of translation string. pslPropMaxLines (Value = -53): Max. number of lines for translation string

202 SDL Passolo Automation Reference 0

Custom Properties

Custom Properties can be defined by parser add-ins, a macro or the user. All properties are in the same list, so they all can be accessed. To distinguish the types, different property names are used. When setting a property the macro is responsible for using the correct name, otherwise the property may be removed when updating string lists.

Type Integer Name String Name Add-In properties 1 - 9999 No prefix Macro properties 10000 - 19999 Uses prefix "M:" User-defined properties 20000 - 30000 Uses prefix "U:"

Example

Dim i As Long Dim selcount As Long Dim srcdisp As PslSourceDisplay Set srcdisp = PSL.ActiveSourceDisplay If Not srcdisp Is Nothing Then selcount = srcdisp.StringCount(pslSelection) For i = 1 To selcount s.Property(10001) = "abc" s.Property("M:myprop") = "def" Next i End If

PslSourceString.Resource

Returns the corresponding PslResource object, read-only property.

Syntax Expression.Resource as PslResource Expression Object of type PslSourceString Object PslResource

PslSourceString.ResType

Returns the resource type for the string. A list of all possible types can be found in the Appendix, read-only property.

SDL Passolo Automation 203 0 Reference

Syntax Expression.ResType as String Expression Object of type PslSourceString Appendix

PslSourceString.SourceList

Returns the source list that contains this source string.

Syntax Expression.SourceList as PslSourceList Expression Object of type PslSourceString

PslSourceString.State

Returns the status bits of the string.

Syntax Expression.State (State as Variant) as Boolean Expression Object of type PslSourceString State Name of the status value. The following values are possible: pslStateAllowUntag (Value = 30): The user may reset the tagged flag pslStateBookmark (Value = 8): The string has a bookmark pslStateChanged (Value = 2): The string was changed during one of the previous updates. pslStateCoordChanged (Value = 5): The string belongs to a dialog control, whose coordinates were changed during one of the previous updates pslStateCorrection (Value = 4): The string is a correction, so it needs not be translated once more. pslStateDeleted (Value = 9): The string has been deleted and is stored in the recycle bin. pslStateDoSegment (Value = 25): The string will be segmented when updating the source list pslStateHidden (Value = 3): The string is not visible for the translator. pslStateInvisible (Value = 31): The string is never shown, not in the source list and not in the translation list (read-only) pslStateNew (Value = 0): The string is new, it was added by one of the previous updates. pslStateReadOnly (Value = 1): The string may not be modified by the translator. pslStateTagged (Value = 29): The string contains tags pslStateTask (Value = 104): One or more tasks are linked to the string pslStateNoReplicate (Value = 18): The string is not used when translating replicates

204 SDL Passolo Automation Reference 0

pslStateVariableID (Value = 20): The ID of the string may change when updating the source list pslStateUnifyReplicates (Value = 200): The string has been marked as "unified replicate"

PslSourceString.Text

Returns the text of the string.

Syntax Expression.Text as String Expression Object of type PslSourceString

PslSourceString.Type

Returns the type of the string. A list of all possible types can be found in the Appendix. This is a read-only property.

Syntax Expression.Type as String Expression Object of type PslSourceString Appendix Object PslStatistics

Use PslTransList.GetStatistics to get statistical information about a translation list. PslTransList. GetStatistics

Methods none

Properties

PslStatistics.AutoTranslated

Returns counter information for all strings in the translation list that originate from machine translation. The counts are returned in an PslStringCounter object.

SDL Passolo Automation 205 0 Reference

Syntax Expression.AutoTranslated as PslStringCounter Expression Object of type PslStatistics Object PslStringCounter

PslStatistics.Fuzzy95_99

Returns counter information for all strings in the translation list that were translated with a 95% - 99% fuzzy match. The counts are returned in an PslStringCounter object.

Syntax Expression.Fuzzy95_99 as PslStringCounter Expression Object of type PslStatistics Object PslStringCounter

PslStatistics.Fuzzy85_94

Returns counter information for all strings in the translation list that were translated with a 85% - 94% fuzzy match. The counts are returned in an PslStringCounter object.

Syntax Expression.Fuzzy85_94 as PslStringCounter Expression Object of type PslStatistics Object PslStringCounter

Psl.Statistics.Fuzzy75_84

Returns counter information for all strings in the translation list that were translated with a 75% - 84% fuzzy match. The counts are returned in an PslStringCounter object.

Syntax Expression.Fuzzy75_84 as PslStringCounter Expression Object of type PslStatistics Object PslStringCounter

206 SDL Passolo Automation Reference 0

Psl.Statistics.Fuzzy30_74

Returns counter information for all strings in the translation list that were translated with a 30% - 74% fuzzy match. The counts are returned in an PslStringCounter object.

Syntax Expression.Fuzzy30_74 as PslStringCounter Expression Object of type PslStatistics Object PslStringCounter

PslStatistics.PreTranslated

Returns counter information for all strings in the translation list that are 100% matches. The counts are returned in an PslStringCounter object.

Syntax Expression.PreTranslated as PslStringCounter Expression Object of type PslStatistics Object PslStringCounter

PslStatistics.Repeats

Returns counter information for all strings repetitions that need to be translated. The counts are returned in an PslStringCounter object.

Syntax Expression.Repeats as PslStringCounter Expression Object of type PslStatistics Object PslStringCounter

PslStatistics.ToReview

Returns counter information for all strings in the translation list that need to be reviewed. The counts are returned in an PslStringCounter object.

Syntax Expression.ToReview as PslStringCounter Expression Object of type PslStatistics Object PslStringCounter

SDL Passolo Automation 207 0 Reference

PslStatistics.Total

Returns Counter information for all strings in the translation list. The counts are returned in an PslString- Counter object.

Syntax Expression.Total as PslStringCounter Expression Object of type PslStatistics Object PslStringCounter

PslStatistics.ToTranslate

Returns counter information for all strings in the translation list that need to be translated. The counts are returned in an PslStringCounter object.

Syntax Expression.ToTranslate as PslStringCounter Expression Object of type PslStatistics Object PslStringCounter

PslStatistics.Translatable

Returns counter information for all strings which are not hidden or marked as read only. The counts are returned in an PslStringCounter object.

Syntax Expression.Translatable as PslStringCounter Expression Object of type PslStatistics Object PslStringCounter

PslStatistics.Translated

Returns counter information for all strings in the translation list that are already translated. The counts are returned in an PslStringCounter object.

Syntax Expression.Translated as PslStringCounter Expression Object of type PslStatistics Object PslStringCounter

208 SDL Passolo Automation Reference 0

PslStatistics.Translation

Returns statistical information about changes (word count, letter count, …) by the translation. The counts are returned in an PslStringCounter object.

Syntax Expression.Translation as PslStringCounter Expression Object of type PslStatistics Object PslStringCounter Object PslStringCounter

This object contains counter information in terms of strings, words, letters and characters. Words are separated by white-spaces and punctuation characters. Characters contains the number of letter plus white-spaces and punctuation characters.

A PslStringCounter object is returned from PassoloApp.GetTextCounts or from one of the PslStatistic methods. PassoloApp.GetTextCounts Object PslStatistics

Methods none

Properties

PslStringCounter.CharCount

Contains the number for characters including white-spaces and punctuation characters.

Syntax Expression.CharCount as Long Expression Required. Object of type PslStringCounter

Example

Sub main Dim test As String test = "This is a test!!!" Dim counter As PslStringCounter Set counter = PSL.GetTextCounts(test) PSL.Output "Counting """ & test & """:" PSL.Output "StringCount = " & counter.StringCount PSL.Output "WordCount = " & counter.WordCount

SDL Passolo Automation 209 0 Reference

PSL.Output "LetterCount = " & counter.LetterCount PSL.Output "CharCount = " & counter.CharCount End Sub

Counting "This is a test!!!" StringCount = 1 WordCount = 4 LetterCount = 11 CharCount = 17

PslStringCounter.LetterCount

Contains the number of characters excluding white-spaces and punctuation characters.

Syntax Expression.LetterCount as Long Expression Required. Object of type PslStringCounter

Example

Sub main Dim test As String test = "This is a test!!!" Dim counter As PslStringCounter Set counter = PSL.GetTextCounts(test) PSL.Output "Counting """ & test & """:" PSL.Output "StringCount = " & counter.StringCount PSL.Output "WordCount = " & counter.WordCount PSL.Output "LetterCount = " & counter.LetterCount PSL.Output "CharCount = " & counter.CharCount End Sub

Counting "This is a test!!!" StringCount = 1 WordCount = 4 LetterCount = 11 CharCount = 17

210 SDL Passolo Automation Reference 0

PslStringCounter.StringCount

Contains the number of strings.

Syntax Expression.StringCount as Long Expression Required. Object of type PslStringCounter

Example

Sub main Dim test As String test = "This is a test!!!" Dim counter As PslStringCounter Set counter = PSL.GetTextCounts(test) PSL.Output "Counting """ & test & """:" PSL.Output "StringCount = " & counter.StringCount PSL.Output "WordCount = " & counter.WordCount PSL.Output "LetterCount = " & counter.LetterCount PSL.Output "CharCount = " & counter.CharCount End Sub

Counting "This is a test!!!" StringCount = 1 WordCount = 4 LetterCount = 11 CharCount = 17

PslStringCounter.WordCount

Contains the number of words delimited by white-spaces and punctuation characters.

Syntax Expression.WordCount as Long Expression Required. Object of type PslStringCounter

Example

Sub main Dim test As String test = "This is a test!!!" Dim counter As PslStringCounter Set counter = PSL.GetTextCounts(test) PSL.Output "Counting """ & test & """:" PSL.Output "StringCount = " & counter.StringCount PSL.Output "WordCount = " & counter.WordCount PSL.Output "LetterCount = " & counter.LetterCount

SDL Passolo Automation 211 0 Reference

PSL.Output "CharCount = " & counter.CharCount End Sub

Counting "This is a test!!!" StringCount = 1 WordCount = 4 LetterCount = 11 CharCount = 17 Object PslTask

This object represents a single task as displayed in the task page of output window.

Methods none

Properties

PslTask.Application

Returns the Application Object.

Syntax Expression.Application as IDispatch Expression Object of type PslTask

PslTask.Comment

Contains the comment of the task.

Syntax Expression.Comment as String Expression Object of type PslTask

212 SDL Passolo Automation Reference 0

PslTask.Done

Contains the finished-state of the task. If a task is done it is striked out in the task list.

Syntax Expression.Done as Boolean Expression Object of type PslTask

PslTask.DueDate

Contains the due date of the task. Expired Tasks are displayed in red.

Syntax Expression.DueDate as Date Expression Object of type PslTask

PslTask.Link

Contains the linked object of the task. An object can only be returned if it is currently loaded. I.e. if a common task is linked to an string list of an project that is not loaded the Link property returns NULL. If you set the link, make sure to link to an object from the same project as the task.

Possible objects are: PslProject, PslSourceString PslTransList PslResource PslSourceString PslTransString.

Syntax

Expression.Link as Object Expression Object of type PslTask

Object PslProject Object PslSourceString Object PslTransList Object PslResource Object PslTransString

PslTask.Number

Contains the number of the task.

Syntax Expression.Comment as Long Expression Object of type PslTask.

SDL Passolo Automation 213 0 Reference

Object PslTasks

This object represents a single task as displayed in the task page of output window.

Methods

PslTasks.Add

Adds a new task to the task collection.

Sntax Expression.Add (Comment as String, Link as Object, DueOn as Date) as PslTask Expression Object of type PslTasks Comment The comment of the new task Link Optional, the object linked to the task. Allowed objects are: PslProject, PslSourceString PslTrans- List PslResource PslSourceString PslTransString. Make sure that the object belongs to the same project as the task. DueOn Optional, the due date of the task Object PslProject Object PslSourceString Object PslTransList Object PslResource Object PslTransString

PslTasks.Delete

Deletes a task from the PslTasks collection.

Syntax Expression.Delete (Index as Variant) as PslTask Expression Object of type PslTasks Index The index of the task (1, ...) or the PslTask object itself

Properties

214 SDL Passolo Automation Reference 0

PslTasks.Application

Returns the Application Object.

Syntax Expression.Application as IDispatch Expression Object of type PslTasks

PslTasks.Count

Returns the number of tasks in this PslTasks collection.

Syntax Expression.Count as Integer Expression Object of type PslTasks

PslTasks.Item

Item returns a task contained in the PslTasks collection. The task is indicated by its index (1,...). Item is the standard function, so the name can be omitted.

Syntax Expression.Item (Index as Variant) as PslTask Expression Object of type PslTasks Index The index of the task. The first task has the index 1 Object PslTransBundle

This object is returned from PslProject.PrepareTransBundle to collect the files, glossaries and macros that are added to a translation bundle. It can also be used to collect files for an export in another format. PslProject.PrepareTransBundle

Methods

SDL Passolo Automation 215 0 Reference

PslTransBundle.AddAllProjectUserFiles

Adds all current user files from the project to the translation bundle.

Syntax Expression.AddAllProjectUserFiles() as Boolean Expression Object of type PslTransBundle.

PslTransBundle.AddGlossary

Adds a glossary to the translation bundle. The glossary can be indicated with its file path or as PslGlossary-Object.

Syntax Expression.AddGlossary (Glossary as Variant) as Boolean Expression Object of type PslTransBundle Glossary Path of a glossary file or PslGlossary-Object.

Example see PslProject.ExportTransBundle Object PslGlossary PslProject.ExportTransBundle

PslTransBundle.AddMacro

Adds a macro to the translation bundle.

Syntax Expression.AddMacro (Macro as String) as Boolean Expression Object of type PslTransBundle Macro Name of a macro file. PslProject.ExportTransBundle

PslTransBundle.AddOptions

Adds an options profile or an option file to the translation bundle. These options will be used when the translator opens the translation bundle.

216 SDL Passolo Automation Reference 0

Syntax Expression.AddUserFile (ProfileOrPath as String) as Boolean Expression Object of type PslTransBundle. ProfileOrPath An profile name or the path to an option file. To create an profile or an option file use the Export command in the SDL Passolo options dialog. If ProfileOrPath is "@" then the current options are used.

PslTransBundle.AddTransList

Syntax Expression.AddTranslist (StringList as Object) as Boolean Expression Object of type PslTransBundle StringList A PslSourceList or a PslTransList to be added to the translation bundle. The string list must be part of the project, that created the translation bundle. (The name of the function AddTransList is for backward compatibility. Now you can add also source lists to a translation bundle) Object PslSourceList Object PslTransList PslProject.ExportTransBundle

PslTransBundle.AddUserFile

Adds an arbitrary file to the bundle.

Syntax Expression.AddUserFile (FileName as String) as Boolean Expression Object of type PslTransBundle. Name Path of the file to be added. If you want to add a user file, that is already embedded in the project, omit the directory and indicate only the name of the file.

PslTransBundle.License

Licenses the translation bundle for beeing editable by the SDL Passolo Translator Edition.

Syntax Expression.License (Comment as String) as Boolean Expression Object of type PslTransBundle. Comment You can set a comment that helps to keep track of your licenses.

SDL Passolo Automation 217 0 Reference

PslTransBundle.MarkAsExported

If this property is FALSE the exported translation lists will not be marked as "exported" when writing the translation bundle. The translation lists will stay editable, but the translation bundle cannot be imported again.

If this property is TRUE (this is the default) all translation lists that are written to the translation bundle are marked as "exported".They are read-only until the bundle has been imported.

Syntax Expression.MarkAsExported as Boolean Expression Object of type PslTransBundle.

PslTransBundle.RemoveRight

Removes one or more of the rights for the translator that works with the translation bundle.

Syntax Expression.RemoveRight (Right as Integer) as Boolean Expression Object of type PslTransBundle Right Specifies the right to remove. You can combine the values by adding them to remove multiple rights pslRightTranslateNew (Value = 1): Translate new texts (red) pslRightTranslateForReview (Value = 16): Modify "for review" texts (blue/green) pslRightTranslateValid (Value = 2): Modify validated texts (black) pslRightLayout (Value = 4): Modify dialog layout pslRightValidate (Value = 8): Validate translated texts pslRightUnlock (Value = 32): Unlock strings pslRightEditBinaries (Value = 256): Edit binaries

PslTransBundle.SetComment

Set an arbitrary comment string for the translation bundle.

218 SDL Passolo Automation Reference 0

Syntax Expression.SetComment (Comment as String, Display) as Boolean Expression Object of type PslTransBundle Comment Arbitrary comment string Display Set this parameter to TRUE to display the comment automatically when the translation bundle is opened.

PslTransBundle.SetRefLanguage

Adds an additional column to the string lists in the translation bundle, that contains the text of another translation list.

Syntax Expression.SetRefLanguage(Language as Variant, Type as Integer) Expression Object of type PslTransBundle Language Language ID or a PslLanguage object that defines the language to add. Type One of these values reflangReference (value = 1): The language is added as additional column. reflangAlternative (value = 2): The language replaces the source language. Make sure, that the translation lists for that language are completely translated.

Example

... bundle.SetRefLanguage(pslLangGerman, reflangReference)

Object PslLanguage

PslTransBundle.SplitBundle

Splits the translation bundle in parts. Each part allows access to another block of strings. Other strings are set to read-only.

Syntax Expression.AddUserFile (Mode as Long, Value as Long) as Boolean Expression Object of type PslTransBundle. Mode Defines the split mode. It is pslSplitBundleParts (Value = 0), splits the bundle in parts of equal word amount. The parameter Value defines the number of parts.

SDL Passolo Automation 219 0 Reference

pslSplitBundleDialogs (Value = 2), splits the bundle in two parts: One containing dialogs and one containing other resources. The parameter Value is ignored. Value A value for additional information, depending on the Mode. Object PslTransDisplay

PslTransDisplay represents the display of one or more translation lists in a SDL Passolo string window.

Methods none

Properties

PslTransDisplay.String

Returns a PslTransString object from this string list window. This string belongs to any of the string lists that are currently opened.

Syntax Expression.String (Index as VARIANT, optional Type as VARIANT) as PslSourceString Expression Object of type PslTransList Index Depending on the Type this is either an index or a number. Type Can be one of the following values: pslIndex (default, Value = 0): An arbitrary string is returned. Index is the Index of the string, correspond- ing to all existing undeleted strings. The first string has got the Index 1. pslIndexDeleted (Value = 4): Works like pslIndex but returns deleted strings from the recycle bin. pslDisplay (Value = 1): A string from the current display is returned. Index is the Index of the string, corresponding to all displayed strings. The first string has got the Index 1. pslSelection (Value = 2): A selected string from the current display is returned. Index is the Index of the string, corresponding to all selected strings. The first selected string has got the Index 1. Object PslTransString Object PslTransList

220 SDL Passolo Automation Reference 0

PslTransDisplay.StringCount

Returns the number of strings in the translation list window. The number refers to all string lists, that are currently opened.

Syntax Expression.StringCount (optional Type as VARIANT) as Long Expression Object of type PslTransDisplay Type Can be one of the following values: pslIndex (default, Value = 0): The total number of (undeleted) strings will be returned. pslIndexDeleted (Value = 4): The total number of deleted strings in the recycle bins will be returned. pslDisplay (Value = 1): The number of displayed strings will be returned. pslSelection (Value = 2): The number of selected strings will be returned. Object PslTranslation

This object contains a translation consisting of a source and a target text.

Methods none

Properties

PslTranslation.Match

Quality of match between 0 and 100. 100 is a perfect match.

Syntax Expression.Match as Long Expression Object of type PslTranslation

SDL Passolo Automation 221 0 Reference

PslTranslation.Origin

Returns the original translation.

Syntax Expression.Origin as String Expression Object of type PslTranslation

PslTranslation.SourceString

For this string PslTranslation.TransString is the translation.

Syntax Expression.SourceString as String Expression Object of type PslTranslation

PslTranslation.TransString

The translation of PslTranslation.SourceString.

Syntax Expression.TransString as String Expression Object of type PslTranslation Object PslTranslations

This object is used to keep a collection of translation for a given source string. If you implement the event handler PassoloApp.OnAutoTranslate you can add translations for the source string which will be used by Passolo during automatic translation. PassoloApp.OnAutoTranslate

Methods

PslTranslations.Add

Adds a translation to the collection of translations.

222 SDL Passolo Automation Reference 0

Syntax Expression.Add (TransString as Variant, [optional] SourceString as Variant, [optional] Match as Variant, [optional] Origin as Variant) as PslTranslation Expression Object of type PslTranslations TransString the translated string SourceString the source string Match quality of match between translation found and SourceString Origin Origin of translation. Can be a tool name

Example

Public Sub PSL_OnAutoTranslate(Translations As PslTranslations, _ ByVal MinMatch As Long, _ ByVal MaxCount As Long) Dim tu As TranslationUnit, i As Integer If TW3Mem Is Nothing Then Exit Sub TW3Mem.Search (Translations.SourceString) Set tu = TW3Mem.TranslationUnit For i = 1 To TW3Mem.HitCount Translations.Add(tu.Target, tu.Source, tu.Score, "TW2Win") TransUnit.Next Next i End Sub

PslTranslations.Item

Item returns a translation contained in the PslTranslations collection.

Syntax Expression.Item (Index as Variant) as PslTranslation Expression Object of type PslTranslations Index Index of the translation

PslTranslations.Remove

Removes a translation.

SDL Passolo Automation 223 0 Reference

Syntax Expression.Remove (Index as Variant) as void Expression Object of type PslTranslations Index Index of the translation

Properties

PslTranslations.Application

Returns the Application Object.

Syntax Expression.Application as IDispatch Expression Object of type PslTranslations

PslTranslations.Count

Returns the count.

Syntax Expression.Count as Long Expression Object of type PslTranslations

PslTranslations.Parent

Returns the Parent Object.

Syntax Expression.Parent as IDispatch Expression Object of type PslTranslations

224 SDL Passolo Automation Reference 0

PslTranslations.SourceLangID

Returns the language ID of the source list.

Syntax Expression.SourceLangID as Integer Expression Object of type PslTranslations

PslTranslations.SourceString

Returns the source string of the translation.

Syntax Expression.SourceString as String Expression Object of type PslTranslations

PslTranslations.StringType

Returns the type of string of SourceString. This information can be used to determine the correct translation if more than one translations are available.

Syntax Expression.StringType as String Expression Object of type PslTranslations

PslTranslations.TargetLangID

Returns the LanguageID for the target language.

Syntax Expression.TargetLangID as Integer Expression Object of type PslTranslations Object PslTransList

PslTransList represents a translation list. It offers methods to perform operations on the translation list and attributes to access each resource string.

SDL Passolo Automation 225 0 Reference

Methods

PslTransList.AutoTranslate

Executes the command Auto-Translate for this string list.

Expression.AutoTranslate (Range as Variant, Retranslate as Variant, MarkForReview as Variant, Multi- Type as Variant) as Long

Expression Required. Object of type PslTransList

Range Variant, optional. Specifies the range of strings to be translated. Possible values are • pslAll (default, value = 0)all strings • pslDisplay (value = 1) displayed strings, therefore the string list has to be open. These values can be added to specify how strings are matched (default is "exact match") • pslIgnoreCase (value = 256) translations are accepted even if the source strings differ regarding the use of upper and lower case. • pslIgnoreAmpersand (value = 512) translations are accepted even if the source strings differ regarding the use of the ampersand to specify the access key. • pslIgnoreSpaces (value = 1024) translations are accepted even if the source strings differ regarding the use of leading and trailing spaces. • pslIgnorePunctuation (value = 2048) translations are accepted even if the source strings differ regarding the use of leading and trailing punctuation marks. • pslIgnoreAll (value = 3840) The combination of all other pslIgnore... values Retranslate Variant, optional. Specifies, if strings that already were translated, have to be translated again. The default value is False

MarkForReview Variant, optional. Specifies, if the translated strings will be marked with the review flag. The default value is True.

MultiType Variant, optional. Specifies how PASSOLO acts, if muliple translations are found. pslMultiTakeFirst (default, value = 0): PASSOLO uses the first translation found. pslMultiNoTranslation (value = 1): PASSOLO does'n translate the string. pslMultiSetBookmark (value = 2): PASSOLO does'n translate the string, but sets a bookmark. pslMultiPrompt (value = 3): PASSOLO displays all translations for selection by the user

226 SDL Passolo Automation Reference 0

PslTransList.Check

Performs a check on this translation list. If errors are found they are written to the output window. The error messages can be accessed with the object PslOutputWnd. Check returns the number of errors.

Syntax Expression.Check() as Long Expression Required. Object of type PslTransList

PslTransList.Close

Closes the string list if it is open.

Syntax Expression.Close (savechanges) as Boolean Expression Required. Object of type PslTransList savechanges Variant, optional. Specifies the method of handling the string list, if it was changed but not yet saved. The following values are possible: • pslSaveChanges (default, Value = 0) : The string list will be saved. • pslPromptToSaveChanges (Value = 1): Message will be displayed, so that the user can decide, if he wants to save the string list or not. • pslPromptWithCancel (Value = 2): A message will be displayed similar to pslPromptToSaveChanges. Additionally the message will contain a [Cancel]-Button, so that the user can stop closing the string list. • pslDoNotSaveChanges (Value = 3): The string list will be closed without saving the changes.

PslTransList.CreateSimulation

Creates a translation list, that is a copy of this translation list with simulated translations. If this is already a simulation list, then the simulated strings are newly calculated. It returns a reference to the simulation list.

Syntax Expression.CreateSimulation as PslTransList Expression Required. Object of type PslTransList

SDL Passolo Automation 227 0 Reference

Example

' Creates a simulation of the current translation list ' and opens it Dim trn As PslTransList Set trn = PSL.ActiveTransList If Not trn Is Nothing Then Dim trnSim As PslTransList Set trnSim = trn.CreateSimulation If Not trnSim Is Nothing Then trnSim.Open End If End If

PslTransList.DecorateText

Adds additional leading or trailing characters to Text. Which characters are added depends on the settings in the tab Edit in the dialog Options.

Syntax Expression.DecorateText (Text as String, RefText as String) as void Expression Required. Object of type PslTransList Text Text to be extended RefText RefText is used as a pattern to determine the characters to be added.

Example

Dim Text As String Text = "Öffnen" PSL.ActiveTransList.DecorateText(Text, "Open...") ' Should display "Öffnen... " MsgBox(Text)

PslTransList.Delete

Deletes the translation list from a specified file. Returns True, if the operation was successful. False indicates an error.

Syntax Expression.Delete() as Boolean Expression Required. Object of type PslTransList

228 SDL Passolo Automation Reference 0

PslTransList.Export

Exports the translation list to a specified file. If the export functions has options, the last options set manually will be used for the export. Returns True, if the operation was successful. False indicates an error.

To export multiple string lists to one export file (if the export format supports this), use Object PslTrans- Bundle to collect the string lists and export with PslProject.Export.

Syntax Expression.Export (Format as String, FileName as String, Range as Variant) as Boolean Expression Required. Object of type PslTransList Format Identifier of the add-in which is used for export. The add-in list in SDL Passolo displays the identifier of each add-in. These are the add-ins that are shipped with Passolo: • "Glossary Export" • "PASSOLO Glossary Maker" • "TMX Export" • "STAR TermStar Export" • "TRADOS MultiTerm" • "TRADOS MultiTerm iX" • "PASSOLO Customizable Text Export" • "SDL Passolo XML Export/Import" • "Trados Text Export" To export a translation bundle, use PslProject.ExportTransBundle FileName Name of the export file Range One of these values • expAll (default) - export all (undeleted) strings • expAllDeleted - exports all strings including the deleted strings • expDisplay - exports only displayed strings • expSelected - exports only selected strings Object PslTransBundle PslProject.Export PslProject.ExportTransBundle

PslTransList.FindID

Returns a PslTransString with a given ID.

SDL Passolo Automation 229 0 Reference

Syntax Expression.FindID (ID as VARIANT, Index as Long) as PslTransString Expression Object of type PsTransList ID The ID you're looking for Index Set to 1 to find the first token with ID. Increase the number to find following tokens with that ID.

Example

' Find all translation strings with the ID 100 Dim trn As PslTransList Set trn = PSL.ActiveTransList If Not trn Is Nothing Then Dim t As PslTransString Dim index As Long index = 1 While True Set t = trn.FindID(100, index) If t Is Nothing Then Exit While PSL.Output Str(t.Number) index = index + 1 Wend End If

Object PslTransString

PslTransList.GenerateTarget

Generates the target list from the translation list. Returns True, if the operation was successful. False indicates an error.

Syntax Expression.GenerateTarget as Boolean Expression Required. Object of type PslTransList

PslTransList.GetConcordances

Returns a list of concordances for one string. The function will search through all concordance providers as set up in the SDL Passolo options. But, in contrast to the Passolo application this function only uses translation providers that are capable of return synchronous results.

The source and target language of this translation list are used for the search.

230 SDL Passolo Automation Reference 0

Syntax Expression.TranslateText (Text as String, MinMatch as Variant, MaxCount as Variant) as PslTranslations Expression Required. Object of type PslTransList Text String, Required. Concordances of this string are searched. MinMatch Variant, optional. Specifies the minimum match required. The default value is 100, so that the function searches for exact matches by default. MaxCount Variant, optional. Specifies the maximum number of segments to be returned.

Note: The list of concordances will be returned as an PslTranslations object which contains all concor- dances found.

Example

Sub Main ' Clear the output window PSL.OutputWnd(pslOutputWndMessages).Clear Dim trnlist As PslTransList Set trnlist = PSL.ActiveTransList If trnlist Is Nothing Then PSL.Output("No (single) active trans list found") Exit Sub End If Dim ts As PslTranslations Dim t As PslTranslation ' Concordances PSL.Output("Concordances------") Set ts = trnlist.GetConcordances("Open", 100) For Each t In ts PSL.Output t.TransString & " (" & t.Origin & ")" Next End Sub

Object PslTranslations

PslTransList.GetStatistics

Returns statistical information about the translation list in a PslStatistics object.

Syntax Expression.GetStatistics as PslStatistics Expression Required. Object of type PslTransList

SDL Passolo Automation 231 0 Reference

Example

Public Sub PSL_OnCloseTransList(TransList As PslTransList) Dim ps As PslStatistics Set ps = TransList.GetStatistics If ps.ToTranslate.StringCount <> 0 Then MsgBox("You have to come back to this translation list!") End If End Sub

Object PslStatistics

PslTransList.GetTerminology

Returns a list of terminology items for one string. The function will search through all terminology providers as set up in the SDL Passolo options. But, in contrast to the Passolo application this function only uses translation providers that are capable of return synchronous results.

The source and target language of this translation list are used for the search.

Syntax Expression.TranslateText (Text as String, MinMatch as Variant, MaxCount as Variant) as PslTranslations Expression Required. Object of type PslTransList Text String, Required. This term to look for. Note: this is a single term, not a segment containing several terms. MinMatch Variant, optional. Specifies the minimum match required. The default value is 100, so that the function searches for exact matches by default.

Note: The list of terminology will be returned as an PslTranslations object which contains all terms found.

Example

Sub Main ' Clear the output window PSL.OutputWnd(pslOutputWndMessages).Clear Dim trnlist As PslTransList Set trnlist = PSL.ActiveTransList If trnlist Is Nothing Then PSL.Output("No (single) active trans list found") Exit Sub End If Dim ts As PslTranslations Dim t As PslTranslation ' Terminology PSL.Output("Terminology------") Set ts = trnlist.GetTerminology("Open", 100) For Each t In ts PSL.Output t.TransString & " (" & t.Origin & ")" Next End Sub

Object PslStatistics

232 SDL Passolo Automation Reference 0

PslTransList.Import

Imports the translation list from a specified file. Returns True, if the operation was successful. False indicates an error.

Syntax Expression.Import (Format as String, FileName as String, MarkForReview as Variant) as Boolean Expression Required. Object of type PslTransList Format Identifier of the add-in which is used for import. The add-in list in SDL Passolo displays the identifier of each add-in. These are the add-ins that are shipped with Passolo and be used for import: • "PASSOLO Customizable Text Export" • "SDL Passolo XML Export/Import" • "Trados Text Export" FileName Name of the file to be imported Flags Some options to control the import. To combine flags, add the values: • pslImportValidate (Value = 256):Text-based imports only: The strings will be validated after importing the translation. • pslImportMerge (Value = 512): Translation bundles only: The translations in the bundle are merged with the existing translations in the project. If you are importing a licensed translation bundle, you can merge only if you use an unlimited Team Edition of Passolo. • pslImportRelease (Value = 1024): Translation bundles only: Imported string lists are released after import. If this flag is not set, the translation list in the project remains marked as "exported".

PslTransList.Leverage

Performs a leverage operation for this translation list. The current leverage options are used.

Syntax Expression.Leverage (ProjectFile as String) as Boolean Expression Required. Object of type PslTransList ProjectFile Path of the project file that is the source for the leverage. PASSOLO opens this project and - if it finds a matching translation list - it transfers data from this project.

PslTransList.Open

Opens the string list.

SDL Passolo Automation 233 0 Reference

Syntax Expression.Open as Boolean Expression Required. Object of type PslTransList

PslTransList.Save

Saves the string list if it was changed.

Syntax Expression.Save as Boolean Expression Required. Object of type PslTransList

PslTransList.ScanTargetFile

Scans a target file and aligns the resource data with the translation list. The result is a translation list which contains the translated text and attributes of the scanned file.

Syntax Expression.ScanTargetFile (TargetFile as String, TargetLangID as Integer, optional ScanFlags as VARIANT) as Boolean Expression Object of type PsTransList TargetFile Name of the file to be scanned. The resource structure of this file should match structure of the source file. TargetLangID Only resources with this resource language are extracted. ScanFlags This parameter can be one or more of the following values. If this parameter is omitted, the default flags are set. • pslScanOverwrite (Value = 1, default) : If set, existing translation will be overwritten with the translation found in the scanned file. • pslScanValidate (Value = 4): If set, each string that is modified will be validated. Otherwise the string is marked as "translated automatically" (green) • pslScanAllTranslated (Value = 8): If set, all strings in the target file are treated as translated, i.e. even if the string in the target file equals the source string, it is set to translated. • pslScanText (Value = 16): If set, the text of a string is read from the target file • pslScanCoord (Value = 32): If set, the text of a string is read from the target file • pslScanProperties (Value = 64): If set, the custom properties a string is read from the target file If you don't set pslScanText, pslScanCoord or pslScanProperties then all data is read from the target file (like combining these three options).

234 SDL Passolo Automation Reference 0

PslTransList.SetTargetPathRule

Assigns a target path rule to the source list.

Syntax Expression.Leverage (Id as Long, bLink as Boolean, [optional] Parser as String) as Boolean Expression Object of type PslTransList Id ID of the target path rule as returned by PslProject.AddTargetPathRule or index if this is a rule from a parser add-in bLink True, if the source list should be linked to the target path rule, i.e. the target path will be calculated automatically and cannot be changed manually. Parser optional, if set, the target path rule is from a parser and ID is the index. Parser has the format "Addin :", see table below.

Standard Add-In defined Target Path Rules

Parser ID Rule Name Description (Index)

AddIn:Java File Parser 0 Java Lang_Region Naming conventions for Java file types *.class, *.java, *properties 1 Multilingual Java archive Naming conventions for Java *.jar files "AddIn:Borland 0 Borland Language DLLs Naming conventions for Borland Delphi/C++ Builder" Language DLLs 1 Borland .NET Language Naming conventions for Borland .NET DLLs Language DLLs "AddIn:Microsoft .NET 0 .NET Assemblies Naming conventions for .NET Satellite Parser" Assemblies 1 .NET Resources Naming conventions for .NET resx-files 2 .NET Satellite Assemblies Naming conventions for translation of .NET Satellite Assemblies

PslProject.AddTargetPathRule PslSourceList.SetTargetPathRule

PslTransList.SimulateTranslation

Generates the target list from simulated translations. The current settings from the application options are used. Returns True, if the operation was successful. False indicates an error.

SDL Passolo Automation 235 0 Reference

Syntax Expression.SimulateTranslation as Boolean Expression Required. Object of type PslTransList

PslTransList.TranslateText

Returns a list of translations for one string. Depending on MinMatch it looks for pre-translations or fuzzy matches. The function will search through all translation providers as set up in the SDL Passolo options. But, in contrast to the Passolo application this function only uses translation providers that are capable of return synchronous results.

The source and target language of this translation list are used for the search.

Syntax Expression.TranslateText (Text as String, MinMatch as Variant, MaxCount as Variant) as PslTranslations Expression Required. Object of type PslTransList Text String, Required. This string will be translated. MinMatch Variant, optional. Specifies the minimum match required. The default value is 100, so that the function searches for pre-translations. A value less then 100 will look for fuzzy matches. MaxCount Variant, optional. Specifies the maximum number of translations to be returned. The default value is 10.

Note: The list of translations will be returned as an PslTranslations object which contains all translations found.

Example

Sub Main ' Clear the output window PSL.OutputWnd(pslOutputWndMessages).Clear Dim trnlist As PslTransList Set trnlist = PSL.ActiveTransList If trnlist Is Nothing Then PSL.Output("No (single) active trans list found") Exit Sub End If Dim ts As PslTranslations Dim t As PslTranslation ' Pretranslation PSL.Output("Pre-Translation------") Set ts = trnlist.TranslateText("Resources: ", 100) For Each t In ts PSL.Output t.TransString & " (" & t.Origin & ")" Next ' Fuzzy Matches PSL.Output("Fuzzy Matches------") Set ts = trnlist.TranslateText("&File", 80) For Each t In ts PSL.Output t.TransString & " (" & t.Origin & ")" Next

236 SDL Passolo Automation Reference 0

End Sub

Object PslTranslations

PslTransList.UndecorateText

Removes additional leading or trailing characters from Text. Which characters are removed depends on the settings in the tab Edit in the dialog Options.

Syntax Expression.UndecorateText (Text as String) as void Expression Required. Object of type PslTransList Text Text to be changed

Text = "Open..." PSL.ActiveTransList.UndecorateText(Text) ' Should display "Open" MsgBox(Text)

PslTransList.Update

Creates or updates the translation list. Return True, if the update was successful and False, if the update failed.

Syntax Expression.Update as Boolean Expression Required. Object of type PslTransList

PslTransList.UnDelete

Restores the translation list. Returns True, if the operation was successful. False indicates an error.

Syntax Expression.UnDelete() as Boolean Expression Required. Object of type PslTransList

SDL Passolo Automation 237 0 Reference

PslTransList.UnExport

Releases the string list if is currently exported to a translation bundle. After that the string list cannot be imported anymore. Returns True, if the un-export was successful and False, if the string list has not been exported.

Syntax Expression.Update as Boolean Expression Required. Object of type PslTransList

Properties

PslTransList.ExportDate

If the translation list has been exported as part of a translation bundle, this property returns the time of the export.

Syntax Expression.ExportDate as Date Expression Required. Object of type PslTransList

PslTransList.ExportFile

If the translation list has been exported as part of a translation bundle, this property returns the path of the translation bundle.

Syntax Expression.FileFile as String Expression Required. Object of type PslTransList

PslTransList.FileDate

Returns the the time stamp of the target file.

238 SDL Passolo Automation Reference 0

Syntax Expression.FileDate as Date Expression Required. Object of type PslTransList

PslTransList.IsDeleted

Returns True, if this translation list has been deleted and is not shown in the project window.

Syntax Expression.IsDeleted as Boolean Expression Required. Object of type PslTransList

PslTransList.IsOpen

Returns True, if the string list is open.

Syntax Expression.IsOpen as Boolean Expression Required. Object of type PslTransList

PslTransList.IsSimulation

Returns True, if this is a translation list with simulated translations.

Syntax Expression.IsSimulation as Boolean Expression Required. Object of type PslTransList PslTransList.CreateSimulation

PslTransList.Language

Returns the target language as a PslLanguage object.

Syntax Expression.Language as PslLanguage Expression Required. Object of type PslTransList Object PslLanguage

SDL Passolo Automation 239 0 Reference

PslTransList.LastChange

Returns the date and the time when this translation list has last been changed by editing tokens or resources.

Syntax Expression.LastChange as Date Expression Required. Object of type PslTransList

Example

' Generate all target files, that are not up to date For Each trn In PSL.ActiveProject.TransLists If trn.LastChange > trn.LastGeneration Then trn.GenerateTarget End If Next trn

PslTransList.LastGeneration

Returns the date and the time when the target file has last been generated.

Syntax Expression.LastGeneration as Date Expression Required. Object of type PslTransList

Example

' Generate all target files, that are not up to date For Each trn In PSL.ActiveProject.TransLists If trn.LastChange > trn.LastGeneration Then trn.GenerateTarget End If Next trn

PslTransList.LastUpdate

Returns the date and the time when this translation list has last been updated.

240 SDL Passolo Automation Reference 0

Syntax Expression.LastUpdate as Date Expression Required. Object of type PslTransList

Example

' Update all translation lists that need to be updated For Each trn In PSL.ActiveProject.TransLists If trn.SourceList.LastChange > trn.LastUpdate Then trn.Update End If Next trn

PslTransList.ListID

Returns the numerical ID that SDL Passolo uses to identify a string list.

Syntax Expression.ListID as Long Expression Required. Object of type PslTransList

PslTransList.Parser

Returns the parser used for parsing the source file of this translation list.

Syntax Expression.Parser as String Expression Required. Object of type PslTransList

Note: The parser is defined by a string with this format:

Name Comment Example "Win32" Internal parser for Win32 .exe "Win32" and .dll files. "Addin:" Uses a parser addin. The add-in "AddIn:Borland Delphi/C++ list in the PASSOLO options Builder" "AddIn:Text Parser" pages displays the identifier of each add-in. "Macro: Uses a macro. is "Macro:PslIniScan" the file name of the macro file without extension.

SDL Passolo Automation 241 0 Reference

PslTransList.Properties

Returns the PslProperties object that contains all custom properties of this PslTransList.

Syntax Expression.Properties as PslProperties Expression Object of type PslTransList Object PslProperties

PslTransList.Property

Returns a custom property of the string list.

Syntax Expression.Property (Name as Variant) as Variant Expression Object of type PslTransList Name Name of the property. If the macro sets a new value, the property name must be between 10000 and 19999 or start with "M:" (see below)

Custom Properties

Custom Properties can be defined by parser add-ins, a macro or the user. All properties are in the same list, so they all can be accessed. To distinguish the types, different property names are used. When setting a property the macro is responsible for using the correct name, otherwise the property may be removed when updating string lists.

Type Integer Name String Name Add-In properties 1 - 9999 No prefix Macro properties 10000 - 19999 Uses prefix "M:" User-defined properties 20000 - 30000 Uses prefix "U:"

Example

Dim trn As PslTransList Set trn = PSL.ActiveTransList If not trn Is Nothing Then trn.Property(10001) = "Hello!" psl.Output(trn.Property(10001)) End If

242 SDL Passolo Automation Reference 0

PslTransList.Resource

Returns a PslResource object from this list. If the list is still closed, it will be opened.

Syntax Expression.Resource (Index as VARIANT, optional Type as VARIANT) as PslResource Expression Object of type PslTransList Index Depending on the Type this is either an index or a number. Type Can be one of the following values: • pslIndex (default, Value = 0): An arbitrary resource is returned. Index is the Index of the resource, corresponding to all existing undeleted resources. The first resource has got the Index 1. • pslIndexDeleted (Value = 4): Works like pslIndex but returns deleted resources from the recycle bin. • pslNumber (Value = 3): An arbitrary resource is returned. Index is the Number of the string. Note: Each string list resource in a Win32 files contains max. 16 strings. PASSOLO displays all string list resources as a single resource, but with this function you access the original string list resources.

Object PslResource

PslSourceList.ResourceCount

Returns the number of resources in this list. If the list is still closed, it will be opened.

Syntax Expression.ResourceCount (optional Type as VARIANT) as Long Expression Object of type PslTransList Type Can be one of the following values: • pslIndex (default, Value = 0): The total number of (undeleted) resources will be returned. • pslIndexDeleted (Value = 4): The total number of deleted resources in the recycle bin will be returned.

Note: Each string list resource in a Win32 files contains max. 16 strings. PASSOLO displays all string list resources as a single resource, but with this function you access the original string list resources.

SDL Passolo Automation 243 0 Reference

PslTransList.Project

Returns the corresponding PslProject object, read-only property.

Syntax Expression.Project as PslProject Expression Required. Object of type PslTransList Object PslProject

PslTransList.Selected

Returns or sets the selection state of this translation list in the project window.

Syntax Expression.Selected as Boolean Expression Required. Object of type PslTransList

Example

' Print title and language of each selected translation list ' and reset selection Dim i As Integer For i = 1 to PSL.ActiveProject.TransLists.Count set trn = PSL.ActiveProject.TransLists(i) If trn.Selected Then PSL.Output trn.SourceList.Title & " " & trn.Language.LangCode trn.Selected = False End If Next i

PslTransList.Simulation

Returns the corresponding simulation list, if available.

Syntax Expression.Simulation as PslTransList Expression Object of type PslTransList

244 SDL Passolo Automation Reference 0

PslTransList.Size

Returns the size (string count) of this translation list as it's displayed in the project window.

Syntax Expression.Size as Long Expression Required. Object of type PslTransList

PslTransList.SourceList

Returns a reference to the source list of the translation list

Syntax Expression.SourceList as PslSourceList Expression Required. Object of type PslTransList

PslTransList.State

Returns the status bits of the translation string list.

Syntax Expression.State (State as Variant) as Boolean Expression Required. Object of type PslTransList State Name of the status value. The following values are possible: • pslListStateBookmark (Value = 100):The string list has a bookmark in the project window • pslSourceListStateVirtual (Value = 212): Read-Only, the source string list has a virtual source file, e.g. a database. • pslTransListStateDeleted (Value = 312): Read-Only, the translation list is deleted and not shown in the project window.

PslTransList.String

Returns a PslTransString-Object from the list. If the list was closed, it will be opened by the way.

SDL Passolo Automation 245 0 Reference

Syntax Expression.String (Index as VARIANT, optional Type as VARIANT) as PslSourceString Expression Object of type PsTransList Index Depending on the Type this is either an index or a number. Type Can be one of the following values: • pslIndex (default, Value = 0): A string from the translation list is returned. Index is the Index of the string, corresponding to all existing undeleted strings. The first string has got the Index 1. • pslIndexDeleted (Value = 4): Works like pslIndex but returns deleted strings from the recycle bin. • pslDisplay (Value = 1): A string from the current display is returned. Index is the Index of the string, corresponding to all displayed strings. The first string has got the Index 1. This value is supported for backward compatibility only. See the note below. • pslSelection (Value = 2): A selected string from the current display is returned. Index is the Index of the string, corresponding to all selected strings. The first selected string has got the Index 1. This value is supported for backward compatibility only. See the note below. • pslNumber (Value = 3): A string from the translation list is returned. Index is the Number of the string. The number is assigned when scanning a source file and will not be changed by update operations like adding or deleting string objects.

Note: With SDL Passolo 6 multiple string lists are displayed in a single window if they have the same languages. To access displayed or selected strings with pslDisplay or pslSelection you should use PslTransDisplay instead of PslTransList. If you use PslTransList then pslDisplay and pslSelection return only strings, if exactly one string list is displayed in the window.

Object PslTransDisplay

PslTransList.StringCount

Returns the number of strings in this list. If the list is still closed, it will be opened.

Syntax Expression.StringCount (optional Type as VARIANT) as Long Expression Object of type PslTransList Type Can be one of the following values: • pslIndex (default, Value = 0): The total number of (undeleted) strings will be returned. • pslIndexDeleted (Value = 4): The total number of deleted strings in the recycle bin will be returned. • pslDisplay (Value = 1): The number of displayed strings will be returned. This value is supported for backward compatibility only. See the note below. • pslSelection (Value = 2): The number of selected strings will be returned. This value is supported for backward compatibility only. See the note below. • The following values use the stored counters in the project. The string list does not need to be loaded, which makes the call much faster. • pslTotal (Value = 100): Returns the total number of strings. Same as pslIndex

246 SDL Passolo Automation Reference 0

• pslToTranslate (Value = 101): Returns that number of strings that need to be translated. This is pslTotal minus empty strings and strings that don't need to be translated, e.g. hidden or read-only strings. • pslTranslated (Value = 102): Returns that number of strings that are translated, including pre- translated and for-review strings (green, blue, black). • pslForReview (Value = 103): Returns that number of strings that are pre-translated or marked for-review (green, blue). • pslUntranslated (Value = 104): Returns that number of strings that are not translated (red). • pslValidated (Value = 105): Returns that number of strings that are translated and validated (black). Note: Multiple string lists are displayed in a single window if they have the same languages. To access displayed or selected strings with pslDisplay or pslSelection you should use PslTransDisplay instead of PslTransList. If you use PslTransList then pslDisplay and pslSelection return only strings, if exactly one string list is displayed in the window.

Example

Sub main ' Creates a glossary from the current translation list Dim trn As PslTransList Set trn = PSL.ActiveTransList If trn Is Nothing Then Exit Sub stringcount = trn.StringCount Open "c:\MyGlossary.txt" For Output As #1 Print #1,trn.SourceList.LangID;Chr(9);trn.Language.LangID codepage1 = trn.SourceList.Option(pslOptionActualCodepage) codepage2 = trn.Language.Option(pslOptionActualCodepage) For i = 1 To stringcount Dim t As PslTransString Set t = trn.String(i) If t.State(pslStateTranslated) Then Dim s1 As String s1 = PSL.ConvertUnicode2ASCII(t.SourceText, codepage1) s2 = PSL.ConvertUnicode2ASCII(t.Text, codepage2) Print #1,s1;Chr(9);s2 End If Next i End Sub

Object PslTransDisplay

PslTransList.TargetFile

Target file for the translation.

SDL Passolo Automation 247 0 Reference

Syntax Expression.TargetFile as String Expression Required. Object of type PslTransList

Example

Dim trn As PslTransList Set trn = PSL.ActiveTransList If trn Is Nothing Then PSL.Output "No active translation list found." Else PSL.Output trn.TargetFile End If

PslTransList.Title

Returns the title this translation list. This is a property that can be set for the accompanying PslSourceList.

Syntax Expression.Title as String Expression Required. Object of type PslTransList Object PslSourceList

PslTransList.TransRate

Returns the translation rate in percent as it's displayed in the project window.

Syntax Expression.TransRate as Long Expression Required. Object of type PslTransList

PslTransList.WordCount

Returns the number of words in this list.

Syntax Expression.WordCount (optional Type as VARIANT) as Long Expression Object of type PslTransList Type Can be one of the following values: • pslTotal (Value = 100): Returns the total number of words. • pslToTranslate (Value = 101): Returns that number of words that need to be translated. This is

248 SDL Passolo Automation Reference 0

pslTotal minus empty strings and strings that don't need to be translated, e.g. hidden or read-only strings. • pslTranslated (Value = 102): Returns that number of words that are translated, including pre- translated and for-review strings (green, blue, black). • pslForReview (Value = 103): Returns that number of words that are pre-translated or marked for-review (green, blue). • pslUntranslated (Value = 104): Returns that number of words that are not translated (red). • pslValidated (Value = 105): Returns that number of words that are translated and validated (black). Object PslTransLists

Contains all translation lists of a project. New translation lists are created automatically by inserting new source file lists or new languages.

Methods

PslTransLists.Add

PslTransLists.Application

Returns the PassoloApp object, read-only property.

Syntax Expression.Application as PassoloApp Expression Required. Object of type PslTransLists Object PassoloApp

PslTransLists.Count

Returns the number of translation lists of a project.

Syntax Expression.Count as Long Expression Required. Object of type PslTransLists

SDL Passolo Automation 249 0 Reference

Example

Dim prj As PslProject Set prj = PSL.Projects(1) PSL.Output "The project has got " & Str(prj.TransLists.Count) _ & " translation lists"

PslTransLists.Item

Item returns a translation list contained in the PslTransLists collection. The translation list can be indicated by its index (1,...), its source string list name or a language code. Item is the standard function, so the name can be omitted.

Syntax Expression.Item (Index as PslTransList, LangID as VARIANT) as PslTransList Expression Required. Object of type PslTransLists Index Variant, Required. Either the index (1,...) of the translation list or the index of the source string list. If the source string list is indicated the second parameter LangID must also be indicated. A source string list can be identified by an index or its title. LangID Variant, optional. If index specifies a source string list, LangID specifies the language. The language can be indicated by a language id (pslLangEnglishUSA, pslLangGerman,...), a language code ("enu", "deu",...) or an object of type PslLanguage.

Example

' Loop over all german translation lists Dim prj As PslProject Set prj = PSL.Projects(1) Dim trn As PslTransList For Each src In prj.SourceLists Set trn = trns(src, "deu") ... Next src

Object PslLanguage

PslTransLists.Open

This function is obsolete and must not be used anymore. It's not possible to load *.trx files anymore.

250 SDL Passolo Automation Reference 0

PslTransLists.Parent

This property returns the corresponding PslProject object, read-only property.

Syntax Expression.Parent as PslProject Expression Required. Object of type PslTransLists Object PslProject Object PslTransString

This object contains the data of an entry in the translation list.

Methods

PslTransString.GetRect

Returns the current coordinates of the translation string object.

Syntax Expression.GetRect (X as LONG, Y as LONG, Cx as LONG, Cy as LONG, [optional] Type as Variant) as Boolean Expression Object of type PslTransString Xx coordinate Yx coordinate Cx width Cy height Type One of these values: • pslDlgUnits (default, Value = 0) returns coordinates in dialog units • pslPixels (Value = 1) returns coordinates in pixels

PslTransString.GetSourceRect

Returns the coordinates of the source string object.

SDL Passolo Automation 251 0 Reference

Syntax Expression.GetSourceRect (X as LONG, Y as LONG, Cx as LONG, Cy as LONG, [optional] Type as Variant) as Boolean Expression Object of type PslTransString Xx coordinate Yx coordinate Cx width Cy height Type One of these values: • pslDlgUnits (default, Value = 0) returns coordinates in dialog units • pslPixels (Value = 1) returns coordinates in pixels

PassoloApp.GetSourceTextCounts

Counts Words, letters and characters in the source text of this string. The count results are stored in the returned PslStringCounter object.

Syntax Expression.Get SourceTextCounts() as PslStringCounter Expression Required. Object of type PslTransString

Example

Sub CompareWordCount(t As PslTransString) Dim srccount As PslStringCounter Set srccount = t.GetSourceTextCounts() Dim trncount As PslStringCounter Set trncount = t.GetTextCounts() Dim diff As Integer diff = trncount.WordCount - srccount.WordCount PSL.Output "Change in word count: " & CStr(diff) End Sub

Object PslStringCounter

PslTransString.GetTextCounts

Counts Words, letters and characters in the translation text of this string. The count results are stored in the returned PslStringCounter object.

252 SDL Passolo Automation Reference 0

Syntax Expression.GetTextCounts() as PslStringCounter Expression Required. Object of type PslTransString

Example

Sub CompareWordCount(t As PslTransString) Dim srccount As PslStringCounter Set srccount = t.GetSourceTextCounts() Dim trncount As PslStringCounter Set trncount = t.GetTextCounts() Dim diff As Integer diff = trncount.WordCount - srccount.WordCount PSL.Output "Change in word count: " & CStr(diff) End Sub

Object PslStringCounter

PslStatistics.Total

Returns Counter information for all strings in the translation list. The counts are returned in an PslString- Counter object.

Syntax Expression.Total as PslStringCounter Expression Object of type PslStatistics Object PslStringCounter

PslTransString.History

Returns the PslHistoryItems object that contains all stored history entries of this PslTransString.

Syntax Expression.History as PslHistoryItems Expression Object of type PslTransString Object HistoryItems

PslTransString.OutputError

Outputs an error message to the log window. The user can jump to the translation string with F4 or by double clicking on the error message.

SDL Passolo Automation 253 0 Reference

Syntax Expression.OutputError (Text as String) as void Expression Object of type PslTransString Text Text to be sent

PslTransString.Properties

Returns the PslProperties object that contains all custom properties of this PslTransString.

Syntax Expression.Properties as PslProperties Expression Object of type PslTransString Object PslProperties

PslTransString.SetRect

Sets the rect coordinates of the translation string object.

Syntax Expression.SetRect (X as LONG, Y as LONG, Cx as LONG, Cy as LONG, [optional] Type as Variant) as Boolean Expression Object of type PslTransString Xx coordinate Yx coordinate Cx width Cy height Type pslDlgUnits returns coordinates in dialog units, pslPixels returns coordinates in pixels

Properties

PslTransString.Attribute

This property is obsolete. Please use PslTransString.Property. PslTransString.Property

254 SDL Passolo Automation Reference 0

PslTransString.Comment

Returns the comment of the string, read-only property.

Syntax Expression.Comment as String Expression Object of type PslTransString

PslTransString.DateChanged

Returns the date and time when the source string of this translation string has last been updated.

Note: This is not the time when the translation string itself has been updated.

Syntax Expression.DateCreated as Date Expression Object of type PslTransString

PslTransString.DateCreated

Returns the the date and the time when the source string of this translation string has first been read to the source string list.

Note: It's not the time when the translation string has been created in the translation list.

Syntax Expression.DateCreated as Date Expression Object of type PslTransString

PslTransString.DateTranslated

Returns the the date and the time when this translation string has last been edited.

Syntax Expression.DateTranslated as Date Expression Object of type PslTransString

SDL Passolo Automation 255 0 Reference

PslTransString.Description

Returns a description of the string like "Editfield 1024 in Dialog 12"

Syntax Expression.Description as String Expression Object of type PslTransString

PslTransString.GetContentSize

Returns the optimal size of a dialog item. This is the same size that is used from the command "Size to content".

Syntax Expression.GetContentSize (Cx as LONG, Cy as LONG) as Boolean Expression Object of type PslTransString Cx Width, calculated from the content of the string Cy Height, calculated from the content of the string

Example

Checks all translation string and corrects the "Text does not fit control size" errors automatically

Sub Main Dim trn As PslTransList Set trn = PSL.ActiveTransList If trn Is Nothing Then Exit Sub ' Make sure that the CheckControlSize option is set PSL.Option(pslOptionCheckCtrlSize) = True ' Check the strings trn.Check ' Peek at the output window to get the errors that have been found Dim checkwnd As PslOutputWnd Set checkwnd = PSL.OutputWnd(pslOutputWndCheck) Dim Line As Long For Line = 1 To checkwnd.LineCount If checkwnd.Type(Line) = pslOutputJump And _ checkwnd.JumpError(Line) = 301 Then Dim t As PslTransString Set t = trn.String(checkwnd.JumpNumber(Line), pslNumber) Dim x As Long Dim y As Long Dim cx As Long Dim cy As Long t.GetRect(x, y, cx, cy) If t.GetContentSize(cx, cy) Then t.SetRect(x, y, cx, cy) PSL.Output "Resized string " & Str(t.Number) & ": (" & CStr(cx) & "," & CStr(cy) & ")" End If End If Next Line End Sub

256 SDL Passolo Automation Reference 0

PslTransString.IDName

Returns the IDName of the string. The IDName is used in header files to substitute numerical IDs with a more meaningful symbolic representation. If this information is not available an empty string will be returned.

Syntax Expression.IDName as String Expression Object of type PslTransString

PslTransString.ID

Returns the ID of the string. The ID can either be a numerical value or a string.

Syntax Expression.ID as Variant Expression Object of type PslTransString

Note: The ID of strings from resource type StringTable is a combination of the resource id and the item id. To calculate the string id use this formula:

Dim s As PslSourceString ... Dim id as Long id = s.ID If s.Resource.Type = "StringList" Then id = 16 * (s.Resource.ID - 1) + s.ID Else id = s.ID End If

PslTransString.Number

Returns the number of the string, read-only property.

Syntax Expression.Number as long Expression Object of type PslTransString

SDL Passolo Automation 257 0 Reference

PslTransString.OldText

Returns the old text (before last update) of the string.

Syntax Expression.OldText as String Expression Object of type PslTransString

PslTransString.Origin

Returns the origin of the pre-translated strings.

The translation origin is set any time a pre-translation or fuzzy match is inserted in the target. It informs the user if the translation comes from machine translation, a glossary or a translation memory.

Syntax Expression.Origin as String Expression Object of type PslTransString

PslTransString.ParserComment

Returns the comment extracted by the parser from the source file. The property is read-only.

Syntax Expression.ParserComment as String Expression Object of type PslTransString

PslTransString.Property

Returns an internal or a custom property of the string.

Syntax Expression.Property (Name as Variant) as Variant Expression Object of type PslTransString Name Name of the property. One of the predefined values below or a custom name. If the macro sets a new value, the property name must be between 10000 and 19999 or start with "M:" (see below) Predefined values are: • pslPropClass (Value = -7): Class of the string • pslPropExstyle (Value = -9): Extended style bits. • pslPropStyle (Value = -8): Style bits.

258 SDL Passolo Automation Reference 0

• pslPropMaxLength (Value = -33): Max. length of translation string. • pslPropMatchRate (Value = -42): If the string has been translated automatically using fuzzy matches, this is the match rate, otherwise it's 0. • pslPropMaxLines (Value = -53): Max. number of lines for translation string

Source

Each translation string contains two sets of custom properties, one from the source string and one "translated" version. The Property returns the "translated" version. To query the source version, use PslTransString.SourceProperty.

Custom Properties

Custom Properties can be defined by parser add-ins, a macro or the user. All properties are in the same list, so they all can be accessed. To distinguish the types, different property names are used. When setting a property the macro is responsible for using the correct name, otherwise the property may be removed when updating string lists.

Type Integer Name String Name Add-In properties 1 - 9999 No prefix Macro properties 10000 - 19999 Uses prefix "M:" User-defined properties 20000 - 30000 Uses prefix "U:"

Example

Dim i As Long Dim selcount As Long Dim trndisp As PslTransDisplay Set trndisp = PSL.ActiveTransDisplay If Not trndisp Is Nothing Then selcount = trndisp.StringCount(pslSelection) For i = 1 To selcount t.Property(10001) = "abc" t.Property("M:myprop") = "def" Next i End If

PslTransString.SourceProperty

PslTransString.Resource

Returns the corresponding PslResource object, read-only property.

SDL Passolo Automation 259 0 Reference

Syntax Expression.Resource as PslResource Expression Object of type PslTransString Object PslResource

PslTransString.ResType

Returns the resource type of the string. A list of all possible types can be found in the Appendix, read-only property.

Syntax Expression.ResType as String Expression Object of type PslTransString Appendix

PslTransString.SourceProperties

Returns a custom source property of the string. These properties are defined by add-ins or macros. Read-only property.

Syntax Expression.SourceProperty (Name as Variant) as Variant Expression Object of type PslSourceString Name Name of the property. One of the predefined values below or a custom name. Custom names are arbitrary integers between 1 and 30000 or strings. Predefined values are: • pslPropClass (Value = -7): Class of the string • pslPropExstyle (Value = -9): Extended style bits. • pslPropStyle (Value = -8): Style bits. • pslPropMaxLength (Value = -33): Max. length of translation string. • pslPropMaxLines (Value = -53): Max. number of lines for translation string Note: Each translation string contains two sets of custom properties, one from the source string and one "translated" version. The SourceProperty returns source string properties. To query the "translated" version, use PslTransString.Property

Object PslProperties

260 SDL Passolo Automation Reference 0

PslTransString.SourceProperty

Returns a custom source property of the string. These properties are defined by add-ins or macros. Read-only property.

Syntax

Expression.SourceProperty (Name as Variant) as Variant Expression Object of type PslSourceString Name Name of the property. One of the predefined values below or a custom name. Custom names are arbitrary integers between 1 and 30000 or strings. Predefined values are: pslPropClass (Value = -7): Class of the string pslPropExstyle (Value = -9): Extended style bits pslPropStyle (Value = -8): Style bits pslPropMaxLength (Value = -33): Max. length of translation string pslPropMaxLines (Value = -53): Max. number of lines for translation string

Note: Each translation string contains two sets of custom properties, one from the source string and one "translated" version. The SourceProperty property returns source string properties. To query the "translated" version, use PslTransString.Property.

PslTransString.Property

PslTransString.SourceText

Returns the original text of the string, read-only property.

Syntax Expression.SourceText as String Expression Object of type PslTransString

PslTransString.State

Returns the status bits of the string.

Syntax Expression.State (State as Variant) as Boolean Expression Object of type PslTransString State Name of the status value. The following values are possible: • pslStateAutoTranslated (Value = 21): The string has been translated automatically (read-only) • pslStateBookmark (Value = 8): The string is marked with a bookmark. • pslStateChanged (Value = 2): The string was changed during one of the previous updates. (read-only) • pslStateCoordChanged (Value = 5): The string belongs to a dialog control, whose coordinates were changed during one of the previous updates (read-only)

SDL Passolo Automation 261 0 Reference

• pslStateCorrection (Value = 4): The string is a correction, so it needs not be translated once more. (read-only) • pslStateDeleted (Value = 9): The string has been deleted and is stored in the recycle bin. • pslStateHidden (Value = 3): The string is not visible for the translator. (read-only) • pslStateInvisible (Value = 31): The string is never shown, not in the source list and not in the translation list (read-only) • pslState Locked (Value = 27): The string locked, i.e. text, properties or coordinates cannot be changed by the user or from macros. • pslStateMirror (Value = 102): If the string belongs to a dialog control: the mirror style of the control is set. • pslStateMirrorThis (Value = 103): If the string belongs to a dialog control: the mirror (no inheritance) style of the control is set. • pslStateMultiline (Value = 100): If the string belongs to a dialog control, the multi line attribute of the control will be set when the target file is generated • pslStateNew (Value = 0): The string is new, it was added by one of the previous updates. (read-only) • pslStateOtherSplitPart (Value = 202): For splitted translation bundles: The string may not be modified because it belongs to another part (read-only) • pslStateReadOnly (Value = 1): The string may not be modified by the translator. (read-only) • pslStateReview (Value = 6): The string is marked with the review flag. All "for review" strings are also "translated". So if you want to validate a string, you need to set this state to False. • pslStateSuppressError (Value = 26): There are suppressed checking errors for this string (read-only) • pslStateToggleRL (Value = 101): If the string belongs to a dialog control: the toggle alignment style of the control is set. • pslStateTagged (Value = 29): The string contains tags (read-only) • pslStateTask (Value = 104): One or more tasks are linked to the string • pslStateTranslated (Value = 7): The string is marked with the translated flag. • pslStateNoReplicate (Value = 18): The string is not used when translating replicates (read-only) • pslStateUnifyReplicates (Value = 200): The string has been marked as "unified replicate" (read-only) • pslStateVariableID (Value = 20): The ID of the string may change when updating the source list (read-only)

PslTransString.Text

Returns the current translation text of the string. The property can both be read and written.

262 SDL Passolo Automation Reference 0

Syntax Expression.Text as String Expression Object of type PslTransString

Note: Changes in the string lists will not be saved automatically. To save the changes, one of the functions PslTransList.Save or PslTransList.Close has to be called.

PslTransList.Save PslTransList.Close

PslTransString.TransComment

Returns the translation comment of the string.

Syntax Expression.TransComment as String Expression Object of type PslTransString

PslTransString.TransList

Returns the translation list that contains this translation string, read-only property.

Syntax Expression.TransList as PslTransList Expression Object of type PslTransString

PslTransString.Type

Returns the type for the string. A list of all possible types can be found in the Appendix, read-only property.

Syntax Expression.Type as String Expression Object of type PslTransString Appendix

SDL Passolo Automation 263 0 Reference

PslTransString.User

Returns the name or another data field of the user who modified this translation string last.

Syntax

Expression.User (Field as Variant) as String Expression Object of type PslTransString Field Variant, optional. Specifies which field to return pslUserName (Value = 0, default) Returns the login name of the user pslUserFullName (Value = 1) Returns the full name of the user pslUserComment (Value = 2) Returns the comment

Example

Sub HandleTransString(t As PslTransString) PSL.Output "String last changed by " & t.User End Sub

Object PslUserFile

This object represents a single user file that is embedded to the project.

Methods none

Properties

PslUserFile.Name

Contains the name of the userfile. (read-only)

Syntax Expression.Name as String Expression Object of type PslUserFile

264 SDL Passolo Automation Reference 0

Object PslUserFiles

This object represents a single task as displayed in the task page of output window.

Methods

PslUserFiles.Add

Inserts a new user file to the project.

Syntax Expression.Add (Path as String) as PslTask Expression Object of type PslUserFiles Path The path of an existing file. This file is embedded to the project. SDL Passolo projects can contain a maximum of 256 user files.

PslUserFiles.Extract

Extracts an embedded user file from the project to a directory. Returns True, if the operation was successful. False indicates an error.

Syntax Expression.Extract (Index as Variant, Path as String, Remove as Variant, Overwrite as Variant) as Boolean Expression Object of type PslUserFiles Index The index or the name of the user file. The first task has the index 1 Path The path of an existing directory. This file will be extracted to this directory. Remove optional, default = FALSE, determines if the user file is removed from the project after extraction Overwrite optional, default = FALSE, determines if an existing file is overwritten when extracting user file

Properties

SDL Passolo Automation 265 0 Reference

PslUserFiles.Application

Returns the Application Object

Syntax Expression.Application as IDispatch Expression Object of type PslUserFiles

PslUserFiles.Count

Returns the number of user files in this PslUserFiles collection.

Syntax Expression.Count as Integer Expression Object of type PslUserFiles

PslUserFiles.Item

Item returns a user file contained in the PslUserFiles collection. The user file is indicated by its index (1,...) or the file name. Item is the standard function, so the name can be omitted.

Syntax Expression.Item (Index as Variant) as PslUserFile Expression Object of type PslUserFiles Index The index or the name of the user file. The first task has the index 1

266 SDL Passolo Automation H

Appendix 0 Appendix

The properties Type and ResType of PslSourceString and PslTransString return the type of a string.

The following types are possible:

Object PslSourceString Object PslTransString

268 SDL Passolo Automation SDL (LSE:SDL) is the global innovator in language translation technology, services and content management. With more than 25 years of experience, SDL delivers transformative business results by enabling powerfully nuanced digital experiences with customers around the world.

Are you in the know? Find out why the top global brands use SDL at sdl.com and follow us on Twitter, LinkedIn and Facebook.

Copyright © 2018 SDL plc. All Rights Reserved. The SDL name and logo, and SDL product and service names are trademarks of SDL plc and/or its subsidiaries, some of which may be registered. Other company, product or service names are the property of their respective holders.

SDL_td_Passolo_2018_EN_A4