You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
;;This is like a key loop, except that it will exclude any keys that
198
+
;;use the exact same segments as a key that has already been processed.
199
+
200
+
data loop = ^as(node, KeyLoopNode)
201
+
data context = template.Context
202
+
203
+
if (template.Context.CurrentStructure.Keys.Count == 0)
204
+
throw new ApplicationException(String.Format("The <{0}> loop at line {1} in template {2} can't be processed because structure {3} has no keys!", node.OpenToken.Value, node.OpenToken.StartLineNumber, template.Context.CurrentTemplateBaseName, template.Context.CurrentStructure.Name))
data prevKeysSegments = new List<RpsKeySegmentCollection>()
227
+
data otherKeySegments, @RpsKeySegmentCollection
228
+
229
+
;;Iterate through all the keys in the structure
230
+
for ix from 0 thru template.Context.CurrentStructure.Keys.Count - 1
231
+
begin
232
+
;; Skip any foreign keys
233
+
if (template.Context.CurrentStructure.Keys[ix].KeyType == RpsKeyType.Foreign)
234
+
nextloop
235
+
236
+
;;If we get here we have an access key. Assume it's a duplicate and we'll look for a difference
237
+
data segmentsMatchAnotherKey = false
238
+
239
+
;;If we havent processed any other keys yet then we can't have a duplicate, so this one gets included
240
+
if (prevKeysSegments.Count > 0)
241
+
begin
242
+
;;We have processed other keys, so make sure the segments of this key don't match any we have already processed
243
+
data segmentsMatchThisKey, boolean
244
+
data thisKeySegments, @RpsKeySegmentCollection, template.Context.CurrentStructure.Keys[ix].Segments
245
+
246
+
data iy, int
247
+
for iy from 0 thru prevKeysSegments.Count - 1
248
+
begin
249
+
;;Assume we have a duplicate, look for a difference
250
+
segmentsMatchThisKey = true
251
+
otherKeySegments = prevKeysSegments[iy]
252
+
253
+
;;Same number of segments?
254
+
if (thisKeySegments.Count != otherKeySegments.Count) then
255
+
begin
256
+
;;Different segment count, not a duplicate
257
+
segmentsMatchThisKey = false
258
+
end
259
+
else
260
+
begin
261
+
;;Same segment count, look at each segment
262
+
data thisKeySeg, @RpsKeySegment
263
+
data otherKeySeg, @RpsKeySegment
264
+
265
+
data iz, int
266
+
data allSegmentsMatch = true
267
+
268
+
;;Iterate through the segments looking for a diff
269
+
for iz from 0 thru thisKeySegments.Count - 1
270
+
begin
271
+
thisKeySeg = thisKeySegments[iz]
272
+
otherKeySeg = otherKeySegments[iz]
273
+
274
+
using thisKeySeg.SegmentType select
275
+
(RpsKeySegmentType.Field),
276
+
begin
277
+
if ((otherKeySeg.SegmentType != RpsKeySegmentType.Field) || (!otherKeySeg.Field.Equals(thisKeySeg.Field)))
278
+
begin
279
+
allSegmentsMatch = false
280
+
end
281
+
end
282
+
(RpsKeySegmentType.Literal),
283
+
begin
284
+
if ((otherKeySeg.SegmentType != RpsKeySegmentType.Literal) || (!otherKeySeg.LiteralValue.Equals(thisKeySeg.LiteralValue)))
285
+
begin
286
+
allSegmentsMatch = false
287
+
end
288
+
end
289
+
(RpsKeySegmentType.External),
290
+
begin
291
+
throw new ApplicationException(String.Format("The <{0}> loop at line {1} in template {2} can't be processed because an unsupported key segment type of 'External' was encountered!", node.OpenToken.Value, node.OpenToken.StartLineNumber, template.Context.CurrentTemplateBaseName))
292
+
end
293
+
(RpsKeySegmentType.RecordNumber),
294
+
begin
295
+
throw new ApplicationException(String.Format("The <{0}> loop at line {1} in template {2} can't be processed because an unsupported key segment type of 'Record Number' was encountered!", node.OpenToken.Value, node.OpenToken.StartLineNumber, template.Context.CurrentTemplateBaseName))
;;This is like an alternate key loop, except that it will exclude any keys that
377
+
;;use the exact same segments as a key that has already been processed.
378
+
379
+
data loop = ^as(node, KeyLoopNode)
380
+
data context = template.Context
381
+
382
+
if (template.Context.CurrentStructure.Keys.Count == 0)
383
+
throw new ApplicationException(String.Format("The <{0}> loop at line {1} in template {2} can't be processed because structure {3} has no keys!", node.OpenToken.Value, node.OpenToken.StartLineNumber, template.Context.CurrentTemplateBaseName, template.Context.CurrentStructure.Name))
data prevKeysSegments = new List<RpsKeySegmentCollection>()
406
+
data otherKeySegments, @RpsKeySegmentCollection
407
+
408
+
;;Iterate through all the keys in the structure
409
+
for ix from 0 thru template.Context.CurrentStructure.Keys.Count - 1
410
+
begin
411
+
;; Skip the first key and any foreign keys
412
+
if ((ix == 0) || (template.Context.CurrentStructure.Keys[ix].KeyType == RpsKeyType.Foreign))
413
+
nextloop
414
+
415
+
;;If we get here we have an alternate access key. Assume it's a duplicate and we'll look for a difference
416
+
data segmentsMatchAnotherKey = false
417
+
418
+
;;If we havent processed any other keys yet then we can't have a duplicate, so this one gets included
419
+
if (prevKeysSegments.Count > 0)
420
+
begin
421
+
;;We have processed other keys, so make sure the segments of this key don't match any we have already processed
422
+
data segmentsMatchThisKey, boolean
423
+
data thisKeySegments, @RpsKeySegmentCollection, template.Context.CurrentStructure.Keys[ix].Segments
424
+
425
+
data iy, int
426
+
for iy from 0 thru prevKeysSegments.Count - 1
427
+
begin
428
+
;;Assume we have a duplicate, look for a difference
429
+
segmentsMatchThisKey = true
430
+
otherKeySegments = prevKeysSegments[iy]
431
+
432
+
;;Same number of segments?
433
+
if (thisKeySegments.Count != otherKeySegments.Count) then
434
+
begin
435
+
;;Different segment count, not a duplicate
436
+
segmentsMatchThisKey = false
437
+
end
438
+
else
439
+
begin
440
+
;;Same segment count, look at each segment
441
+
data thisKeySeg, @RpsKeySegment
442
+
data otherKeySeg, @RpsKeySegment
443
+
444
+
data iz, int
445
+
data allSegmentsMatch = true
446
+
447
+
;;Iterate through the segments looking for a diff
448
+
for iz from 0 thru thisKeySegments.Count - 1
449
+
begin
450
+
thisKeySeg = thisKeySegments[iz]
451
+
otherKeySeg = otherKeySegments[iz]
452
+
453
+
using thisKeySeg.SegmentType select
454
+
(RpsKeySegmentType.Field),
455
+
begin
456
+
if ((otherKeySeg.SegmentType != RpsKeySegmentType.Field) || (!otherKeySeg.Field.Equals(thisKeySeg.Field)))
457
+
begin
458
+
allSegmentsMatch = false
459
+
end
460
+
end
461
+
(RpsKeySegmentType.Literal),
462
+
begin
463
+
if ((otherKeySeg.SegmentType != RpsKeySegmentType.Literal) || (!otherKeySeg.LiteralValue.Equals(thisKeySeg.LiteralValue)))
464
+
begin
465
+
allSegmentsMatch = false
466
+
end
467
+
end
468
+
(RpsKeySegmentType.External),
469
+
begin
470
+
throw new ApplicationException(String.Format("The <{0}> loop at line {1} in template {2} can't be processed because an unsupported key segment type of 'External' was encountered!", node.OpenToken.Value, node.OpenToken.StartLineNumber, template.Context.CurrentTemplateBaseName))
471
+
end
472
+
(RpsKeySegmentType.RecordNumber),
473
+
begin
474
+
throw new ApplicationException(String.Format("The <{0}> loop at line {1} in template {2} can't be processed because an unsupported key segment type of 'Record Number' was encountered!", node.OpenToken.Value, node.OpenToken.StartLineNumber, template.Context.CurrentTemplateBaseName))
0 commit comments