vb6parse 1.0.1

vb6parse is a library for parsing and analyzing VB6 code, from projects, to controls, to modules, and forms.
Documentation
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
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
//! # `LoadResPicture` Function
//!
//! Returns a picture object (`StdPicture`) containing an image from a resource (.res) file.
//!
//! ## Syntax
//!
//! ```vb
//! LoadResPicture(index, format)
//! ```
//!
//! ## Parameters
//!
//! - `index` (Required): Integer or String identifying the picture resource
//!   - Can be a numeric ID or string name
//!   - Must match the ID/name used when the resource was compiled
//! - `format` (Required): Integer specifying the format of the picture
//!   - `vbResBitmap` (0): Bitmap (.bmp)
//!   - `vbResIcon` (1): Icon (.ico)
//!   - `vbResCursor` (2): Cursor (.cur)
//!
//! ## Return Value
//!
//! Returns a `StdPicture` object:
//! - Picture object containing the loaded image from resources
//! - Object can be assigned to Picture properties of controls
//! - Object implements `IPicture` interface
//! - Returns Nothing if resource not found (some VB versions)
//! - May raise error 32813 if resource not found
//!
//! ## Remarks
//!
//! The `LoadResPicture` function loads images from embedded resources:
//!
//! - Loads images from compiled resource (.res) files
//! - Resource file must be linked to project at compile time
//! - Supports BMP, ICO, and CUR formats only
//! - Does NOT support JPG, GIF, or PNG
//! - Returns `StdPicture` object implementing `IPicture`
//! - Alternative to `LoadPicture` for embedded images
//! - No external files needed at runtime
//! - Faster than loading from disk
//! - More secure (can't be modified by users)
//! - Resources embedded in compiled EXE/DLL
//! - Only one resource file per project
//! - Resource file added via Project > Add File
//! - Resource files created with Resource Editor or RC.EXE
//! - Index can be numeric ID or string name
//! - Format constants: vbResBitmap, vbResIcon, vbResCursor
//! - Error 32813: "Resource not found" if ID/format don't match
//! - Error 48: "Error loading from file" if resource file corrupt
//! - Pictures are not cached (loaded each time)
//! - Set object = Nothing to release memory
//! - Common in `Form_Load` for initial graphics
//! - Used with Image, `PictureBox`, and Form.Picture
//! - Preferred for distribution (no external image files)
//!
//! ## Typical Uses
//!
//! 1. **Load Bitmap to `PictureBox`**
//!    ```vb
//!    Picture1.Picture = LoadResPicture(101, vbResBitmap)
//!    ```
//!
//! 2. **Load Icon to Image Control**
//!    ```vb
//!    Image1.Picture = LoadResPicture(102, vbResIcon)
//!    ```
//!
//! 3. **Load Form Background**
//!    ```vb
//!    Me.Picture = LoadResPicture("BACKGROUND", vbResBitmap)
//!    ```
//!
//! 4. **Load Cursor**
//!    ```vb
//!    Me.MousePointer = vbCustom
//!    Me.MouseIcon = LoadResPicture(103, vbResCursor)
//!    ```
//!
//! 5. **Load Named Resource**
//!    ```vb
//!    imgLogo.Picture = LoadResPicture("LOGO", vbResBitmap)
//!    ```
//!
//! 6. **Conditional Image Loading**
//!    ```vb
//!    If mode = "dark" Then
//!        Picture1.Picture = LoadResPicture(201, vbResBitmap)
//!    Else
//!        Picture1.Picture = LoadResPicture(101, vbResBitmap)
//!    End If
//!    ```
//!
//! 7. **Button Icons**
//!    ```vb
//!    cmdSave.Picture = LoadResPicture(104, vbResIcon)
//!    ```
//!
//! 8. **Multiple Images in Loop**
//!    ```vb
//!    For i = 1 To 5
//!        imgArray(i).Picture = LoadResPicture(100 + i, vbResBitmap)
//!    Next i
//!    ```
//!
//! ## Basic Examples
//!
//! ### Example 1: Basic Picture Loading
//! ```vb
//! ' Load bitmap from resources
//! Picture1.Picture = LoadResPicture(101, vbResBitmap)
//!
//! ' Load icon
//! Image1.Picture = LoadResPicture(102, vbResIcon)
//!
//! ' Load using string name
//! Picture2.Picture = LoadResPicture("SPLASH", vbResBitmap)
//! ```
//!
//! ### Example 2: Form Initialization
//! ```vb
//! Private Sub Form_Load()
//!     ' Load form background
//!     Me.Picture = LoadResPicture(101, vbResBitmap)
//!     
//!     ' Load toolbar icons
//!     cmdNew.Picture = LoadResPicture(201, vbResIcon)
//!     cmdOpen.Picture = LoadResPicture(202, vbResIcon)
//!     cmdSave.Picture = LoadResPicture(203, vbResIcon)
//! End Sub
//! ```
//!
//! ### Example 3: Error Handling
//! ```vb
//! On Error Resume Next
//! Picture1.Picture = LoadResPicture(999, vbResBitmap)
//! If Err.Number = 32813 Then
//!     MsgBox "Resource not found!", vbCritical
//!     Err.Clear
//! ElseIf Err.Number <> 0 Then
//!     MsgBox "Error loading resource: " & Err.Description, vbCritical
//!     Err.Clear
//! End If
//! ```
//!
//! ### Example 4: Dynamic Loading
//! ```vb
//! Dim imageID As Integer
//! imageID = 101 + selectedIndex
//! Picture1.Picture = LoadResPicture(imageID, vbResBitmap)
//! ```
//!
//! ## Common Patterns
//!
//! ### Pattern 1: `SafeLoadResPicture`
//! ```vb
//! Function SafeLoadResPicture(ByVal resID As Variant, _
//!                             ByVal resFormat As Integer, _
//!                             ByVal ctrl As Object) As Boolean
//!     On Error Resume Next
//!     Set ctrl.Picture = LoadResPicture(resID, resFormat)
//!     SafeLoadResPicture = (Err.Number = 0)
//!     Err.Clear
//! End Function
//! ```
//!
//! ### Pattern 2: `PreloadResourcePictures`
//! ```vb
//! Dim preloadedPics() As StdPicture
//!
//! Sub PreloadResourcePictures()
//!     Dim i As Long
//!     ReDim preloadedPics(1 To 5)
//!     
//!     For i = 1 To 5
//!         Set preloadedPics(i) = LoadResPicture(100 + i, vbResBitmap)
//!     Next i
//! End Sub
//!
//! Sub ShowPreloadedImage(ByVal index As Long)
//!     If index >= 1 And index <= UBound(preloadedPics) Then
//!         Set Picture1.Picture = preloadedPics(index)
//!     End If
//! End Sub
//! ```
//!
//! ### Pattern 3: `LoadResPictureWithDefault`
//! ```vb
//! Function LoadResPictureWithDefault(ByVal resID As Variant, _
//!                                    ByVal resFormat As Integer, _
//!                                    ByVal defaultID As Variant) As StdPicture
//!     On Error Resume Next
//!     
//!     Set LoadResPictureWithDefault = LoadResPicture(resID, resFormat)
//!     If Err.Number <> 0 Then
//!         Err.Clear
//!         Set LoadResPictureWithDefault = LoadResPicture(defaultID, resFormat)
//!     End If
//! End Function
//! ```
//!
//! ### Pattern 4: `LoadResByName`
//! ```vb
//! Function LoadResByName(ByVal resName As String, _
//!                        ByVal resFormat As Integer) As StdPicture
//!     On Error Resume Next
//!     Set LoadResByName = LoadResPicture(resName, resFormat)
//!     
//!     If Err.Number <> 0 Then
//!         Debug.Print "Failed to load resource: " & resName
//!         Set LoadResByName = Nothing
//!         Err.Clear
//!     End If
//! End Function
//! ```
//!
//! ### Pattern 5: `ToggleResPicture`
//! ```vb
//! Dim currentState As Boolean
//!
//! Sub ToggleResPicture()
//!     If currentState Then
//!         Picture1.Picture = LoadResPicture(101, vbResBitmap)
//!     Else
//!         Picture1.Picture = LoadResPicture(102, vbResBitmap)
//!     End If
//!     currentState = Not currentState
//! End Sub
//! ```
//!
//! ### Pattern 6: `LoadThemeResources`
//! ```vb
//! Enum ThemeType
//!     tmLight = 0
//!     tmDark = 1
//! End Enum
//!
//! Sub LoadThemeResources(theme As ThemeType)
//!     Dim baseID As Integer
//!     baseID = IIf(theme = tmDark, 200, 100)
//!     
//!     Me.Picture = LoadResPicture(baseID + 1, vbResBitmap)
//!     Picture1.Picture = LoadResPicture(baseID + 2, vbResBitmap)
//!     Picture2.Picture = LoadResPicture(baseID + 3, vbResBitmap)
//! End Sub
//! ```
//!
//! ### Pattern 7: `ResExists`
//! ```vb
//! Function ResExists(ByVal resID As Variant, _
//!                    ByVal resFormat As Integer) As Boolean
//!     On Error Resume Next
//!     Dim pic As StdPicture
//!     Set pic = LoadResPicture(resID, resFormat)
//!     ResExists = (Err.Number = 0)
//!     Set pic = Nothing
//!     Err.Clear
//! End Function
//! ```
//!
//! ### Pattern 8: `LoadAllResourceIcons`
//! ```vb
//! Function LoadAllResourceIcons(startID As Integer, _
//!                               endID As Integer) As Collection
//!     Dim col As New Collection
//!     Dim i As Integer
//!     Dim pic As StdPicture
//!     
//!     On Error Resume Next
//!     For i = startID To endID
//!         Set pic = LoadResPicture(i, vbResIcon)
//!         If Err.Number = 0 Then
//!             col.Add pic
//!         End If
//!         Err.Clear
//!     Next i
//!     
//!     Set LoadAllResourceIcons = col
//! End Function
//! ```
//!
//! ### Pattern 9: `SetButtonIcon`
//! ```vb
//! Sub SetButtonIcon(btn As CommandButton, _
//!                   ByVal iconID As Integer, _
//!                   ByVal enabled As Boolean)
//!     On Error Resume Next
//!     
//!     If enabled Then
//!         Set btn.Picture = LoadResPicture(iconID, vbResIcon)
//!     Else
//!         Set btn.Picture = LoadResPicture(iconID + 100, vbResIcon)
//!     End If
//!     
//!     btn.enabled = enabled
//! End Sub
//! ```
//!
//! ### Pattern 10: `LoadResourceArray`
//! ```vb
//! Sub LoadResourceArray(ByRef picArray() As StdPicture, _
//!                       ByVal startID As Integer, _
//!                       ByVal count As Integer, _
//!                       ByVal resFormat As Integer)
//!     Dim i As Integer
//!     ReDim picArray(1 To count)
//!     
//!     On Error Resume Next
//!     For i = 1 To count
//!         Set picArray(i) = LoadResPicture(startID + i - 1, resFormat)
//!         If Err.Number <> 0 Then
//!             Debug.Print "Failed to load resource: " & (startID + i - 1)
//!             Err.Clear
//!         End If
//!     Next i
//! End Sub
//! ```
//!
//! ## Advanced Examples
//!
//! ### Example 1: Resource Picture Manager
//! ```vb
//! ' Class: ResPictureManager
//! Private m_cache As Collection
//!
//! Private Sub Class_Initialize()
//!     Set m_cache = New Collection
//! End Sub
//!
//! Public Function LoadPicture(ByVal resID As Variant, _
//!                             ByVal resFormat As Integer) As StdPicture
//!     Dim key As String
//!     On Error Resume Next
//!     
//!     key = CStr(resID) & "_" & CStr(resFormat)
//!     Set LoadPicture = m_cache(key)
//!     
//!     If Err.Number <> 0 Then
//!         Err.Clear
//!         Set LoadPicture = LoadResPicture(resID, resFormat)
//!         If Err.Number = 0 Then
//!             m_cache.Add LoadPicture, key
//!         Else
//!             Err.Raise vbObjectError + 1000, "ResPictureManager", _
//!                       "Failed to load resource"
//!         End If
//!     End If
//! End Function
//!
//! Public Sub AssignToControl(ByVal ctrl As Object, _
//!                            ByVal resID As Variant, _
//!                            ByVal resFormat As Integer)
//!     Set ctrl.Picture = LoadPicture(resID, resFormat)
//! End Sub
//!
//! Public Sub ClearCache()
//!     Dim i As Long
//!     For i = m_cache.Count To 1 Step -1
//!         m_cache.Remove i
//!     Next i
//! End Sub
//!
//! Public Property Get CacheSize() As Long
//!     CacheSize = m_cache.Count
//! End Property
//!
//! Private Sub Class_Terminate()
//!     ClearCache
//!     Set m_cache = Nothing
//! End Sub
//! ```
//!
//! ### Example 2: Image Gallery from Resources
//! ```vb
//! ' Form with Picture1, Timer1, cmdNext, cmdPrev, lblInfo
//! Private Const BASE_IMAGE_ID = 1001
//! Private Const IMAGE_COUNT = 10
//! Private currentIndex As Long
//!
//! Private Sub Form_Load()
//!     currentIndex = 0
//!     ShowCurrentImage
//!     Timer1.Interval = 5000 ' 5 seconds
//!     Timer1.Enabled = True
//! End Sub
//!
//! Private Sub ShowCurrentImage()
//!     Dim imageID As Integer
//!     On Error Resume Next
//!     
//!     imageID = BASE_IMAGE_ID + currentIndex
//!     Set Picture1.Picture = LoadResPicture(imageID, vbResBitmap)
//!     
//!     If Err.Number <> 0 Then
//!         Picture1.Cls
//!         Picture1.Print "Image not found"
//!     Else
//!         lblInfo.Caption = "Image " & (currentIndex + 1) & " of " & IMAGE_COUNT
//!     End If
//!     Err.Clear
//! End Sub
//!
//! Private Sub Timer1_Timer()
//!     NextImage
//! End Sub
//!
//! Private Sub cmdNext_Click()
//!     NextImage
//! End Sub
//!
//! Private Sub cmdPrev_Click()
//!     PrevImage
//! End Sub
//!
//! Private Sub NextImage()
//!     currentIndex = (currentIndex + 1) Mod IMAGE_COUNT
//!     ShowCurrentImage
//! End Sub
//!
//! Private Sub PrevImage()
//!     currentIndex = (currentIndex - 1 + IMAGE_COUNT) Mod IMAGE_COUNT
//!     ShowCurrentImage
//! End Sub
//! ```
//!
//! ### Example 3: Toolbar with Resource Icons
//! ```vb
//! ' Form with toolbar buttons array: cmdTool(0 to 9)
//! Private Type ToolButton
//!     caption As String
//!     iconID As Integer
//!     enabled As Boolean
//!     tooltip As String
//! End Type
//!
//! Private toolConfig() As ToolButton
//!
//! Private Sub Form_Load()
//!     InitializeToolbar
//!     ApplyToolbarConfig
//! End Sub
//!
//! Private Sub InitializeToolbar()
//!     ReDim toolConfig(0 To 9)
//!     
//!     With toolConfig(0)
//!         .caption = "New"
//!         .iconID = 201
//!         .enabled = True
//!         .tooltip = "Create new document"
//!     End With
//!     
//!     With toolConfig(1)
//!         .caption = "Open"
//!         .iconID = 202
//!         .enabled = True
//!         .tooltip = "Open existing document"
//!     End With
//!     
//!     With toolConfig(2)
//!         .caption = "Save"
//!         .iconID = 203
//!         .enabled = False
//!         .tooltip = "Save current document"
//!     End With
//!     
//!     ' ... more buttons
//! End Sub
//!
//! Private Sub ApplyToolbarConfig()
//!     Dim i As Long
//!     On Error Resume Next
//!     
//!     For i = 0 To UBound(toolConfig)
//!         With cmdTool(i)
//!             .caption = toolConfig(i).caption
//!             .enabled = toolConfig(i).enabled
//!             .ToolTipText = toolConfig(i).tooltip
//!             
//!             Set .Picture = LoadResPicture(toolConfig(i).iconID, vbResIcon)
//!             If Err.Number <> 0 Then
//!                 Debug.Print "Failed to load icon: " & toolConfig(i).iconID
//!                 Err.Clear
//!             End If
//!         End With
//!     Next i
//! End Sub
//!
//! Public Sub EnableTool(ByVal index As Long)
//!     If index >= 0 And index <= UBound(toolConfig) Then
//!         toolConfig(index).enabled = True
//!         cmdTool(index).enabled = True
//!     End If
//! End Sub
//!
//! Public Sub DisableTool(ByVal index As Long)
//!     If index >= 0 And index <= UBound(toolConfig) Then
//!         toolConfig(index).enabled = False
//!         cmdTool(index).enabled = False
//!     End If
//! End Sub
//! ```
//!
//! ### Example 4: Multi-State Indicator
//! ```vb
//! ' Form with imgStatus (Image control)
//! Public Enum StatusState
//!     stIdle = 0
//!     stProcessing = 1
//!     stSuccess = 2
//!     stWarning = 3
//!     stError = 4
//! End Enum
//!
//! Private Const RES_STATUS_IDLE = 301
//! Private Const RES_STATUS_PROCESSING = 302
//! Private Const RES_STATUS_SUCCESS = 303
//! Private Const RES_STATUS_WARNING = 304
//! Private Const RES_STATUS_ERROR = 305
//!
//! Private statusIcons() As StdPicture
//! Private currentStatus As StatusState
//!
//! Private Sub Form_Load()
//!     LoadStatusIcons
//!     SetStatus stIdle
//! End Sub
//!
//! Private Sub LoadStatusIcons()
//!     ReDim statusIcons(0 To 4)
//!     
//!     On Error Resume Next
//!     Set statusIcons(stIdle) = LoadResPicture(RES_STATUS_IDLE, vbResIcon)
//!     Set statusIcons(stProcessing) = LoadResPicture(RES_STATUS_PROCESSING, vbResIcon)
//!     Set statusIcons(stSuccess) = LoadResPicture(RES_STATUS_SUCCESS, vbResIcon)
//!     Set statusIcons(stWarning) = LoadResPicture(RES_STATUS_WARNING, vbResIcon)
//!     Set statusIcons(stError) = LoadResPicture(RES_STATUS_ERROR, vbResIcon)
//!     
//!     If Err.Number <> 0 Then
//!         MsgBox "Warning: Some status icons could not be loaded", vbExclamation
//!         Err.Clear
//!     End If
//! End Sub
//!
//! Public Sub SetStatus(ByVal newStatus As StatusState)
//!     currentStatus = newStatus
//!     
//!     If newStatus >= 0 And newStatus <= UBound(statusIcons) Then
//!         If Not statusIcons(newStatus) Is Nothing Then
//!             Set imgStatus.Picture = statusIcons(newStatus)
//!         End If
//!     End If
//! End Sub
//!
//! Public Function GetStatus() As StatusState
//!     GetStatus = currentStatus
//! End Function
//!
//! Private Sub Form_Unload(Cancel As Integer)
//!     Dim i As Long
//!     For i = 0 To UBound(statusIcons)
//!         Set statusIcons(i) = Nothing
//!     Next i
//! End Sub
//! ```
//!
//! ## Error Handling
//!
//! ```vb
//! ' Error 32813: Resource not found
//! On Error Resume Next
//! Set pic = LoadResPicture(999, vbResBitmap)
//! If Err.Number = 32813 Then
//!     MsgBox "Resource not found!"
//! End If
//!
//! ' Error 48: Error loading from file
//! Set pic = LoadResPicture(101, vbResBitmap)
//! If Err.Number = 48 Then
//!     MsgBox "Resource file is corrupt or missing!"
//! End If
//!
//! ' Safe loading pattern
//! Function TryLoadResPicture(ByVal resID As Variant, _
//!                            ByVal resFormat As Integer, _
//!                            ByRef pic As StdPicture) As Boolean
//!     On Error Resume Next
//!     Set pic = LoadResPicture(resID, resFormat)
//!     TryLoadResPicture = (Err.Number = 0)
//!     Err.Clear
//! End Function
//! ```
//!
//! ## Performance Considerations
//!
//! - **Fast Loading**: Resources embedded in EXE (very fast access)
//! - **No File I/O**: No disk access required
//! - **Memory Usage**: Pictures consume memory until released
//! - **No Caching**: Each call loads fresh copy (implement caching if needed)
//! - **Preloading**: Load frequently used images once at startup
//! - **EXE Size**: Large images increase executable size
//!
//! ## Best Practices
//!
//! 1. **Always handle errors** - resource might not exist
//! 2. **Use constants** for resource IDs for maintainability
//! 3. **Preload frequently used images** for better performance
//! 4. **Release memory** by setting picture objects to Nothing when done
//! 5. **Use meaningful names** for string-based resource IDs
//! 6. **Test all resources** during development
//! 7. **Document resource IDs** in code or separate file
//! 8. **Use Resource Editor** to manage resources efficiently
//! 9. **Consider image size** - large bitmaps increase EXE size
//! 10. **Cache in Collection** for images used multiple times
//!
//! ## Comparison with Related Functions
//!
//! | Function | Purpose | Source | External Files |
//! |----------|---------|--------|----------------|
//! | **`LoadResPicture`** | Load from resources | Embedded .res | No |
//! | **`LoadPicture`** | Load from file | External file | Yes |
//! | **`LoadResData`** | Load binary data | Embedded .res | No |
//! | **`LoadResString`** | Load string | Embedded .res | No |
//!
//! ## `LoadResPicture` vs `LoadPicture`
//!
//! ```vb
//! ' LoadResPicture - from embedded resources
//! Picture1.Picture = LoadResPicture(101, vbResBitmap)
//!
//! ' LoadPicture - from external file
//! Picture1.Picture = LoadPicture("C:\Images\logo.bmp")
//! ```
//!
//! **When to use each:**
//! - **`LoadResPicture`**: Distribution (no external files), static images, faster loading
//! - **`LoadPicture`**: Dynamic images, user-selected files, easier updates
//!
//! ## Resource Format Constants
//!
//! ```vb
//! ' Format constants
//! Const vbResBitmap = 0  ' Bitmap (.bmp)
//! Const vbResIcon = 1    ' Icon (.ico)
//! Const vbResCursor = 2  ' Cursor (.cur)
//!
//! ' Usage
//! Picture1.Picture = LoadResPicture(101, vbResBitmap)
//! Image1.Picture = LoadResPicture(102, vbResIcon)
//! Me.MouseIcon = LoadResPicture(103, vbResCursor)
//! ```
//!
//! ## Platform Notes
//!
//! - Available in VB6 (not in early VB versions)
//! - Requires resource file (.res) linked to project
//! - Resource file created with Resource Editor or RC.EXE
//! - Only one resource file per project
//! - Resources embedded in compiled EXE/DLL
//! - Returns `StdPicture` object (OLE automation object)
//! - Supports BMP, ICO, CUR formats only
//! - No native support for JPG, GIF, PNG
//! - Format parameter: 0=Bitmap, 1=Icon, 2=Cursor
//! - Icons can contain multiple sizes
//!
//! ## Limitations
//!
//! - **Format Support**: Only BMP, ICO, CUR (no JPG/GIF/PNG)
//! - **One Resource File**: Only one .res file per project
//! - **Compile Time**: Must recompile to update resources
//! - **No Modification**: Cannot modify resources at runtime
//! - **No Caching**: Each call reloads from resource
//! - **EXE Size**: Large images significantly increase EXE size
//! - **No Compression**: Images stored uncompressed
//! - **Limited Editor**: VB6 Resource Editor is basic
//! - **No Metadata**: Cannot read image dimensions before loading
//! - **Memory Usage**: Large images consume significant memory
//!
//! ## Related Functions
//!
//! - `LoadPicture`: Load picture from external file
//! - `LoadResData`: Load custom binary data from resources
//! - `LoadResString`: Load string from resources
//! - `SavePicture`: Save picture object to file
//! - `Set`: Assign object references

#[cfg(test)]
mod tests {
    use crate::*;

    #[test]
    fn loadrespicture_basic() {
        let source = r"
            Set Picture1.Picture = LoadResPicture(101, vbResBitmap)
        ";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_icon() {
        let source = r"
            Image1.Picture = LoadResPicture(102, vbResIcon)
        ";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_if_statement() {
        let source = r"
            If hasResource Then
                Picture1.Picture = LoadResPicture(resID, vbResBitmap)
            End If
        ";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_string_name() {
        let source = r#"
            Picture1.Picture = LoadResPicture("LOGO", vbResBitmap)
        "#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_form_load() {
        let source = r"
            Private Sub Form_Load()
                Me.Picture = LoadResPicture(101, vbResBitmap)
            End Sub
        ";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_array_assignment() {
        let source = r"
            Set images(i) = LoadResPicture(100 + i, vbResBitmap)
        ";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_for_loop() {
        let source = r"
            For i = 1 To 5
                Set imgArray(i).Picture = LoadResPicture(100 + i, vbResBitmap)
            Next i
        ";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_function_return() {
        let source = r"
            Function GetResPicture() As StdPicture
                Set GetResPicture = LoadResPicture(101, vbResBitmap)
            End Function
        ";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_error_handling() {
        let source = r#"
            On Error Resume Next
            Picture1.Picture = LoadResPicture(999, vbResBitmap)
            If Err.Number = 32813 Then
                MsgBox "Resource not found"
            End If
        "#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_with_statement() {
        let source = r"
            With Picture1
                .Picture = LoadResPicture(101, vbResBitmap)
            End With
        ";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_select_case() {
        let source = r"
            Select Case imageType
                Case 1
                    Picture1.Picture = LoadResPicture(101, vbResBitmap)
                Case 2
                    Picture1.Picture = LoadResPicture(102, vbResIcon)
            End Select
        ";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_elseif() {
        let source = r#"
            If mode = "dark" Then
                Picture1.Picture = LoadResPicture(201, vbResBitmap)
            ElseIf mode = "light" Then
                Picture1.Picture = LoadResPicture(101, vbResBitmap)
            End If
        "#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_parentheses() {
        let source = r"
            Set pic = (LoadResPicture(101, vbResBitmap))
        ";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_iif() {
        let source = r"
            Picture1.Picture = IIf(enabled, LoadResPicture(101, vbResIcon), LoadResPicture(102, vbResIcon))
        ";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_in_class() {
        let source = r"
            Private Sub Class_Initialize()
                Set m_defaultPic = LoadResPicture(101, vbResBitmap)
            End Sub
        ";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_function_argument() {
        let source = r"
            Call SetPicture(LoadResPicture(101, vbResBitmap))
        ";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_property_assignment() {
        let source = r"
            Set MyForm.Picture = LoadResPicture(101, vbResBitmap)
        ";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_is_nothing() {
        let source = r#"
            Set pic = LoadResPicture(101, vbResBitmap)
            If pic Is Nothing Then
                MsgBox "Failed to load"
            End If
        "#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_while_wend() {
        let source = r"
            While index < maxImages
                Set images(index) = LoadResPicture(100 + index, vbResBitmap)
                index = index + 1
            Wend
        ";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_do_while() {
        let source = r"
            Do While hasMore
                Set currentPic = LoadResPicture(GetNextID(), vbResBitmap)
            Loop
        ";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_do_until() {
        let source = r"
            Do Until loaded
                On Error Resume Next
                Set pic = LoadResPicture(resID, vbResBitmap)
                loaded = (Err.Number = 0)
            Loop
        ";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_cursor() {
        let source = r"
            Me.MousePointer = vbCustom
            Me.MouseIcon = LoadResPicture(103, vbResCursor)
        ";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_constants() {
        let source = r"
            Const RES_LOGO = 101
            Picture1.Picture = LoadResPicture(RES_LOGO, vbResBitmap)
        ";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_addition() {
        let source = r"
            Dim imageID As Integer
            imageID = 100 + selectedIndex
            Picture1.Picture = LoadResPicture(imageID, vbResBitmap)
        ";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_toolbar_button() {
        let source = r"
            cmdSave.Picture = LoadResPicture(203, vbResIcon)
        ";
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_debug_print() {
        let source = r#"
            Set pic = LoadResPicture(101, vbResBitmap)
            Debug.Print "Loaded resource 101"
        "#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }

    #[test]
    fn loadrespicture_msgbox() {
        let source = r#"
            On Error Resume Next
            Set pic = LoadResPicture(101, vbResBitmap)
            If Err.Number <> 0 Then
                MsgBox "Failed to load resource"
            End If
        "#;
        let (cst_opt, _failures) = ConcreteSyntaxTree::from_text("test.bas", source).unpack();
        let cst = cst_opt.expect("CST should be parsed");

        let tree = cst.to_serializable();

        let mut settings = insta::Settings::clone_current();
        settings.set_snapshot_path(
            "../../../../../snapshots/syntax/library/functions/resources/loadrespicture",
        );
        settings.set_prepend_module_to_snapshot(false);
        let _guard = settings.bind_to_scope();
        insta::assert_yaml_snapshot!(tree);
    }
}