There are two kinds of labeled common blocks:
Common /NAME/ variable ,variable ... Common //variable// variable , variable ...What are the two kinds called? "Static" and "dynamic"?
I have the following in a function of mine:
... ... ... Common_Name=First_Name Common //Common_Name// First_Various_Stuff@ ... ... ... Common_Name=Second_Name Common //Common_Name// Second_Various_Stuff@ ... ... ...What if the values of First_Name and Second_Name should happen to be equal (if I define the same dynamic common block twice)? I don't seem to get any runtime error, but is it safe to do?
I notice that after the second common has been executed that both First_Various_Stuff@ and Second_Various_Stuff@ seem to be the same variable (point to the same content). Is that a correct observation?
- Oystein -
Oystein ..
Essentially, both types of common blocks are identical at run time. It doesn't matter if one is static or dynamic. The place you can get in trouble is parsing the internal contents of a dynamic common block.
If you ever get a system-delimiter (@VM or such) into this variable you can corrupt memory. It is quite possible that two common blocks can contain the same data. This doesn't cause run-time problems since the pointers into string space are different.
Don Miller
C3 Inc.
As long as the number of variables match, you are OK.
Cameron Purdy
Revelation Software
Don, Cameron,
Thanks for your response, both of you!
Don - what's that about @VMs? Do you mean I should avoid doing the following?!?!?:
common /YYY/ A@, B@ A@=xxx" : @VM : "yyy"Don - also I'm not sure I understand what you mean with "two common blocks containing the same data". This is what I'd call two (dynamic) common blocks containing the same data:
Var=XXX" common //Var// A@, B@ common //Var// X@, Y@Here e.g A@ and X@ point to the same data. And that's exactly what I need for my purposes.
(If I inspect this with the debugger, the two equal-named dynamic common blocks at first look like two static common blocks /DC1/ and /DC2/, but if I e.g change the value of A@, I can see that X@ is changed to the same value.)
- Oystein -
Oystein ..
The contents of the Variables within a common block can contain any delimiters you like:
Common /xxx/ var1,var2 where
var1 can contain "ABC":@FM:"DEF" , etc.however if the number of variables in the common block doesn't match between initiator and receptor then you'll get errors. Cam Purdy said the same thing. You are correct in stating that the common blocks can have different internal variable names as long as the number of variables match. Your example is absolutely correct. The only time I have run into trouble is with Dimensioned variables passed in common.
Dynamic arrays seem fine. This bugaboo caused some problems in AREV where variable W was dimensioned on the fly to W_CNT within a common block. Most AREV folks had a variant of AREV.COMMON that didn't do that so that you could use code outside of a window.
Don Miller
C3 Inc.
Don,
Thanks for the clarification! (That Arev W_CNT thing does ring a bell, but it's certainly faint. Seems like a lifetime since I worked with Arev.)
- Oystein -
Ah well, Oystein .. what can I say? I still find tatty old AREV a very efficient tool for doing quick and dirty things; although, most of our new development projects are being done in OI. Even worse, I must confess that I still do Pick as well (but less of it than I used to do). Anyway, dimensioned arrays in common blocks have sometimes given me fits at debug time since this can run you out of string space and memory in a big hurry. A DIM FOO(KNT) - where KNT is 1000 sucks up 1001 variables. That can ruin your whole day.
Don Miller
C3 Inc.
… but not in OI
![]()