summaryrefslogtreecommitdiff
path: root/testautomation/global/tools/includes/optional/t_basic_ide_tools.inc
blob: f7537d52700ceb8215f43730fb63cb04bbc4fbff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
'encoding UTF-8  Do not remove or change this line!
'**************************************************************************
' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
'
' Copyright 2000, 2010 Oracle and/or its affiliates.
'
' OpenOffice.org - a multi-platform office productivity suite
'
' This file is part of OpenOffice.org.
'
' OpenOffice.org is free software: you can redistribute it and/or modify
' it under the terms of the GNU Lesser General Public License version 3
' only, as published by the Free Software Foundation.
'
' OpenOffice.org is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' GNU Lesser General Public License version 3 for more details
' (a copy is included in the LICENSE file that accompanied this code).
'
' You should have received a copy of the GNU Lesser General Public License
' version 3 along with OpenOffice.org.  If not, see
' <http://www.openoffice.org/license.html>
' for a copy of the LGPLv3 License.
'
'/************************************************************************
' **
' ** owner : joerg.skottke@oracle.com
' **
' ** short description : tools for the property-browser test
' **
'\******************************************************************************

function hShowMacroControls() as boolean

    '///<h3>Tear off the ToolsCollectionBar from the MacroBar</h3>
    '///<i>Starting point: Basic dialog editor is open and has the focus</i>
    '///<ul>
    const CFN = "hShowMacroControls::"

    const MAX_WAIT = 5
    const SHORT_WAIT = 1

    const VERTICALLY_CENTERED = 50
    const HORIZONTALLY_CENTERED = 50
    
    if ( GVERBOSE ) then printlog( CFN & "Enter" )

    '///+<li>Test whether the ToolsCollectionBar is already open. If yes, exit directly</li>
    kontext "ToolsCollectionBar"
    if ( ToolsCollectionBar.exists( SHORT_WAIT ) ) then
        printlog( CFN & "ToolsCollectionBar is already open." )
        hShowMacroControls() = true
        exit function
    endif
    
    '///+<li>Verify that the Dialog Bar is available</li>
    Kontext "DialogBar"
    if ( DialogBar.exists( MAX_WAIT ) ) then

        '///+<li>Verify that the controls-button is enabled</li>
        try        
            '///+<li>Click on the controls-button to open the ToolsCollectionBar</li>
            controls.click()
            
            '///+<li>Tear off the ToolsCollectionBar from the DialogBar</li>
            controls.tearOff()
            
            '///+<li>Verify that the ToolsCollectionBar is visible and can be accessed</li>
            kontext "ToolsCollectionBar"
            if ( ToolsCollectionBar.exists( MAX_WAIT ) ) then
            
                '///+<li>Move it to the upper left corner at pos 50/50</li>
                ToolsCollectionBar.Move ( HORIZONTALLY_CENTERED , VERTICALLY_CENTERED )
                printlog( CFN & "ToolsCollectionBar is open and has been placed" )
                hShowMacroControls() = true
            else
                printlog( CFN & "ToolsCollectionBar is not available. Aborting." )
                hShowMacroControls() = false
            endif
        catch
            printlog( CFN & "The Controls-Button is not enabled. Aborting." )
            hShowMacroControls() = false
        endcatch	
    else
        printlog( CFN & "The Dialog Bar is not available. Aborting." )
        hShowMacroControls() = false
    endif
    '///</ul>    
        
end function

'*******************************************************************************

function hGetBasicWorkFile( cMajorID as string ) as string

    '///<h3>Retrieve a filename, depending on gApplication and Build-ID</h3>
    '///<i>Structure: work-directory/basic[.suffix]</i>
    const CFN = "hGetBasicWorkFile::"
    dim sFile as string : sFile = hGetWorkPath() & "basic" & hGetSuffix( cMajorId )
    printlog( CFN & sFile & " for " & gApplication & " (" & cMajorID & ")" )
    hGetBasicWorkFile() = sFile

end function

'*******************************************************************************

function hOpenBasicIDE() as boolean

    '///<h3>Open the Basic IDE for the last module listed in the Macro Organizer</h3>
    '///<i>Starting point: Basic Macro Organizer has focus</i>
    
    const CFN = "hOpenBasicIDE::"
    const BUTTON_TIMEOUT = -1
    const MAX_WAIT = 2
    
    if ( hSelectTheLastModule( true ) ) then
    
        if ( hClickButton( Bearbeiten) <> BUTTON_TIMEOUT ) then

            kontext "BASICIDE"
            if ( BasicIDE.exists( MAX_WAIT ) ) then
                printlog( "Basic IDE is open" )
                BasicIDE.maximize()
                hOpenBasicIDE() = true
            else
                warnlog( CFN & "Failed to open BASIC IDE" )
                hOpenBasicIDE() = false
            endif
        else
            warnlog( CFN & "Edit button is not enabled, cannot open BASIC IDE"
            hOpenBasicIDE() = false
        endif
    else
        warnlog( CFN & "Unable to select the last module" )
        hOpenBasicIDE() = false
    endif

end function

'*******************************************************************************

function hCloseBasicIDE() as boolean

    '///<h3>Close the BASIC-IDE</h3>
    hCloseCollectionBar()
    kontext "BasicIDE"
    hCloseBasicIDE() = hDestroyDocument()

end function

'*******************************************************************************

function hReOpenBasicDialog() as boolean

    '///<h3>Open BASIC-IDE after loading a workfile with documentbound macro</h3>
    '///<i>Starting point: Focus on document containing at least one macro</i><br>
    const CFN = "hReopenBasicDialog: "
    const BUTTON_TIMEOUT = -1
    
    if ( hSelectTheLastModule( true ) ) then

        if ( hClickButton( Bearbeiten ) <> BUTTON_TIMEOUT ) then

            kontext "BasicIDE"
            BasicIde.maximize()

            if ( hFindFirstDialog() ) then
                printlog( "BASIC IDE is open." )
                hReOpenBasicDialog() = true
            else
                warnlog( CFN & "Could not find any dialog" )
                hReOpenBasicDialog() = false
            endif
        else
            warnlog( CFN & "Unable to click Edit button, BASIC IDE not open" )
            hReOpenBasicDialog() = false
        endif
    else
        warnlog( CFN & "Could not open the last module for editing." )
        hReOpenBasicDialog() = false
    endif

end function

'*******************************************************************************

function hFindFirstDialog() as boolean

    '///<h3>Find the first dialog in the BASIC-IDE</h3>
    '///<i>Starting point: Basic IDE must be open and has the focus</i>
    '///<ul>
    
    const CFN = "hFindFirstDialog::"
    const REPEAT_COUNT = 5 ' number of times to send a keystroke to BASIC IDE
    const MAX_NUMBER_OF_RETRIES = 20
    const SELECT_TAB_RIGHT = "<MOD1 PAGEUP>"
    const SCROLL_UP_LEFT   = "<UP><LEFT>"

    dim iPosOverTabbar as integer
    hFindFirstDialog() = false

    '///+<li>Set focus to Basic IDE, maximize it</li>
    kontext "BasicIDE"
    BasicIde.maximize()


    '///+<li>move pointer over the tabbar and click until a dialog opens (hopefully)</li>
    for iPosOverTabbar = 1 to MAX_NUMBER_OF_RETRIES

        BASICIDE.typeKeys( SELECT_TAB_RIGHT )

        if ( DialogWindow.Exists() ) then
            printlog( "BASIC Dialog window found" )
            hFindFirstDialog() = true
            DialogWindow.typeKeys( SCROLL_UP_LEFT , REPEAT_COUNT )
            exit for
        endif

    next iPosOverTabbar
       '///</ul>

end function

'*******************************************************************************

function hSelectDialogPane() as boolean

    '///<h3>Select the dialog pane in the Basic dialog editor</h3>
    '///<i>Starting point: Basic dialog editor is open and has the focus</i>
    const CFN = "hSelectDialogPane::"
    const UP_LEFT    = 10
    const DOWN_RIGHT = 90

    if ( GVERBOSE ) then printlog( CFN & "Enter" )
    
    kontext "BasicIDE"
    DialogWindow.mouseDown( DOWN_RIGHT , DOWN_RIGHT )
    DialogWindow.mouseMove( UP_LEFT , UP_LEFT )
    DialogWindow.mouseUp  ( UP_LEFT , UP_LEFT )
    
    printlog( CFN & "Selected dialog pane (not verified)" )
    hSelectDialogPane() = true

end function

'*******************************************************************************

function hCloseCollectionBar() as boolean

    const CFN = "hCloseCollectionBar(): "

    kontext "ToolsCollectionBar"
    if ( ToolsCollectionBar.exists() ) then

        if ( hCloseDialog( ToolsCollectionBar, "close" ) ) then
            printlog( "Closed Macro Controls Float" )
            hCloseCollectionBar() = true
        else
            warnlog( CFN & "Failed to close Macro Controls Float" )
            hCloseCollectionBar() = false
        endif
    else
        printlog( "Macro Controls Float not open" )
        hCloseCollectionBar() = true
    endif

end function

'*******************************************************************************

function hDeleteMacro() as boolean

    '///<h3>Delete all text in the Basic IDE editor</h3>
    const CFN = "hDeleteMacro(): "
    
    kontext "BasicIDE"
    if ( BasicIDE.exists() ) then
        WaitSlot() : Wait( 100 ) : EditWindow.typeKeys( "<MOD1 HOME>" )
        WaitSlot() : Wait( 100 ) : EditWindow.typeKeys( "<MOD1 SHIFT END>" )
        WaitSlot() : Wait( 100 ) : EditWindow.typeKeys( "<DELETE>" )
        hDeleteMacro() = hIsEditWindowEmpty()
    else
        warnlog( CFN & "Basic IDE is not open" )
        hDeleteMacro() = false
    endif

end function

'*******************************************************************************

function hIsEditWindowEmpty() as boolean

    '///<h3>Test if the Basic-EditWindow is empty</h3>
    '///<i>Starting point: Basic IDE editor is open and has the focus</i>
    const CFN = "hIsEditWindowEmpty(): "

    kontext "BasicIDE"
    if ( BasicIDE.exists() ) then
        SetClipboard( "" )
        WaitSlot() : EditWindow.typeKeys( "<MOD1 HOME>" )
        WaitSlot() : EditWindow.typeKeys( "<MOD1 SHIFT END>" )
        hUseAsyncSlot( "EditCopy" )

        if ( GetClipBoardText() = "" ) then
            hIsEditWindowEmpty() = true
        else
            warnlog( CFN & "Edit window is not empty" )
            hIsEditWindowEmpty() = false
        endif
    else
        warnlog( CFN & "BasicIDE is not open" )
        hIsEditWindowEmpty() = false
    endif
    
end function

'*******************************************************************************

function hRenameTab( cTabName as string ) as integer

    const CFN = "hRenameTab(): "

    const MENUITEM_RENAME  = 3
    const MAX_WAIT         = 1000

    const RETVAL_SUCCESS   = 0
    const RETVAL_NO_IDE    = 1
    const RETVAL_NO_ACCESS = 2
    const RETVAL_NO_MENU   = 3

    dim sFullString as string : sFullString = "<HOME><SHIFT END>" & cTabName & "<RETURN>"

    kontext "BasicIDE"
    if ( BasicIDE.exists() ) then
        try
            hRenameTab() = RETVAL_NO_MENU
            Tabbar.openContextMenu()
            hMenuSelectNr( MENUITEM_RENAME )
            Wait( MAX_WAIT )

            ' At this point the string on the tab should be selected, print the 
            ' string to the log and overwrite it with the new name
            hRenameTab() = RETVAL_NO_ACCESS

            Tabbar.typeKeys( sFullString , true )
            hRenameTab() = RETVAL_SUCCESS
        catch
            warnlog( CFN & "Failed to rename the current module" )
        endcatch
    else
        warnlog( CFN & "BASIC IDE is not open" )
        hRenameTab() = RETVAL_NO_IDE
    endif

end function

'*******************************************************************************

function hGetTabNameFromOrganizer() as string

    '///<h3>Retrieve the name of a tab from the Basic Library Organizer</h3>
    '///<i>Starting point: Basic IDE is open and has the focus</i>
    '///<ul>

    const CFN = "hGetTabNameFromOrganizer::"
    dim cReturnString as string

    '///+<li>Open the Basic Library Organizer</li>
    '///+<li>Go to the Module-Tab</li>
    '///+<li>Get the name of the currently selected item from the Module-list</li>
    '///+<li>Close the Macro Library Organizer</li> 
    if ( hOpenBasicObjectOrganizer( 1 ) ) then
        cReturnString = Modulliste.GetSelText()
        TabModule.Close()
        printlog( CFN & "Returning Tab-Name: " & cReturnString )
    else
        cReturnString = "Failure: Macro Organizer not open"
        warnlog( CFN & cReturnString )
        
    endif
    
    '///+<li>Return the name from the Module-list</li>
    hGetTabNameFromOrganizer() = cReturnString
    '///</ul>
   
end function

'*******************************************************************************

function hNewDialog() as boolean

    '///<h3>Create a new BASIC dialog</h3>
    '///<i>Starting point: Basic IDE is open</i>
    '///<ul>

    const CFN = "hNewDialog::"
    const MAX_WAIT = 2000

    '///+<li>Open the context menu for the tabbar</li>
    kontext "basicide"
    Tabbar.OpenContextMenu
    
    '///+<li>Select the first item (insert)</li>
    hMenuSelectNr( 1 )
    WaitSlot( MAX_WAIT ) ' sleep( 1 )
    
    '///+<li>Select the second item (new dialog)</li>
    hMenuSelectNr( 2 )
    WaitSlot( MAX_WAIT ) ' sleep( 2 )
    
    '///+<li>Verify that a new dialog is opened and has the focus</li>
    if ( DialogWindow.Exists() ) then 
        printlog( CFN & "New dialog is open" )
        hNewDialog() = true
	if ( DialogWindow.IsMax() = false ) then		
            DialogWindow.Maximize()
            Wait( MAX_WAIT )
	end if		
    else
        warnlog( CFN & "New dialog is not open" )
        hNewDialog() = false
    endif
    '///+<li>Return TRUE on success, FALSE on failure</li>
    '///</ul>

end function

'*******************************************************************************

function hNewModule() as boolean

    '///<h3>Create a new BASIC module</h3>
    '///<i>Starting point: Basic IDE is open</i>
    '///<ul>

    const CFN = "hNewModule::"
    const MAX_WAIT = 2000

    '///+<li>Open the context menu for the tabbar</li>
    kontext "basicide"
    Tabbar.OpenContextMenu
    
    '///+<li>Select the first item (insert)</li>
    hMenuSelectNr( 1 )
    WaitSlot( MAX_WAIT ) ' sleep( 1 )
    
    '///+<li>Select the first item (new module)</li>
    hMenuSelectNr( 1 )
    WaitSlot( MAX_WAIT ) ' sleep( 2 )
    
    '///+<li>Verify that a new module is opened and has the focus</li>
    if ( EditWindow.Exists() ) then 
        printlog( CFN & "New module is open" )
        hNewModule() = true 
    else
        warnlog( CFN & "New module is not open" )
        hNewModule() = false
    endif
    '///+<li>Return TRUE on success, FALSE on failure</li>
    '///</ul>

end function        

'*******************************************************************************

function hHideModule() as boolean

    '///<h3>Hide a Basic Module from the IDE</h3>
    '///<i>Starting point: Basic IDE is open and has the focus</i>
    '///<ul>

    const CFN = "hHideModule::"
    const MENUENTRY_HIDE = 4
    
    kontext "basicide"
    
    '///+<li>Open the context menu of the tabbar</li>
    try
       tabbar.openContextMenu
       
       '///+<li>Select the fourth entry (Hide)</li>
       hMenuSelectNr( MENUENTRY_HIDE )
       sleep( 1 )
       hHideModule() = true
       printlog( CFN & "Success" )
    catch
       hHideModule() = false 
       warnlog( CFN & "Failure" )
    endcatch
    '///+<li>Return TRUE on success, FALSE on any other condition (not verified)</li>
    '///</ul>
   
end function   

'*******************************************************************************

function hInitFormControls( cModule as string ) as boolean

    '///<h3>Get from a new document to the Macro Controls Float in one go</h3>
    '///<i>Starting point: Plain document</i><br>
    '///This function performs following steps:
    '///<ol>
    '///+<li>Open the Basic Organizer</li>
    '///+<li>Create a new module for the current document</li>
    '///+<li>Open a new basic dialog</li>
    '///+<li>Open the Macro controls float</li>
    '///</ol>
    '///Description:
    '///<ul>
    
    const CFN = "hInitFormControls::"
    hInitFormControls() = false
    '///+<li>Create and edit a new module for the current document</li>

    if ( not hInitBasicIde( cModule ) ) then
        warnlog( "Could not create new module" )
        hCloseBasicIde()
        exit function
    endif     
    
    kontext "BasicIde"
    BasicIde.maximize()   

    '///+<li>Create a new dialog.</li>
    if ( not hNewDialog() ) then
        warnlog( "Could not create Basic-Dialog" )
        hCloseBasicIde()
        exit function
    endif    
    
    '///+<li>Open the macro controls float.</li>
    if ( not hShowMacroControls() ) then
        warnlog( CFN & "Could not tear off the macro controls float" )
        hCloseBasicIde()
        exit function            
    endif
    
    '///+<li>Return TRUE if all went well, FALSE on any other error</li>
    hInitFormControls() = true
    '///</ul>
    '///NOTE: The function will try to cleanup after itself in case of failure
    
end function

'*******************************************************************************

function hInitBasicIde( cModule as string ) as boolean

    '///<h3>Get from a new document to the Basic IDE in one go</h3>
    '///<i>Starting point: New, plain document</i>

    const CFN = "hInitBasicIde::"

    ToolsMacro_uno

    kontext "Makro"
    if ( Makro.exists( 2 ) ) then

        if ( hCreateModuleForDoc( cModule ) ) then

            kontext "BasicIDE"
            if ( BasicIDE.exists( 2 ) ) then
                BasicIDE.maximize()
                hInitBasicIde() = true
            else
                warnlog( CFN & "Failed to open BASIC IDE" )
                hInitBasicIde() = false
            endif
        else
            warnlog( CFN & "Failed to create a module for the current document" )
            hInitBasicIde() = false
        endif
    else
        warnlog( CFN & "Failed to open macro organizer" )
        hInitBasicIde() = false
    endif
    
end function 

'*******************************************************************************

function hInsertMacro( _id as integer ) as boolean

    '///<h3>Insert a macro into the Basic-IDE edit window by Index</h3>
    '///<i>Starting point: Basic IDE is open, has the focus</i>
    '///<ul>
    
    const CFN = "hInsertMacro::"
    kontext "basicide"

    printlog( CFN & "This function is deprecated" )
    
    '///+<li>Delete the content of the edit window</li>
    if ( not hDeleteMacro() ) then
        warnlog( CFN & "Content of Basic-IDE was not deleted" )
        hInsertMacro() = false
        exit function
    endif
        
    '///+<li>Insert a macro by index (passed as function parameter)</li>
    select case _id
    case 1 :
        ' this is a working macro that contains no errors
        EditWindow.TypeKeys( "'# TTMacro1: This is a short testscript for automated testing!<return><return>" )
        EditWindow.TypeKeys( "sub main<return><return>" )
        EditWindow.TypeKeys( "print " & Chr (34) + "hallo" & Chr (34) )
        EditWindow.TypeKeys( "<Return><Return>" )
        EditWindow.TypeKeys( "<Home>end sub<return>" )
        hInsertMacro() = true
        printlog( CFN & "Inserted: " & _id )
    case 2 :
        EditWindow.TypeKeys( "'# TTMacro2: a second module for automated testing!" )
        EditWindow.TypeKeys( "<Return><Return>" )
        hInsertMacro() = true
        printlog( CFN & "Inserted: " & _id )
    case 3 :
        EditWindow.TypeKeys( "'# TTMacro3: Bring up a messagebox<return><return>" )
        EditWindow.TypeKeys( "sub main<return><return>" )
        EditWindow.TypeKeys( "    msgbox " & Chr (34) + "TTMacro3" & Chr (34) )
        EditWindow.TypeKeys( "<Return><Return>" )
        EditWindow.TypeKeys( "<Home>end sub<return>" )
        hInsertMacro() = true  
        printlog( CFN & "Inserted: " & _id )
    end select
   
    '///</ul>
    
end function

'*******************************************************************************

function hTestMacro( _id as integer ) as integer

    '///<h3>Verify that the correct macro is visible in the IDE edit Window</h3>
    '///<i>Starting point: Basic IDE is open and has focus</i>
    '///<ul>
    
    const CFN = "hTestMacro::"
    qaerrorlog( CFN & "This function is deprecated, remove me!" )

    kontext "basicide"

    '///+<li>Copy the first line in the editwindow to clipboard</li>  
    EditWindow.TypeKeys( "<Mod1 Home>" )
    EditWindow.TypeKeys( "<Home><Shift End>" ) 
    EditCopy
    
    '///+<li>Compare the string to a unique substring for the macro</li>
    select case _id
    case 1 :
        if ( Instr ( GetClipboardText, "TTMacro1" ) <> 0 ) then
            printlog( CFN & "The correct macro is displayed in the editwindow" )
            htestMacro() = 1
            exit function
        endif
    case 2 :
        if ( Instr ( GetClipboardText, "TTMacro2" ) <> 0 ) then
            printlog( CFN & "The correct macro is displayed in the editwindow" )
            htestMacro() = 2
            exit function
        endif
    case 3 :
        if ( Instr ( GetClipboardText, "TTMacro3" ) <> 0 ) then
            printlog( CFN & "The correct macro is displayed in the editwindow" )
            htestMacro() = 3
            exit function
        endif        
    end select
    
    hTestMacro() = 0
    '///</ul>
    
end function

'*******************************************************************************

function hCreateBasicWorkFiles() as string

    '///<H3>Create a macro, attach it to a file, save the file</H3>
    '///<i>Starting point: Any plain document or the backing window</i>
    '///<ul>
    const CFN = "hCreateBasicWorkFiles::"
    const CMACRO = "TestMacro"
    
    dim sFile as string : sFile = hGetBasicWorkFile( "CURRENT" )
        
    '///+<li>Open a new document</li>
    hCreateDocument()
    
    '///+<li>Change the document (to save it)</li>
    printlog( CFN & hChangeDoc() )
    
    '///+<li>Open Basic-Organizer, select the document and create a module</li>
    if ( not hInitBasicIde( CMACRO ) ) then
        printlog( CFN & "Unable to create a module, aborting" )
        hDestroyDocument()
        hCreateBasicWorkFiles() = ""
        exit function
    endif
    
    '///+<li>Insert a macro that triggers a messagebox</li>
    if ( not hInsertMacro( 3 ) ) then
        printlog( CFN & "Unable to insert macro, aborting" )
        hCloseBasicIde()
        hDestroyDocument()
        hCreateBasicWorkFiles() = ""
        exit function
    endif
    
    '///+<li>Close the Basic-IDE</li>
    hCloseBasicIde()
    
    '///+<li>Save the file without autoextension, overwrite existing</li>
    if ( not hFileSaveAsKill( sFile ) ) then
        printlog( CFN & "Unknown error while saving the file. Resetting" )
        ExitRestartTheOffice
        hCreateBasicWorkFiles() = ""
        exit function
    endif
    
    '///+<li>Close the document</li>
    hDestroyDocument()
    
    '///</ul>
    
end function


'*******************************************************************************

function hIDESelectTabByIndex( iIndex as integer ) as string

    '///<h3>Select a tab within the BASIC-IDE by index</h3>
     '///<i>The BASIC-IDE has to be open and has the focus. This function
     '///+ selects the tab by sending CTRL+PAGEUP or CTRL+PAGEDOWN to the IDE using 
     '///+ the .typeKeys method. It is assumed that - when opening the IDE - the 
     '///+ first tab is active. When the specified index has been reached we 
     '///+ retrieve the name of the current tab by opening the context menu on the 
     '///+ tab and selecting &quot;Rename&quot;. The name (which should be 
     '///+ highlighted by default) is then copied to the clipboard and returned  
     '///+ to the calling function.</i><br><br>

    '///<u>Parameter(s):</u><br>
    '///<ol>

    '///+<li>Index of the requested Tab (Integer)</li>
    '///<ul>
    '///+<li>Index must not be negative</li>
    '///+<li>0 does nothing (returning the name of the current tab)</li>
    '///+<li>Index must be &le; present number of tabs</li>
    '///+<li>If Index &gt; number of tabs, the last tab is selected</li>
    '///</ul>

    '///</ol>


    '///<u>Returns:</u><br>
    '///<ol>
    '///+<li>Name of the selected tab (string)</li>
    '///<ul>
    '///+<li>Always evaluate the returnvalue</li>
    '///</ul>
    '///</ol>

    const CFN = "hIDESelectTabByIndex::"
    printlog( CFN & "Enter with option: " & iIndex )
    dim brc as boolean 'a multi purpose boolean returnvalue
    
    dim cTabName as string
    dim iCurrentTab as integer

    '///<u>Description:</u>
    '///<ul>
    '///+<li>Set context to BASIC IDE</li>
    kontext "BasicIDE"
    
    '///+<li>Retrieve the accelerator to switch tabs</li>
    '///+<li>Switch tabs</li>
    select case iIndex
    case 1   :
        for iTab = 1 to 20
            BasicIDE.typeKeys( "<MOD1 PAGEDOWN>" )
        next iTab
    case else:  
        for iTab = 1 to iIndex
            BasicIDE.typeKeys( "<MOD1 PAGEUP>" )
        next iTab
    end select
    
    '///+<li>Select the Tabbar</li>
    Kontext "Tabbar"
    
    '///+<li>Open the context menu</li>
    hUseMenu()
    
    '///+<li>Select &quot;Rename&quot;</li>
    hSelectMenuNr( 3 )
    
    '///+<li>Copy the selected string to the clipboard</li>
    hUseAsyncSlot( "EditCopy" )
    
    '///+<li>Send ESC to the tabbar to deselect the tab</li>
    Kontext "Tabbar"
    Tabbar.typeKeys( "<ESCAPE>" )
    
    '///+<li>Copy the string from clipboard to a local variable</li>
    cTabName = getClipboardText
    
    '///+<li>Print exit message, set return value</li>
    if ( GVERBOSE ) then printlog( CFN & "Exit with result: " & cTabName )
    hIDESelectTabByIndex() = cTabName
    '///</ul>

end function