Why run_app() in {golem} starts the shiny app? - shiny

The run_app() function in {golem} returns an object of class shiny.appobj, as far as I understand, since this is what is returned by with_golem_options() with the default parameter print=FALSE, inside run_app(). How does this object get "printed", i.e. the app executed?
I do not see any difference in calling with_golem_options() with print=FALSE or print=TRUE. In both cases, the shiny app starts normally.

Related

Calling Compiled rstan Model to Shiny App

I have a Shiny app that works perfectly fine from my PC, but when I export it to Shinyapps.io, the pre-compiled rstan object (product of stan_model()) throws an error. Specifically the error I get looking back at the log is this:
159: object#mk_cppmodule
Warning: Error in prep_call_sampler: could not find function "prep_call_sampler"
Checking the compiled stan object, there is a function called mk_cppmodule. It has "formals", "body", and "environment" subheadings. It seems that the function prep_call_sampler is defined in "body" and takes the argument "object." It also seems that this "object" argument is supposed to be in the "formals" section; however, its value is listed as "missing" there.
Like I said, the model runs perfectly fine from my PC, and it has been successfully moved over to Shinyapps.io; however, it throws the error anytime the model is called, which makes me think that it's something to do with the server side not accessing the compiled C++. The model needs to be run by sampling() for the app to work. Has anyone had success getting a pre-compiled rstan model object to run on the Shinyapps.io?

Firemonkey: How to iterate through all forms in the application using TScreen.Forms

I am attempting to iterate through the forms I have open in my application. I have found the documentation for FMX.Forms.TScreen.Forms, which looks like it can be used to accomplish my goal. However, I am confused on how I am supposed to use it.
At first I tried this in a function within my form's CPP file:
ShowMessage( Forms::TScreen::FormCount );
This produced the error 'Member TScreen::FormCount cannot be used without an object'
I figured that to mean that I need to attempt to access this property from my form, or from the global Application variable. I tried both
this->Forms...
Application->Forms...
and
this->TScreen...
Application->TScreen...
However, neither Forms nor TScreen exist within either of these objects.
How do I go about accessing Forms.TScreen.Forms?
The error gives you a clue:
Member TScreen::FormCount cannot be used without an object
TScreen is a class, not an object. FormCount is not a static member of the class, so you need an object instance of the TScreen class. And such an object is provided for you - the global Screen object:
ShowMessage( Screen->FormCount );
This is stated in the documentation:
FMX.Forms.TScreen
There is a global variable, Screen, of type TScreen, which is instantiated for use by any application with a GUI. Use Screen to obtain information about the current state of the screen in an application.
FMX.Forms.Screen
extern DELPHI_PACKAGE TScreen* Screen;
Here's what works well:
ShowMessage(Screen->FormCount);
Screen is a global object, like Application. The compiler said that FormCount is not static method or smth.

Add controls in a class other than form class in tizen

I need to have two IconListView in same form. I created a second class for displaying the second listview but while using the AddControl() in the second class it shows an 'undeclared identifier error AddControl'. While the same code works if AddControl() is used in Form class, but my application requires me to use AddControl() in the second class itself. What change should be added to make it usable.
__pIconListView = new IconListView();
result r=__pIconListView->Construct(Rectangle(0,300, 600, 300),Dimension(200,200), ICON_LIST_VIEW_STYLE_NORMAL, ICON_LIST_VIEW_SCROLL_DIRECTION_HORIZONTAL);
__pIconListView->SetItemProvider(*this);
__pIconListView->AddIconListViewItemEventListener(*this);
r=AddControl(__pIconListView);
Made some changes in the code.
And the above code is given in the second class and the AddControl() is in red color meaning its valid. But soon after executing the code, when the execution reaches the AddControl(__pIconListView) the program crashes. The Log says 'Construct should be called before use'. But the above Construct() doesn't make any errors it works fine, I checked the log. So where is this bug comming from!
The GetClientAreaBounds() also hits error.
I found a solution by using AddControl(secondclassObject) in the initial class itself. But with an over head of checking each second whether the required images for the iconlistview has been completely fetched!
But still not found a way to use AddControl() in the second class.

ColdFusion function variable name and CfBuilder

I need to call a function of an object and pass it a variable. Because I need to make multiple call to function of this object I've tried to make one only handler that invoke the specific function by the form value I pass it. The code works, but CFBuilder show me that there is an error (missing semicolon on the last row). I'm on Railo.
local.myReport = seoUtility.init();
local.func = form.action;
local.report = local.myReport[local.func](form.user);
So the question is: this code is correct? I could simply ignore the cfbuilder error icon?
If you don't want CFBuilder to nag you about the syntax, you can change to this:
local.myReport = seoUtility.init();
local.func = local.myReport[form.action];
local.myReport.func = local.func;
local.report = local.myReport.func(form.user);
This sets local.func to the instance of seoUtility as a reference to the actual function you want to call, preserving its relationship to the parent object. This way the offending []() syntax isn't needed.
However, this only works if seoUtility.init() is returning a fresh instance every time, as opposed to a singleton shared by the application, in which case there would be a race condition on all calls to local.myReport.func().

Getting lua error when I'm calling a bound c++ class function twice?

I found this blog post about how to bind c++ classes to lua: http://loadcode.blogspot.com/2007/02/wrapping-c-classes-in-lua.html
But it's not working straight out of the box.
I've tweaked the function to my own and instead of a Sprite class I'm using a NPC class.
I changed the function setSpeed to my own called NpcSetPosition(lua_State *L) which will be called everytime I call the following in lua:
local npc = Npc:New()
npc:SetPosition(5,5)
(the npc:SetPosition function)
Now what's interesting is how I call the checkSprite inside the NpcSetPosition and if I do so once, the lua script will run all fine. But if I do it twice(I call npc:SetPosition(5,5) twice) I get the following error message:
Lua Compile Error: script.lua:10: bad argument #1-1 to: 'SetPosition' (table expected, got userdata)
Which means I can't set the position for the npc twice which is crap.
Do you know what's going wrong?
Does it have to do with the lua stack?
Thanks.
Sounds like you are incorrectly managing your stack.
Are you doing lua_settop( 0 ); or similar in your SetPosition function?
If your managing your stack correctly then this error will disappear.