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
|
/* Classic Ladder Project */
/* Copyright (C) 2001-2007 Marc Le Douarain */
/* http://membres.lycos.fr/mavati/classicladder/ */
/* http://www.sourceforge.net/projects/classicladder */
/* June 2007 (but only old code moved here!) */
/* --------------------------------------- */
/* Variable names strings for display/edit */
/* --------------------------------------- */
/* This library is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Lesser General Public */
/* License as published by the Free Software Foundation; either */
/* version 2.1 of the License, or (at your option) any later version. */
/* This library 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 for more details. */
/* You should have received a copy of the GNU Lesser General Public */
/* License along with this library; if not, write to the Free Software */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "classicladder.h"
#include "global.h"
#include "symbols.h"
#include "vars_names.h"
// include the var name table (not a header!)
#include "vars_names_list.c"
//old code with names directly in it...
//to be deleted, but some precise errors codes aren't present in the new function...
#ifdef AAAAAAAAA
char * CreateVarName(int Type, int Offset)
{
static char Buffer[20];
switch(Type)
{
case VAR_MEM_BIT:
sprintf(Buffer,"%cB%d",'%',Offset);
break;
#ifdef OLD_TIMERS_MONOS_SUPPORT
case VAR_TIMER_DONE:
sprintf(Buffer,"%cT%d.D",'%',Offset);
break;
case VAR_TIMER_RUNNING:
sprintf(Buffer,"%cT%d.R",'%',Offset);
break;
case VAR_MONOSTABLE_RUNNING:
sprintf(Buffer,"%cM%d.R",'%',Offset);
break;
#endif
case VAR_TIMER_IEC_DONE:
sprintf(Buffer,"%cTM%d.Q",'%',Offset);
break;
case VAR_COUNTER_DONE:
sprintf(Buffer,"%cC%d.D",'%',Offset);
break;
case VAR_COUNTER_EMPTY:
sprintf(Buffer,"%cC%d.E",'%',Offset);
break;
case VAR_COUNTER_FULL:
sprintf(Buffer,"%cC%d.F",'%',Offset);
break;
case VAR_STEP_ACTIVITY:
sprintf(Buffer,"%cX%d",'%',Offset);
break;
case VAR_PHYS_INPUT:
sprintf(Buffer,"%cI%d",'%',Offset);
break;
case VAR_PHYS_OUTPUT:
sprintf(Buffer,"%cQ%d",'%',Offset);
break;
case VAR_MEM_WORD:
sprintf(Buffer,"%cW%d",'%',Offset);
break;
case VAR_STEP_TIME:
sprintf(Buffer,"%cX%d.V",'%',Offset);
break;
#ifdef OLD_TIMERS_MONOS_SUPPORT
case VAR_TIMER_PRESET:
sprintf(Buffer,"%cT%d.P",'%',Offset);
break;
case VAR_TIMER_VALUE:
sprintf(Buffer,"%cT%d.V",'%',Offset);
break;
case VAR_MONOSTABLE_PRESET:
sprintf(Buffer,"%cM%d.P",'%',Offset);
break;
case VAR_MONOSTABLE_VALUE:
sprintf(Buffer,"%cM%d.V",'%',Offset);
break;
#endif
case VAR_TIMER_IEC_PRESET:
sprintf(Buffer,"%cTM%d.P",'%',Offset);
break;
case VAR_TIMER_IEC_VALUE:
sprintf(Buffer,"%cTM%d.V",'%',Offset);
break;
case VAR_COUNTER_PRESET:
sprintf(Buffer,"%cC%d.P",'%',Offset);
break;
case VAR_COUNTER_VALUE:
sprintf(Buffer,"%cC%d.V",'%',Offset);
break;
default:
sprintf(Buffer,"???");
break;
}
printf("infogene display symbols=&i\n",InfosGene->DisplaySymbols);
if ( InfosGene->DisplaySymbols )
{
// verify if a symbol has been defined for the variable...
char * Symbol = ConvVarNameToSymbol( Buffer );
if ( (Symbol!=NULL )||(Symbol[0]!=' ')||(Symbol[0]!='\0')){
return Symbol;}
}
return Buffer;
}
/* Convert a string to a number if >=Min and <=Max */
/* return TRUE if okay */
/* (pointer advance !) */
int TextToNumberAndAdvance(char ** text,int ValMin,int ValMaxi,int *ValFound)
{
int IsOk = TRUE;
int Value = 0;
char * pScan = *text;
char NumberFound = FALSE;
while( *pScan>='0' && *pScan<='9' )
{
Value = Value*10+(*pScan-'0');
pScan++;
NumberFound = TRUE;
}
if ( !NumberFound || (Value<ValMin) || (Value>ValMaxi) )
IsOk = FALSE;
if (IsOk)
{
*ValFound = Value;
*text = pScan;
}
return IsOk;
}
/* Convert a string to variable (type/offset) */
/* if pNumberOfChars not NULL, give length of the string found */
/* return TRUE if okay */
char TextParserForAVar( char * text,int * VarTypeFound,int * VarOffsetFound, int * pNumberOfChars, char PartialNames )
{
int TypeFound = 0;
int OffsetFound;
int IsOk = TRUE;
char TimerIEC = FALSE;
char * pScanPos = text; // content will be modified when advancing!
char * * pPtrScanPos = &pScanPos;
char * VarNameFromSymbol = NULL;
int MaxNbr = 0;
// if not commencing per '%', search the corresponding symbol !
if ( *pScanPos!='%' )
{
VarNameFromSymbol = ConvSymbolToVarName( pScanPos );
if ( VarNameFromSymbol==NULL )
{
IsOk = FALSE;
ErrorMessageVarParser = "Unknown symbol for variable name";
}
else
{
pScanPos = VarNameFromSymbol;
}
}
if ( IsOk )
{
// pass the first character '%'
(*pPtrScanPos)++;
switch(**pPtrScanPos)
{
case 'B':
TypeFound = VAR_MEM_BIT;
(*pPtrScanPos)++;
if (!TextToNumberAndAdvance(pPtrScanPos,0,NBR_BITS-1,&OffsetFound))
{
IsOk = FALSE;
ErrorMessageVarParser = "Unknown variable (number value out of bound)";
}
break;
case 'T':
(*pPtrScanPos)++;
// New IEC Timer ?
if ( **pPtrScanPos=='M' )
{
TimerIEC = TRUE;
(*pPtrScanPos)++;
}
MaxNbr = NBR_TIMERS_IEC-1;
#ifdef OLD_TIMERS_MONOS_SUPPORT
if ( TimerIEC==FALSE )
MaxNbr = NBR_TIMERS-1;
#else
TimerIEC = TRUE;
#endif
if (!TextToNumberAndAdvance(pPtrScanPos,0,MaxNbr,&OffsetFound))
{
IsOk = FALSE;
ErrorMessageVarParser = "Unknown variable (number value out of bound)";
}
else
{
if ( PartialNames==FALSE )
{
if ( **pPtrScanPos!=VAR_ATTRIBUTE_SEP )
{
IsOk = FALSE;
ErrorMessageVarParser = "Unknown variable (missing '.' character before attribute)";
}
else
{
(*pPtrScanPos)++;
switch(**pPtrScanPos)
{
case 'D':
if ( TimerIEC==FALSE )
{
TypeFound = VAR_TIMER_DONE;
}
else
{
IsOk = FALSE;
ErrorMessageVarParser = "Unknown variable (unknown attribute)";
}
break;
case 'Q':
if ( TimerIEC==TRUE )
{
TypeFound = VAR_TIMER_IEC_DONE;
}
else
{
IsOk = FALSE;
ErrorMessageVarParser = "Unknown variable (unknown attribute)";
}
break;
case 'R':
if ( TimerIEC==FALSE )
{
TypeFound = VAR_TIMER_RUNNING;
}
else
{
IsOk = FALSE;
ErrorMessageVarParser = "Unknown variable (unknown attribute)";
}
break;
case 'P':
TypeFound = (TimerIEC==FALSE)?VAR_TIMER_PRESET:VAR_TIMER_IEC_PRESET;
break;
case 'V':
TypeFound = (TimerIEC==FALSE)?VAR_TIMER_VALUE:VAR_TIMER_IEC_VALUE;
break;
default:
IsOk = FALSE;
ErrorMessageVarParser = "Unknown variable (unknown attribute)";
break;
}
(*pPtrScanPos)++;
}
}
}
break;
#ifdef OLD_TIMERS_MONOS_SUPPORT
case 'M':
(*pPtrScanPos)++;
if (!TextToNumberAndAdvance(pPtrScanPos,0,NBR_MONOSTABLES-1,&OffsetFound))
{
IsOk = FALSE;
ErrorMessageVarParser = "Unknown variable (number value out of bound)";
}
else
{
if ( PartialNames==FALSE )
{
if ( **pPtrScanPos!=VAR_ATTRIBUTE_SEP )
{
IsOk = FALSE;
ErrorMessageVarParser = "Unknown variable (missing '.' character before attribute)";
}
else
{
(*pPtrScanPos)++;
switch(**pPtrScanPos)
{
case 'R':
TypeFound = VAR_MONOSTABLE_RUNNING;
break;
case 'P':
TypeFound = VAR_MONOSTABLE_PRESET;
break;
case 'V':
TypeFound = VAR_MONOSTABLE_VALUE;
break;
default:
IsOk = FALSE;
ErrorMessageVarParser = "Unknown variable (unknown attribute)";
break;
}
(*pPtrScanPos)++;
}
}
}
break;
#endif
case 'C':
(*pPtrScanPos)++;
if (!TextToNumberAndAdvance(pPtrScanPos,0,NBR_COUNTERS-1,&OffsetFound))
{
IsOk = FALSE;
ErrorMessageVarParser = "Unknown variable (number value out of bound)";
}
else
{
if ( PartialNames==FALSE )
{
if ( **pPtrScanPos!=VAR_ATTRIBUTE_SEP )
{
IsOk = FALSE;
ErrorMessageVarParser = "Unknown variable (missing '.' character before attribute)";
}
else
{
(*pPtrScanPos)++;
switch(**pPtrScanPos)
{
case 'D':
TypeFound = VAR_COUNTER_DONE;
break;
case 'E':
TypeFound = VAR_COUNTER_EMPTY;
break;
case 'F':
TypeFound = VAR_COUNTER_FULL;
break;
case 'P':
TypeFound = VAR_COUNTER_PRESET;
break;
case 'V':
TypeFound = VAR_COUNTER_VALUE;
break;
default:
IsOk = FALSE;
ErrorMessageVarParser = "Unknown variable (unknown attribute)";
break;
}
(*pPtrScanPos)++;
}
}
}
break;
case 'I':
TypeFound = VAR_PHYS_INPUT;
(*pPtrScanPos)++;
if (!TextToNumberAndAdvance(pPtrScanPos,0,NBR_PHYS_INPUTS-1,&OffsetFound))
{
IsOk = FALSE;
ErrorMessageVarParser = "Unknown variable (number value out of bound)";
}
break;
case 'Q':
TypeFound = VAR_PHYS_OUTPUT;
(*pPtrScanPos)++;
if (!TextToNumberAndAdvance(pPtrScanPos,0,NBR_PHYS_OUTPUTS-1,&OffsetFound))
{
IsOk = FALSE;
ErrorMessageVarParser = "Unknown variable (number value out of bound)";
}
break;
case 'W':
TypeFound = VAR_MEM_WORD;
(*pPtrScanPos)++;
if (!TextToNumberAndAdvance(pPtrScanPos,0,NBR_WORDS-1,&OffsetFound))
{
IsOk = FALSE;
ErrorMessageVarParser = "Unknown variable (number value out of bound)";
}
break;
#ifdef SEQUENTIAL_SUPPORT
case 'X':
TypeFound = VAR_STEP_ACTIVITY; //per default, but it could change later...
(*pPtrScanPos)++;
if (!TextToNumberAndAdvance(pPtrScanPos,0,NBR_STEPS-1,&OffsetFound))
{
IsOk = FALSE;
ErrorMessageVarParser = "Unknown variable (number value out of bound)";
}
else
{
// verify if there is a '.' after number so that it must be the Xyyy.V form
// instead of Xyyy form.
if ( **pPtrScanPos==VAR_ATTRIBUTE_SEP )
{
(*pPtrScanPos)++;
if ( **pPtrScanPos=='V' )
{
TypeFound = VAR_STEP_TIME;
}
else
{
IsOk = FALSE;
ErrorMessageVarParser = "Unknown variable (unknown attribute)";
}
}
}
break;
#endif
default:
IsOk = FALSE;
ErrorMessageVarParser = "Unknown variable (on first character following %)";
}
if (IsOk)
{
if ( VarTypeFound )
*VarTypeFound = TypeFound;
if ( VarOffsetFound )
*VarOffsetFound = OffsetFound;
if ( pNumberOfChars!=NULL )
*pNumberOfChars = (VarNameFromSymbol==NULL)?*pPtrScanPos-text : *pPtrScanPos-VarNameFromSymbol;
}
else
{
if ( ErrorMessageVarParser==NULL )
ErrorMessageVarParser = "Unknown variable (global error)";
}
}
return IsOk;
}
#endif
/* return 0 if bad or the number of characters to pass... */
int ComparStaticPart(char * pSearchedString, char * pComparString)
{
int iNbrCaracs = 0;
do
{
iNbrCaracs++;
}
while( (pComparString[ iNbrCaracs ]!='%') && (pComparString[ iNbrCaracs ]!='\0') );
if (strncmp(pSearchedString,pComparString,iNbrCaracs)==0)
return iNbrCaracs;
return 0;
}
/* Convert variable name -> internal ID of the corresponding var */
/* a little parser... */
/* return -1 if not found, else the corresponding Variable ID */
char TextParserForAVar( char * TextToParse, int * VarTypeFound,int * VarOffsetFound, int * pNumberOfChars, char PartialNames )
{
int iBalayTable = 0;
char bFound = FALSE, bEchecCompar,cOneAttributPassed ;
int iIdVar = -1,iBalayProf,iTaillePartieStatique;
StrConvIdVarName * pConv;
char * pVarCherch = TextToParse;
char * pBalayVarCherch;
int iScruteCarac;
int iOffset1;
int iOffset2;
int iOffset3;
//printf( "TextParserForAVar:start...\n" );
if (*TextToParse=='\0' )
return FALSE;
// if not commencing per '%', search the corresponding symbol !
if (*pVarCherch!='%')
{
pVarCherch = ConvSymbolToVarName( TextToParse );
if ( pVarCherch==NULL )
return FALSE;
}
else
{
// seems too much short for a base name !
if ( strlen(TextToParse)<3 )
return FALSE;
}
// pass the start '%' before parsing
pVarCherch++;
// scanning the base name variables table
do
{
pBalayVarCherch = pVarCherch;
bEchecCompar = FALSE;
iScruteCarac = 0;
iBalayProf = 0;
iOffset1 = 0;
iOffset2 = 0;
iOffset3 = 0;
cOneAttributPassed = FALSE;
// pointer on the table list
pConv = &TableConvIdVarName[ iBalayTable ];
do
{
// start number mark ?
if ( pConv->StringBaseVarName[ iScruteCarac ]=='%' )
{
// searching the end number mark in the base variable string
do
{
iScruteCarac++;
}
while ( (pConv->StringBaseVarName[ iScruteCarac ]!='d')
&& (pConv->StringBaseVarName[ iScruteCarac ]!='\0') );
iScruteCarac++;
// number value in the string searched
if ( *pBalayVarCherch>='0' && *pBalayVarCherch<='9' )
{
int iNumFound = 0;
do
{
iNumFound = iNumFound*10;
iNumFound = iNumFound + *pBalayVarCherch-'0';
pBalayVarCherch++;
}
while( *pBalayVarCherch>='0' && *pBalayVarCherch<='9');
switch( iBalayProf )
{
case 0: iOffset1 = iNumFound; break;
case 1: iOffset2 = iNumFound; break;
case 2: iOffset3 = iNumFound; break;
}
iBalayProf++;
}
else
{
bEchecCompar = TRUE;
}
}
else
{
if ( pConv->StringBaseVarName[ iScruteCarac ]=='.' )
cOneAttributPassed = TRUE;
// comparing static part...
iTaillePartieStatique = ComparStaticPart(pBalayVarCherch,&pConv->StringBaseVarName[ iScruteCarac ]);
if (iTaillePartieStatique>0)
{
iScruteCarac = iScruteCarac+iTaillePartieStatique;
pBalayVarCherch = pBalayVarCherch+iTaillePartieStatique;
}
else
{
bEchecCompar = TRUE;
if ( PartialNames && cOneAttributPassed )
return TRUE;
}
}
// at the end of the reference string ?
// if yes it means we have found what we were searching for (else perhaps another one exists starting by the same string)
if ( pConv->StringBaseVarName[ iScruteCarac ]=='\0' )
{
// verify that there isn't too much characters after !
// if yes, dropped...
// Put in comment because it is used in the arithmetic parser !!!!!
if ( !bEchecCompar /* && *pBalayVarCherch=='\0' */ )
bFound = TRUE;
else
bEchecCompar = TRUE;
}
}
while( !bEchecCompar && !bFound );
iBalayTable++;
}
while( !bFound && TableConvIdVarName[ iBalayTable ].StringBaseVarName );
if (bFound)
{
char bVerifCoherenceOk = TRUE;
// verify if offsets given are in
if ( iOffset1>=pConv->iSize1+pConv->iFirstVal1 )
bVerifCoherenceOk = FALSE;
if ( iOffset1<pConv->iFirstVal1 )
bVerifCoherenceOk = FALSE;
if ( pConv->iSize2>0 )
{
if ( iOffset2>=pConv->iSize2+pConv->iFirstVal2 )
bVerifCoherenceOk = FALSE;
if ( iOffset2<pConv->iFirstVal2 )
bVerifCoherenceOk = FALSE;
}
if ( pConv->iSize3>0 )
{
if ( iOffset3>=pConv->iSize3+pConv->iFirstVal3 )
bVerifCoherenceOk = FALSE;
if ( iOffset3<pConv->iFirstVal3 )
bVerifCoherenceOk = FALSE;
}
if ( bVerifCoherenceOk==FALSE )
ErrorMessageVarParser = "Unknown variable (number value out of bound)";
if (bVerifCoherenceOk)
{
// calc final Id
if ( pConv->iSize3<=0 && pConv->iSize2<=0 )
{
iIdVar = pConv->iIdVar + iOffset1-pConv->iFirstVal1;
}
else
{
if ( pConv->iSize3<=0 )
iIdVar = pConv->iIdVar + (iOffset1-pConv->iFirstVal1)*pConv->iSize2 + iOffset2-pConv->iFirstVal2;
else
iIdVar = pConv->iIdVar + (iOffset1-pConv->iFirstVal1)*pConv->iSize2*pConv->iSize3 + (iOffset2-pConv->iFirstVal2)*pConv->iSize3 + iOffset3-pConv->iFirstVal3;
}
if ( VarTypeFound!=NULL )
{
#ifdef IDVAR_IS_TYPE_AND_OFFSET
*VarTypeFound = pConv->iTypeVar;
#else
*VarTypeFound = VAR_DEFAULT_TYPE;
#endif
}
if ( VarOffsetFound!=NULL )
*VarOffsetFound = iIdVar;
if ( pNumberOfChars!=NULL )
*pNumberOfChars = pBalayVarCherch-TextToParse;
}
else
{
bFound = FALSE;
}
}
return bFound;
}
StrConvIdVarName * ConvIdVarEnPtrSurEleConv( int iTypeVarToSearch, int iIdVarCherchee )
{
int iBalayTable = 0;
char bFound = FALSE;
int iIdFound = 0;
int iSizeTotal = 0;
StrConvIdVarName * pConv;
// research in the table list
do
{
pConv = &TableConvIdVarName[ iBalayTable ];
// same type ?
#ifdef IDVAR_IS_TYPE_AND_OFFSET
if ( pConv->iTypeVar==iTypeVarToSearch )
#endif
{
iIdFound = pConv->iIdVar;
iSizeTotal = (pConv->iSize2<=0)?pConv->iSize1:pConv->iSize1*pConv->iSize2;
if ( pConv->iSize3>0 )
iSizeTotal *= pConv->iSize3;
/* Offset value between start and end values ? */
if ( (iIdFound<=iIdVarCherchee) && (iIdVarCherchee<(iIdFound+iSizeTotal)) )
bFound = TRUE;
else
iBalayTable++;
}
#ifdef IDVAR_IS_TYPE_AND_OFFSET
else
{
iBalayTable++;
}
#endif
}
while (!bFound && TableConvIdVarName[ iBalayTable].StringBaseVarName);
if (bFound)
return pConv;
else
return NULL;
}
/* Convert a Type/Id variable into a default base name */
/* return the string character or ??? if not found */
char * CreateVarName( int TypeVarSearched, int OffsetVarSearched )
{
static char tcBuffer[ 100 ];
static char tcBuffer2[ 100 ];
int iIdFound;
StrConvIdVarName * pConv;
// research in the table list
pConv = ConvIdVarEnPtrSurEleConv( TypeVarSearched, OffsetVarSearched );
if (pConv)
{
strcpy(tcBuffer,"%");
iIdFound = pConv->iIdVar;
if (pConv->iSize2<=0 && pConv->iSize3<=0)
{
sprintf(tcBuffer2, pConv->StringBaseVarName, OffsetVarSearched-iIdFound +pConv->iFirstVal1 );
}
else
{
if (pConv->iSize3<=0)
sprintf(tcBuffer2, pConv->StringBaseVarName, (OffsetVarSearched-iIdFound)/pConv->iSize2 +pConv->iFirstVal1,
(OffsetVarSearched-iIdFound)%pConv->iSize2 +pConv->iFirstVal2 );
else
sprintf(tcBuffer2, pConv->StringBaseVarName, (OffsetVarSearched-iIdFound)/(pConv->iSize2*pConv->iSize3) +pConv->iFirstVal1,
((OffsetVarSearched-iIdFound)/pConv->iSize3)%pConv->iSize2 +pConv->iFirstVal2, (OffsetVarSearched-iIdFound)%pConv->iSize3 +pConv->iFirstVal3 );
}
strcat(tcBuffer,tcBuffer2);
if ( InfosGene->DisplaySymbols )
{
// verify if a symbol has been defined for the variable...
char * Symbol = ConvVarNameToSymbol( tcBuffer );
if ( (Symbol!=NULL ) && ((Symbol[0]!=' ') || (Symbol[0]!='\0'))) {return Symbol;}
}
return tcBuffer;
}
else
{
return "???";
}
}
char TestVarIsReadWrite( int TypeVarTested, int OffsetVarTested )
{
StrConvIdVarName * pConv;
// research in the table list
pConv = ConvIdVarEnPtrSurEleConv( TypeVarTested, OffsetVarTested );
if (pConv)
{
return pConv->cReadWriteAccess;
}
return FALSE;
}
|