• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

the component function with visibility problem persists

New Here ,
Sep 19, 2021 Sep 19, 2021

Copy link to clipboard

Copied

It has looked like the problem was solved at CF 2021. After the 2nd. update, the same problem come back!

 

I've created a simple component containing a private and a public function.

 

component{
    private numeric function f_private(){
        return 12345;
    }

    public struct function f_public(){
        local['s_test']={
            'v_test':f_private()+9876
        };
        return local['s_test'];
    }
}

 

Then a simple page that calls the component itself...

 

<cfprocessingdirective pageEncoding="utf-8">
<cfscript>
    variables['c_test']=createObject('component','path.to.cfcFile');
    variables['s_test']=variables['c_test']['f_public']();
    writeDump(var=variables);
</cfscript>

 

Testing the cfc calling, it generates an error:

Variable F_PRIVATE is undefined.
 
 
The error occurred in C:/Websites/test.lab/wwwroot/path/to/_cfcFile.cfc: line 8
6 : 	public struct function f_public(){
7 : 		local['s_test']={
8 : 			'v_test':f_private()+9876
9 : 		};
10 : 		return local['s_test'];

Views

183

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 20, 2021 Sep 20, 2021

I don't think the problem is with the component. I think the problem is this line:

     variables['s_test']=variables['c_test']['f_public']();

 

The right-hand-side is not quite correct. It does not invoke the function properly. The way it now reads, the function is variables.c_test.f_public, which is not entirely correct.

 

Correct is:

   variables['s_test']=variables['c_test'].f_public();

 

Votes

Translate

Translate
New Here ,
Sep 19, 2021 Sep 19, 2021

Copy link to clipboard

Copied

correcting...

 

"...the same problem comes back!"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 20, 2021 Sep 20, 2021

Copy link to clipboard

Copied

I don't think the problem is with the component. I think the problem is this line:

     variables['s_test']=variables['c_test']['f_public']();

 

The right-hand-side is not quite correct. It does not invoke the function properly. The way it now reads, the function is variables.c_test.f_public, which is not entirely correct.

 

Correct is:

   variables['s_test']=variables['c_test'].f_public();

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 22, 2021 Sep 22, 2021

Copy link to clipboard

Copied

Greatful! Now it's working perfectly! Although I'm asking: why the platform found the function (as a variable) but not the embedded function?

Continuing to my analysis, JavaScript is years beyond CFscript when I mention "variable callings by bracket notations". Unfortunately... And I use bracket notations to force case sensitivity when I need to track other bug issues.

 

Thanks for your return and best regards!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 23, 2021 Sep 23, 2021

Copy link to clipboard

Copied

quote

Although I'm asking: why the platform found the function (as a variable) but not the embedded function?


By @I.am.Sceiffer

Who knows all the fuzzy logic that goes on in the mind of a weakly-typed language! 😉

Your guess is as good as mine.

 

Best regards

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 23, 2021 Sep 23, 2021

Copy link to clipboard

Copied

And you don't have to just put up with things. First, since you seem to imply that the code worked for you with update 1 and failed with update 2, you could and should file a bug report (at tracker.adobe.com). Perhaps the change was not expected.

 

Or if I am misunderstanding, and it also did NOT work with update 1, then you could file a feature request at the same tracker.adobe.com site.

 

In either case, it would be best to create a simple standalone test case, that has no reliance on any objects, etc.

 


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 24, 2021 Sep 24, 2021

Copy link to clipboard

Copied

First of all Mr. Arehart, the problem itself was not the instead function calling (f_private). The problem itself was using bracket notation to invoke a function. As we can note, the CF Script has a sentence problem when we use bracket notation. Similar as "for( in )" sentence that I exposed in this community some months ago. Honestly, it could be solved until first release of ColdFusion 2021. The real problem is promissing a language similar as JavaScript to ease the CFML learning and development, but it could not be perfectly as we expect. Thus, NodeJS is getting more popular than ColdFusion and its propose is almost similar! What are we doing wrong? How can we argh our customers to convince them using ColdFusion instead of .NET, PHP or NodeJS?

You can not note that because US$9.5K is really 9 thousand and half dollars. For Brazil, a ColdFusion server costs more than a basic car. In this way, it won't be an investment!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 24, 2021 Sep 24, 2021

Copy link to clipboard

Copied

I agree with you that CFSCRIPT is at best "kind of" like JavaScript. There's no complete formal documentation for the language itself as far as I know, and it was originally included in CF as a sop to people who don't like CFML. My own personal feeling about using CFSCRIPT is that if it works for me, that's great, but my expectations are a lot lower.

 

But I think you're being a bit unfair to @Charlie Arehart here, because your question just changed from "Why isn't CFSCRIPT working?" to "How can I justify buying ColdFusion?" I dunno, that's kind of a loaded question to me. There's no stopping you or anyone from using another product, if you decide that's a better deal for you. Personally, I find that I'm not as productive with PHP or ASP.NET for a variety of reasons. Maybe those reasons won't apply for you.

 

Dave Watts, Eidolon LLC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 24, 2021 Sep 24, 2021

Copy link to clipboard

Copied

LATEST

Thanks for that, Dave. Besides the reply I just offered to him, I say that about your observation of the thread title chs going, I'm not seeing it to be so--but perhaps he has already changed it back.

 

But yeah, I didn't see how my reply led to his observations. I was simply proposing that he bring it to Adobe to fix. Perhaps something was lost in translation. 


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 24, 2021 Sep 24, 2021

Copy link to clipboard

Copied

quote
You can not note that because US$9.5K is really 9 thousand and half dollars. For Brazil, a ColdFusion server costs more than a basic car. 

By @I.am.Sceiffer

 

Great example there, Brazil being one of the emerging economies. 

Certainly food for thought for the Adobe team.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 24, 2021 Sep 24, 2021

Copy link to clipboard

Copied

@I.am.Sceiffer, I think you've misunderstood the intention in my reply. I was simply pointing out that since you feel your problem worked BEFORE Cf2021, then you should file a bug report. That's how Adobe would know some that worked now is broken. 

 

The rest of what you said in reply to me suggests you didn't understand why I said this. I'll leave you and others to debate/consider the rest of your points.

 

As always, I was just trying to help. 


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation