• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

public variables, scope, local variables, and function calls

Started by Eduardo Jorge, June 11, 2018, 02:58:50 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Eduardo Jorge

Hello

from the tests I did
what is inside SCOPE and BLOCK can modify external public variables that have not been declared internally, as if it were an unnamed SUB
but you can not call internal functions, nor access values of declared variables within them.

while NAMESPACE can modify external variables not declared internally and access values of internal variables using " :: ",

but how do you access internal functions to execute what want ??

Charles Pegge

Hi Eduardo,

Yes, I see we have a problem with :: function names. The only way to access the function is to reopen the namespace. I will fix this.


Chris Chancellor

Welcome Eduardo to the new Oxygen forum, which is truly open and newbie friendly



Eduardo Jorge

#3
Thank you, Chris
let's try to decipher this puzzle that is O2

Thank you,
Charles,
in NAMESPACE an END instead of only NAMESPACE to close would help in the typing of the syntax and would make the use more intuitive because the person would know at once that to close has to use the END before the name of the function

  it looks like I was the only one using this functionality
would not it be better to define a more comfortable use of SCOPE and BLOCK or even NAMESPACE?
so in IDE these procedures could be separated into individual windows.
and may also serve to accommodate many lengthy codes also serving to facilitate programming



Charles Pegge

in contrast to scope or block, namespaces are not nestable.

But end namespace is feasible. I can add this quite easily.

Eduardo Jorge

Charles
I think its intention is to make the use of O2 intuitive, besides polyphoric
so I think have to have some standardization of the syntax
SKIP for example only accepts SKIP {...} and does not accept END SKIP

this disrupts the use of a style of syntax,
and can lead to errors in the code by wrong syntax, use of { } where only accepts END X and the use of the END with functions that only accept the { }

about SCOPE and BLOCK, what would its use be like without being able to call its internal functions?
the only way I see to leverage an independent scope is the use of public control variables and a jump to the beginning of the scope,
of course also for initial execution, but with use of public variables to pass instructions or data to the rest of the code

Charles Pegge

Eduardo,

I will scrap the skip command, since its limited functionality has been superceded by #ifdef..#endif etc.

In most block-constructs, {..} can be used instead of construct .. end construct

The main use of scopes, at the user-level, is in macros which define their own variables, or set their own indexbase. But internally, scopes are used to encapsulate procedures and classes, isolating their symbols from the global namespace.




Eduardo Jorge

Thanks for the feedback, I'm going to remove the skip from my project

um, so scopes are the same as the VBA class modules.
is why I did not set a usage, when I tried to use classes in VBA I found it slow for my type of project, so I did not learn.

I will wait for NAMESPACE, I use public and private variable scope to facilitate the use of variables with the same functionality but different values

Charles Pegge

O2 now updated.

I've also included some examples of object-based arrays in examples\oop\containers

Eduardo Jorge

#9
Thanks, Charles.
I'm going to test by setting the array test I'm doing

I do not know if this behavior is predicted
but I've tried something like this
Array1 (L + ArrayNx_M[N + 5]) * ArrayNx_M[N + 8] + (c + ArrayNx_M[N + 6])
but it gave way to execution

but that way it works
int B = (L + ArrayNx_M [N + 5]) * ArrayNx_M[N + 8] + (c + ArrayNx_M[N + 6])
Array1(B)


one more doubt
How to set the pointer inside a MACRO?
MACRO ARRAYnx(AN, L, C)
            INT N = (AN + * 9)
'   @Arr1 = ArrayNx_M(n)
           int B = (L + ArrayNx_M[N + 5]) * ArrayNx_M[N + 8] + (c + ArrayNx_M[N + 6])
           Arr1(B)
END MACRO


===================================
I noticed here that Macros can not stay inside NAMESPACE to be accessed externally
without "::" they are not recognized, with "::" they do not pass the variables from within NAMESPACE
functions with "::" appear to function normally

well, I'll have to do a lot of testing to understand how this works.

Charles Pegge

Hi Eduardo,

Your code is almost impossible to understand. What is the purpose of these pieces of code?
Perhaps breaking it down into smaller steps will help.

Eduardo Jorge

#11
Wow,  got a feat.

in case
(L + LBoundNx_M(AN +)) * TBoundNx_M(AN + 1) + (c + LBoundNx_M(AN + 1))
it's just a matrix position calculation

  but it is not possible to place inside the matrix, have to insert it into a variable and then place the variable with the calculated value in the matrix

ARRAY(CALCULATE x) '''does not work
but
B = Calculate X
ARRAY(B) '''works

in the case of MACRO
basically this is what i want to do
MACRO ARRAYnx(AN, L, C)
           
       @Array1 = ArrayNx_M(AN)' Array1 is a pointer

   " ARRAYnx = " Array1(position L, C )

END MACRO

Charles Pegge

Sorry, I'm still confused. Does anyone else understand what Eduardo is trying to do?


Eduardo Jorge

Charles,
I noticed that Redim only works to create new arrays using index with variables.
they are not able to change the size of existing arrays?

how can I do to resize public arrays within procedures?