ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
global.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 GLOBAL
48
49@english
50This keyword sets up a list of variables that can be accessed from absolutely
51anywhere in your program. This is a simplified single command, designed to
52be used without the need for an explicit ''SHARED'' statement in
53procedure definitions.
54
55There is a facility of using strings in procedure definitions.
56As with disc names, the "wild card" characters ''*'' and ''?'' can also
57be included. In this case, the ''*'' character is used to mean "match this
58with any list of characters in the variable name, until the next control
59character is reached", and the ''?'' character means "match this with any
60single character in the variable name". If no parameter is given, a "*"
61is implictly assumed.
62
63''GLOBAL'' or ''SHARED'' should be employed before the first use of the
64variable. Only strings may be used for this technique.
65
66
67@italian
68Questa parola chiave imposta un elenco di variabili a cui è possibile
69accedere da qualsiasi punto del programma. Si tratta di un singolo comando
70semplificato, progettato per essere utilizzato senza la necessità di un'esplicita
71istruzione ''SHARED'' in sede di definizione de procedura. Prima del primo
72utilizzo della variabile è necessario utilizzare ''GLOBAL'' o ''SHARED''.
73
74C'è la possibilità di usare le stringhe nelle definizioni delle procedure.
75Come per i nomi dei file, possono essere inclusi anche i caratteri "jolly"
76''*'' e ''?''. In questo caso, il carattere ''*'' viene utilizzato per
77indicare "corrisponde a un qualsiasi elenco di caratteri nel nome della
78variabile, fino a quando non viene raggiunto il carattere di controllo
79successivo", e il carattere ''?''" significa "abbinalo a qualsiasi
80carattere singolo nel nome della variabile". Solo le stringhe possono
81essere utilizzate con questa tecnica. Se non viene inserito alcun parametro,
82si intende "*".
83
84@syntax GLOBAL [var1[, var2[, ...] ]]
85@syntax GLOBAL "string1"[, "string2"[, ...] ]
86@syntax GLOBAL : REM is like GLOBAL "*"
87
88@example GLOBAL test
89@example GLOBAL "a*", b, "*c"
90
91@usedInExample procedures_global_01.bas
92@usedInExample procedures_global_02.bas
93
94@target all
95</usermanual> */
96void global( Environment * _environment ) {
97
98 if ( _environment->emptyProcedure ) {
99 return;
100 }
101
102 if ( _environment->procedureName ) {
104 }
105
106 if ( _environment->parameters == 0 ) {
107 variable_global( _environment, "*" );
108 } else {
109 int i = 0;
110 for( i=0; i<_environment->parameters; ++i ) {
111 variable_global( _environment, _environment->parametersEach[i] );
112 }
113 }
114
115 _environment->parameters = 0;
116}
void variable_global(Environment *_environment, char *_pattern)
void global(Environment *_environment)
Manage variable as "global".
Definition global.c:96
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_GLOBAL_ONLY_OUTSIDE_PROCEDURES()
Definition ugbc.h:3486
struct _Environment Environment
Structure of compilation environment.