ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
shared.c
Go to the documentation of this file.
1/*****************************************************************************
2 * ugBASIC - an isomorphic BASIC language compiler for retrocomputers *
3 *****************************************************************************
4 * Copyright 2021-2026 Marco Spedaletti (asimov@mclink.it)
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *----------------------------------------------------------------------------
18 * Concesso in licenza secondo i termini della Licenza Apache, versione 2.0
19 * (la "Licenza"); è proibito usare questo file se non in conformità alla
20 * Licenza. Una copia della Licenza è disponibile all'indirizzo:
21 *
22 * http://www.apache.org/licenses/LICENSE-2.0
23 *
24 * Se non richiesto dalla legislazione vigente o concordato per iscritto,
25 * il software distribuito nei termini della Licenza è distribuito
26 * "COSÌ COM'È", SENZA GARANZIE O CONDIZIONI DI ALCUN TIPO, esplicite o
27 * implicite. Consultare la Licenza per il testo specifico che regola le
28 * autorizzazioni e le limitazioni previste dalla medesima.
29 ****************************************************************************/
30
31/****************************************************************************
32 * INCLUDE SECTION
33 ****************************************************************************/
34
35#include "../../ugbc.h"
36
37/****************************************************************************
38 * CODE SECTION
39 ****************************************************************************/
40
46/* <usermanual>
47@keyword SHARED
48
49@english
50This keyword sets up a list of variables of a procedure that can be accessed from absolutely
51anywhere in your program.
52
53There is a facility of using strings in procedure definitions.
54As with disc names, the "wild card" characters ''*'' and ''?'' can also
55be included. In this case, the ''*'' character is used to mean "match this
56with any list of characters in the variable name, until the next control
57character is reached", and the ''?'' character means "match this with any
58single character in the variable name".
59
60''GLOBAL'' or ''SHARED'' should be employed before the first use of the
61variable. Only strings may be used for this technique.
62
63@italian
64Questa parola chiave imposta un elenco di variabili della procedura a cui è possibile
65accedere da qualsiasi punto del programma. Prima del primo
66utilizzo della variabile è necessario utilizzare ''GLOBAL'' o ''SHARED''.
67
68C'è la possibilità di usare le stringhe nelle definizioni delle procedure.
69Come per i nomi dei file, possono essere inclusi anche i caratteri "jolly"
70''*'' e ''?''. In questo caso, il carattere ''*'' viene utilizzato per
71indicare "corrisponde a un qualsiasi elenco di caratteri nel nome della
72variabile, fino a quando non viene raggiunto il carattere di controllo
73successivo", e il carattere ''?''" significa "abbinalo a qualsiasi
74carattere singolo nel nome della variabile". Solo le stringhe possono
75essere utilizzate con questa tecnica.
76
77@syntax SHARED var1[, var2[, ...] ]
78@syntax SHARED "string1"[, "string2"[, ...] ]
79
80@example SHARED test
81@example SHARED "a*", b, "*c"
82
83@usedInExample procedures_global_01.bas
84@usedInExample procedures_global_02.bas
85
86@target all
87</usermanual> */
88void shared( Environment * _environment ) {
89
90 if ( _environment->emptyProcedure ) {
91 return;
92 }
93
94 if ( !_environment->procedureName ) {
96 }
97
98 int i = 0;
99 for( i=0; i<_environment->parameters; ++i ) {
100 variable_global( _environment, _environment->parametersEach[i] );
101 }
102 _environment->parameters = 0;
103}
void variable_global(Environment *_environment, char *_pattern)
void shared(Environment *_environment)
Manage variable as "global".
Definition shared.c:88
char * parametersEach[MAX_PARAMETERS]
Definition ugbc.h:2790
int parameters
Definition ugbc.h:2785
char * procedureName
Definition ugbc.h:2775
int emptyProcedure
Definition ugbc.h:2932
#define CRITICAL_SHARED_ONLY_IN_PROCEDURES()
Definition ugbc.h:3485
struct _Environment Environment
Structure of compilation environment.