Author Topic: Is this a thing?  (Read 132 times)

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 1106
    • View Profile
Is this a thing?
« on: January 07, 2022, 07:08:05 AM »
Can anyone explain the following to me?

The BCX Help file contains the following:

Code: [Select]

SHAREDSET processing allows BCX keywords to be recognized, for example,


 SHAREDSET(PTR CC[3])(LPSTR) AS LPSTR
  UCASE$, MCASE$, LCASE$             
 END SET


Examining the BCX translator source, I found [only] those 3 keywords are given special
attention - that is, they are transformed to $$UCASE, $$MCASE, and $$LCASE but I could
not find any other meaningful significance to those transformations.

I suspect a previous maintainer had a reason for this but simply never finished the implementation.

I further suspect that the little bit of code that I did find in the translator on this subject is "dead" and
not doing anything at all except taking up space and wasting time.  But before I remove what I've found,
I thought I should tap your memories for an explanation that I may be overlooking.


iancasey

  • Jr. Member
  • **
  • Posts: 94
    • View Profile
Re: Is this a thing?
« Reply #1 on: January 07, 2022, 11:17:02 AM »
I did find a couple of msgs between Doyle and Wayne on 5 May 2010.
A bug found when compiling BME .
Quote
Just more fallout from the over aggressive translation of previous
versions that has been stop. 6.08 contains fixes for those 3 cases.

It was that bug which seems to have caused the thread to begin with?, so it was there before.

Quote
2010/05/30 16:00 GMT-5   Wayne Halsdorf
* Added LCASE, MCASE and UCASE as to appear in the SET command as function pointers
« Last Edit: January 07, 2022, 11:26:09 AM by iancasey »

Robert

  • Hero Member
  • *****
  • Posts: 805
    • View Profile
Re: Is this a thing?
« Reply #2 on: January 07, 2022, 01:47:37 PM »
Can anyone explain the following to me?

The BCX Help file contains the following:

Code: [Select]

SHAREDSET processing allows BCX keywords to be recognized, for example,


 SHAREDSET(PTR CC[3])(LPSTR) AS LPSTR
  UCASE$, MCASE$, LCASE$             
 END SET


Examining the BCX translator source, I found [only] those 3 keywords are given special
attention - that is, they are transformed to $$UCASE, $$MCASE, and $$LCASE but I could
not find any other meaningful significance to those transformations.

I suspect a previous maintainer had a reason for this but simply never finished the implementation.

I further suspect that the little bit of code that I did find in the translator on this subject is "dead" and
not doing anything at all except taking up space and wasting time.  But before I remove what I've found,
I thought I should tap your memories for an explanation that I may be overlooking.

Hi MrBCX:

Wayne Halsdorf
3.63a
Added SHAREDSET generates code just like SET but without static. Allows data to
be shared across multiple files.

Mike Henning added the SHAREDSET example to the Help file about BCX 506.193. I think Mike expected me to flesh it out but it was added verbatim. I can not find record of the delivery of the example code, only the reference to the addition to the Help file.

As is, the SHAREDSET example in the Help file is dysfunctional.

Robert

  • Hero Member
  • *****
  • Posts: 805
    • View Profile
Re: Is this a thing?
« Reply #3 on: January 07, 2022, 02:07:16 PM »
> Kevin Diggins wrote:
&gt; &gt; --- In <a href="http://tech.groups.yahoo.com/group/BCX/post?postID=MftSsZmCDph79TKRV6_SJgmsPYPXa3oTGAFzr30b9bsxuw_I1LMk0bCcjx6bo2Er0x8c6seWtQwZRz_D3UE">BCX@yahoogroups.com</a>, "mikehg_67" &lt;mikehg_67@&gt; wrote:
&gt; &gt;
&gt; &gt;&gt;SET (PTR OnClick[])(void) AS void
&gt; &gt;&gt;   OnClick1, OnClick2, OnClick3
&gt; &gt;&gt;END SET
&gt; &gt;&gt;
&gt; &gt;
&gt; &gt;
&gt; &gt;
&gt; &gt; Slick!
&gt; &gt;
&gt; &gt; That's an inventive use of the SET command Mike.
&gt;
&gt; I'll say. Now, can someone who understands this explain it to a
&gt; simple minded guy like me? Slooowly! :-)
&gt;
&gt;
&gt; --
&gt; Doyle Whisenant
&gt; <a href="http://www.freewebs.com/mekdesign/">http://www.freewebs.com/mekdesign/</a>
&gt; "mechanic" at "sonet" dot "net"
&gt;


Hi Doyle,

I suppose it does look a little cryptic :=)

Keep in mind a function name is just a pointer itself.
So we are just creating an array of pointers and assigning the
function addresses to the array.

Let's break things down a little:

SET (PTR OnClick[])(void) AS void

(PTR OnClick[])  &lt;-- This declares an array of pointers
Parenthesis are important here - they tell the compiler that this is a
function declaration.
(void)           &lt;-- The argument types to the function(s).
AS void          &lt;-- The last is the return type of the function(s).

Note that the argument and return types are for informational purposes
to the compiler to allow proper type checking.
With this in mind, all of the functions should have the same number of
arguments and types.

In the end we basically end up with the equivalent of:
DIM OnClick[3] AS VOID PTR


Here is one I use in my copy of BCB:

SET (PTR CC[3])(LPSTR) AS LPSTR
    UCASE$, MCASE$, LCASE$
END SET

Usage:
Newstring$ = CC$[CCASE](OldString$)


Are you really confused now ?
If not, let me know and I'll try again :0)

Mike H

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 1106
    • View Profile
Re: Is this a thing?
« Reply #4 on: January 07, 2022, 02:31:43 PM »
Thanks guys ...

With testing, I've concluded that the corner cases of $$mcase, $$lcase, and $$ucase need to remain as is.


Robert

  • Hero Member
  • *****
  • Posts: 805
    • View Profile
Re: Is this a thing?
« Reply #5 on: January 07, 2022, 03:31:32 PM »
Here's the fixed example

Code: [Select]

DIM OldString$, Newstring$

SHAREDSET (PTR CC[3])(LPSTR) AS LPSTR
 UCASE$, MCASE$, LCASE$
END SET

OldString$ = "hello we're old"

Newstring$ = CC$[0](OldString$)

? Newstring$

Newstring$ = CC$[1](OldString$)

? Newstring$

Newstring$ = CC$[2](OldString$)

? Newstring$


Robert

  • Hero Member
  • *****
  • Posts: 805
    • View Profile
Re: Is this a thing?
« Reply #6 on: January 07, 2022, 03:42:27 PM »
Using the new example, here's the only difference between SET and SHAREDSET

SET
Code: [Select]
static LPSTR (*CC[3])(LPSTR)=
  {
 ucase,mcase,lcase
};

SHAREDSET
Code: [Select]
LPSTR (*CC[3])(LPSTR)=
  {
 ucase,mcase,lcase
};

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 1106
    • View Profile
Re: Is this a thing?
« Reply #7 on: January 07, 2022, 09:18:44 PM »
Using the new example, here's the only difference between SET and SHAREDSET

SET
Code: [Select]
static LPSTR (*CC[3])(LPSTR)=
  {
 ucase,mcase,lcase
};

SHAREDSET
Code: [Select]
LPSTR (*CC[3])(LPSTR)=
  {
 ucase,mcase,lcase
};

Robert -- my original question was not about SET/SHAREDSET per se but rather why
only  $$UCASE, $$MCASE, and $$LCASE receive special treatment while a boatload
of other BCX functions did not.  As Ian suggested, it was not to benefit BCX but
rather to benefit Doyle's editor (BME) from that era. 

However, when I commented out the special case code transforms for those three
functions ($$UCASE, $$MCASE, and $$LCASE), I discovered BCX barfed on the
translating itself correctly, so I concluded to it best to leave things alone for now.

Robert

  • Hero Member
  • *****
  • Posts: 805
    • View Profile
Re: Is this a thing?
« Reply #8 on: January 07, 2022, 09:50:22 PM »
Using the new example, here's the only difference between SET and SHAREDSET

SET
Code: [Select]
static LPSTR (*CC[3])(LPSTR)=
  {
 ucase,mcase,lcase
};

SHAREDSET
Code: [Select]
LPSTR (*CC[3])(LPSTR)=
  {
 ucase,mcase,lcase
};

Robert -- my original question was not about SET/SHAREDSET per se but rather why
only  $$UCASE, $$MCASE, and $$LCASE receive special treatment while a boatload
of other BCX functions did not.  As Ian suggested, it was not to benefit BCX but
rather to benefit Doyle's editor (BME) from that era. 

However, when I commented out the special case code transforms for those three
functions ($$UCASE, $$MCASE, and $$LCASE), I discovered BCX barfed on the
translating itself correctly, so I concluded to it best to leave things alone for now.

Hi MrBCX:

Understood. Your original post was very clear in outlining your concerns. In fact in some of my snooping the $$ ended up in the C translations when early BCX 5 era was used.

I was just expressing the realization that the SHAREDSET example was not only not working but that the SHAREDSET section was misplaced. All has been corrected and the revised documentation will be released when 7.8.0 hits the shelves.

Lacking the intelligence to leave "well enough alone" and risking being labelled a trouble-maker, a good example of why SHAREDSET exists would be useful. Obviously, I still don't get it.

Wayne Halsdorf

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Is this a thing?
« Reply #9 on: January 08, 2022, 10:11:04 AM »
The difference comes into play when you have multiple files being compiled to object files and then linking them together. Shareset x allows all the object files to see the set x, while set y can only be seen in the object that has the set y in it.

Robert

  • Hero Member
  • *****
  • Posts: 805
    • View Profile
Re: Is this a thing?
« Reply #10 on: January 08, 2022, 02:29:34 PM »
The difference comes into play when you have multiple files being compiled to object files and then linking them together. Shareset x allows all the object files to see the set x, while set y can only be seen in the object that has the set y in it.

Thank you Wayne.