Script properties becomes corrupt: Failed to save Project Properties for script - google-apps-script

Script properties becomes "corrupt" after a call to "PropertiesService.getScriptProperties().setProperties(properties)" in my script. By "corrupt", I mean I can no longer add or edit existing properties in: "File -> Project properties -> Script properties", and when I first try I receive the error message "Failed to save Project Properties for script." I've tried deleting all properties and re-adding them, I tried deleting all browser cache, and I tried minimizing my Properties calls to ensure(?) I'm not exceeding quotas.
After this error, going to "File -> Project properties" results in in a endlessly spinning busy cursor while it tries to load the "Info" tab. Re-loading the spreadsheet allows "File -> Project properties" to properly load, but any edits made to properties in the "Script properties" tab brings back the error and spinning cursor problem.
I've narrowed down the culprit in my script but I cannot figure out why it's causing this problem. In my "onOpen()" method I am building up ~125 properties, and then I set them with one call to "setProperties()". The properties go into Script Properties okay, and they function as expected, but this programmatic setting of script properties is definitely the cause of the "Failed to save Project Properties for script." error message.
Link to a copy of my Google spreadsheet containing the script causing the problem. The 3 calls causing the problem are commented with "SETPROPS", and the call to set the properties is commented with "BROKE!". This problem, or ones similar, have come up in the past but seem to be "fixed" or no longer occur.
The code sequence is as follows:
I clear all script properties with: PropertiesService.getScriptProperties().deleteAllProperties()
I call three methods, each taking a "properties" argument.
Each of these 3 methods does nearly the same thing. They each add key/value pairs to "properties".
After each of the 3 methods is called, I set the properties with:
if (Object.getOwnPropertyNames(properties).length !== 0)
{
PropertiesService.getScriptProperties().setProperties(properties);
}
Here is one of the 3 methods that adds to the "properties" var (initialize with: var properties = {};). The other 3 methods add to the properties variable in the same manner, but operate on different data.
function setScriptPropertiesShipSizesForFaction(properties, factionName)
{
var dataSheetName = factionName + "Data";
var dataSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(dataSheetName);
var shipValues = dataSheet.getRange('B3:D200').getValues();
var index = 0;
while ( (index < shipValues.length) && (shipValues[index][0] != "") )
{
var key = '_shipSize_' + normalize(shipValues[index][0]);
var value = shipValues[index][2];
properties[key] = value;
index++;
}
}
I believe I am not exceeded any Google script quota. I do not get any error messages from the call to "setProperties", and I do not see any errors in Google's Stackdriving Logging. At the bottom of this post I have a list of what I am setting in ScriptProperties. It's logging output, with syntax: key=value.
_shipSize_ArquitensCC=S
_shipSize_ArquitensLC=S
_shipSize_AssaultFrigateMk2A=M
_shipSize_AssaultFrigateMk2B=M
_shipSize_CR90-A=S
_shipSize_CR90-B=S
_shipSize_GR-75CombatRetrofits=S
_shipSize_GR-75MediumTransports=S
_shipSize_Gladiator1=S
_shipSize_Gladiator2=S
_shipSize_GozantiAssault=S
_shipSize_GozantiCruisers=S
_shipSize_HammerheadScout=S
_shipSize_HammerheadTorpedo=S
_shipSize_ISD1=L
_shipSize_ISD2=L
_shipSize_ISDCymoon=L
_shipSize_ISDKuat=L
_shipSize_InterdictorCombat=M
_shipSize_InterdictorSuppression=M
_shipSize_MC30cScout=S
_shipSize_MC30cTorpedo=S
_shipSize_MC75ArmoredCruiser=L
_shipSize_MC75OrdnanceCruiser=L
_shipSize_MC80AssaultCruiser=L
_shipSize_MC80BattleCruiser=L
_shipSize_MC80CommandCruiser=L
_shipSize_MC80StarCruiser=L
_shipSize_Nebulon-BEscort=S
_shipSize_Nebulon-BSupport=S
_shipSize_PeltaAssault=S
_shipSize_PeltaCommand=S
_shipSize_QuasarFire1=M
_shipSize_QuasarFire2=M
_shipSize_Raider1=S
_shipSize_Raider2=S
_shipSize_Victory1=M
_shipSize_Victory2=M
_upgradeKeyPrefix_EmpireDEFENSIVE 2=6.0
_upgradeKeyPrefix_EmpireDEFENSIVE=5.0
_upgradeKeyPrefix_EmpireEXPERIMENTAL 2=8.0
_upgradeKeyPrefix_EmpireEXPERIMENTAL=7.0
_upgradeKeyPrefix_EmpireFLEET COMMAND=9.0
_upgradeKeyPrefix_EmpireFLEET SUPPORT=10.0
_upgradeKeyPrefix_EmpireION CANNONS=11.0
_upgradeKeyPrefix_EmpireOFFENSIVE 2=13.0
_upgradeKeyPrefix_EmpireOFFENSIVE=12.0
_upgradeKeyPrefix_EmpireOFFICER=4.0
_upgradeKeyPrefix_EmpireORDNANCE=14.0
_upgradeKeyPrefix_EmpireSUPPORT TEAM=15.0
_upgradeKeyPrefix_EmpireTITLE=3.0
_upgradeKeyPrefix_EmpireTURBOLASER 2=17.0
_upgradeKeyPrefix_EmpireTURBOLASER=16.0
_upgradeKeyPrefix_EmpireWEAPONS TEAM 2=19.0
_upgradeKeyPrefix_EmpireWEAPONS TEAM=18.0
_upgradeKeyPrefix_RebelDEFENSIVE 2=7.0
_upgradeKeyPrefix_RebelDEFENSIVE=6.0
_upgradeKeyPrefix_RebelFLEET COMMAND=8.0
_upgradeKeyPrefix_RebelFLEET SUPPORT=9.0
_upgradeKeyPrefix_RebelION CANNONS=10.0
_upgradeKeyPrefix_RebelOFFENSIVE=11.0
_upgradeKeyPrefix_RebelOFFICER 2=5.0
_upgradeKeyPrefix_RebelOFFICER=4.0
_upgradeKeyPrefix_RebelORDNANCE 2=13.0
_upgradeKeyPrefix_RebelORDNANCE=12.0
_upgradeKeyPrefix_RebelSUPPORT TEAM=14.0
_upgradeKeyPrefix_RebelTITLE=3.0
_upgradeKeyPrefix_RebelTURBOLASER 2=16.0
_upgradeKeyPrefix_RebelTURBOLASER=15.0
_upgradeKeyPrefix_RebelWEAPONS TEAM=17.0
_upgradeSize_BailOrgana=ML
_upgradeSize_DisposableCapacitors=SM
_upgradeSize_GovernorPryce=ML
_upgradeSize_HardenedBulkheads=L
_upgradeSize_StrategicAdviser=L calculatedDataSheetName=Calculated Data cellCommander=E2 colEmpirePlayerNames=1 colRebelPlayerNames=8
colShipNames=2 colSquadNames=2 colUpgradesStart=3
colVariableUpgradesEndEmpire=19 colVariableUpgradesEndRebel=17
colVariableUpgradesStartEmpire=5 colVariableUpgradesStartRebel=6
disabledBgColor=#999999 enabledBgColor=#93c47d
factionNameEmpire=Empire factionNameRebel=Rebel
indexFleetSheetsStart=3
multipleIconUpgrade_BoardingEngineers=OFFENSIVE,WEAPONS TEAM
multipleIconUpgrade_BoardingTroopers=OFFENSIVE,WEAPONS TEAM
multipleIconUpgrade_ChamSyndulla=OFFENSIVE,WEAPONS TEAM
multipleIconUpgrade_DarthVader=OFFENSIVE,WEAPONS TEAM
multipleIconUpgrade_JynErso=OFFENSIVE,WEAPONS TEAM playersPerTeam=3
rowPlayerNamesStart=7 rowShipsEnd=17 rowShipsStart=6
rowSquadNamesEnd=44 rowSquadNamesStart=21 rowUpgradeNames=5
sheetNameSystemTracking=Systems Tracking sheetNameTeamStatus=Team
Status upgradeKeyPrefix=_upgradeKeyPrefix_
upgradeKeyPrefixEmpireDEFENSIVE 2=6.0
upgradeKeyPrefixEmpireDEFENSIVE=5.0
upgradeKeyPrefixEmpireEXPERIMENTAL 2=8.0
upgradeKeyPrefixEmpireEXPERIMENTAL=7.0 upgradeKeyPrefixEmpireFLEET
COMMAND=9.0 upgradeKeyPrefixEmpireFLEET SUPPORT=10.0
upgradeKeyPrefixEmpireION CANNONS=11.0
upgradeKeyPrefixEmpireOFFENSIVE 2=13.0
upgradeKeyPrefixEmpireOFFENSIVE=12.0
upgradeKeyPrefixEmpireOFFICER=4.0 upgradeKeyPrefixEmpireORDNANCE=14.0
upgradeKeyPrefixEmpireSUPPORT TEAM=15.0
upgradeKeyPrefixEmpireTITLE=3.0 upgradeKeyPrefixEmpireTURBOLASER
2=17.0 upgradeKeyPrefixEmpireTURBOLASER=16.0
upgradeKeyPrefixEmpireWEAPONS TEAM 2=19.0
upgradeKeyPrefixEmpireWEAPONS TEAM=18.0
upgradeKeyPrefixRebelDEFENSIVE 2=7.0
upgradeKeyPrefixRebelDEFENSIVE=6.0 upgradeKeyPrefixRebelFLEET
COMMAND=8.0 upgradeKeyPrefixRebelFLEET SUPPORT=9.0
upgradeKeyPrefixRebelION CANNONS=10.0
upgradeKeyPrefixRebelOFFENSIVE=11.0 upgradeKeyPrefixRebelOFFICER
2=5.0 upgradeKeyPrefixRebelOFFICER=4.0 upgradeKeyPrefixRebelORDNANCE
2=13.0 upgradeKeyPrefixRebelORDNANCE=12.0
upgradeKeyPrefixRebelSUPPORT TEAM=14.0 upgradeKeyPrefixRebelTITLE=3.0
upgradeKeyPrefixRebelTURBOLASER 2=16.0
upgradeKeyPrefixRebelTURBOLASER=15.0 upgradeKeyPrefixRebelWEAPONS
TEAM=17.0 upgradeRegex_DEFENSIVE 2=MC80\s+Assault
upgradeRegex_DEFENSIVE=Arquitens|ISD\s+(2|Kuat)|Assault\s+Frigate|CR90|MC30|MC75|MC80\s+(Assault|Command)
upgradeRegex_EXPERIMENTAL 2=Suppression
upgradeRegex_EXPERIMENTAL=Interdictor upgradeRegex_FLEET
COMMAND=Pelta|ISD\s+Cymoon upgradeRegex_FLEET SUPPORT=Gozanti|GR\-75
upgradeRegex_ION
CANNONS=CR90\-B|ISD\s+(2|Kuat|1)|Interdictor|MC75\s+Armored|MC80|Raider\s+2|Victory\s+2
upgradeRegex_OFFENSIVE 2=ISD\s+1|Quasar\s+Fire\s+1
upgradeRegex_OFFENSIVE=Gozanti|ISD|Interdictor|Quasar|Raider|Victory|Assault\s+Frigate|GR\-75|Hammerhead|MC75|MC80\s+Command|Pelta\s+Command
upgradeRegex_ORDNANCE 2=MC75\s+Ordnance
upgradeRegex_ORDNANCE=Hammerhead\s+Torpedo|Gladiator|ISD\s+Kuat|MC30|MC75|Raider\s+1|Victory\s+1|Pelta\s+Assault
upgradeRegex_SUPPORT
TEAM=Arquitens\s+CC|CR90|Gladiator|Interdictor|MC80|Pelta|Nebulon
upgradeRegex_TURBOLASER 2=ISD\s+Cymoon|MC80\s+(Star|Battle)
upgradeRegex_TURBOLASER=Arquitens|Assault\s+Frigate|CR90\-A|Hammerhead\s+Scout|ISD\s+(2|Cymoon|1)|MC30|MC75\s+Armored|MC80|Nebulon|Victory
upgradeRegex_WEAPONS TEAM 2=Quasar\s+Fire\s+2 upgradeRegex_WEAPONS
TEAM=Assault\s+Frigate|Hammerhead|Gladiator|ISD|MC30|MC75|MC80\s+(Battle|Star)|Quasar|Raider|Victory

For what it's worth, I'm experiencing much the same problem too. There's an older version of this Google Apps Script running and it's got around the same number of Properties. Going via the GAS interface I can't delete any of the properties. I've only just come across this problem so I haven't yet delved into a solution. The property I'm storing is a token for each user for a Service Account to utilise, so I'm hoping a programmatic purge of the tokens every x days will suffice. I'll post updates here.

In my case i couldn't save any file because an old linked library was deleted.

Related

Equivalent of Platform::IBoxArray in C++/WinRT

I am currently porting an UWP application from C++/CX to C++/WinRT. I encountered a safe_cast<Platform::IBoxArray<byte>^>(data) where data is of type Windows::Foundation::IInspectable ^.
I know that the safe_cast is represented by the as<T> method, and I know there are functions for boxing (winrt::box_value) and unboxing (winrt::unbox_value) in WinRT/C++.
However, I need to know the equivalent of Platform::IBoxArray in order to perform the cast (QueryInterface). According to https://learn.microsoft.com/de-de/cpp/cppcx/platform-iboxarray-interface?view=vs-2017, IBoxArray is the C++/CX equivalent of Windows::Foundation::IReferenceArray, but there is no winrt::Windows::Foundation::IReferenceArray...
Update for nackground: What I am trying to achieve is retrieving the view transform attached by the HoloLens to every Media Foundation sample from its camera. My code is based on https://github.com/Microsoft/HoloLensForCV, and I got really everything working except for this last step. The problem is located around this piece of code:
static const GUID MF_EXTENSION_VIEW_TRANSFORM = {
0x4e251fa4, 0x830f, 0x4770, 0x85, 0x9a, 0x4b, 0x8d, 0x99, 0xaa, 0x80, 0x9b
};
// ...
// In the event handler, which receives const winrt::Windows::Media::Capture::Frames::MediaFrameReader& sender:
auto frame = sender.TryAcquireLatestFrame();
// ...
if (frame.Properties().HasKey(MF_EXTENSION_VIEW_TRANSFORM)) {
auto /* IInspectable */ userData = frame.Properties().Lookup(MF_EXTENSION_VIEW_TRANSFORM);
// Now I would have to do the following:
// auto userBytes = safe_cast<Platform::IBoxArray<Byte> ^>(userData)->Value;
//viewTransform = *reinterpret_cast<float4x4 *>(userBytes.Data);
}
I'm also working on porting some code from HoloLensForCV to C++/WinRT. I came up with the following solution for a very similar case (but not the exact same line of code you ask about):
auto user_data = source.Info().Properties().Lookup(c_MF_MT_USER_DATA); // type documented as 'array of bytes'
auto source_name = user_data.as<Windows::Foundation::IReferenceArray<std::uint8_t>>(); // Trial and error to get the right specialization of IReferenceArray
winrt::com_array<std::uint8_t> arr;
source_name.GetUInt8Array(arr);
winrt::hstring source_name_str{ reinterpret_cast<wchar_t*>(arr.data()) };
Specifically, you can replace the safe_cast with .as<Windows::Foundation::IReferenceArray<std::uint8_t> for a boxed array of bytes. Then, I suspect doing the same cast as me (except to float4x4* instead of wchar_t*) will work for you.
The /ZW flag is not required for my example above.
I can't believe that actually worked, but using information from https://learn.microsoft.com/de-de/windows/uwp/cpp-and-winrt-apis/interop-winrt-cx, I came up with the following solution:
Enable "Consume Windows Runtime Extension" via /ZW and use the following conversion:
auto abi = reinterpret_cast<Platform::Object ^>(winrt::get_abi(userData));
auto userBytes = safe_cast<Platform::IBoxArray<byte> ^>(abi)->Value;
viewTransform = *reinterpret_cast<float4x4 *>(userBytes->Data);
Unfortunately, the solution has the drawback of generating
warning C4447: 'main' signature found without threading model. Consider using 'int main(Platform::Array^ args)'.
But for now, I can live with it ...

How to wait, then do something, in the GameScene

SKAction has waiting for duration abilities, for a period of time on a node. And seems to perform actions on nodes. Like moveTo, etc.
If I don't want that, rather I'd prefer to call functions within GameScene after a period of time, how do I do that with SpriteKit in the GameScene, not on a Sprite or other Node?
Are SKActions the way to do this? The only way to do this?
Yes. This question IS that ridiculously simple. I lack the heuristics and terminology to find an answer. Just keep looping around on how SKAction waits are calls on SKSprites for things like scale, rotation, etc, after time. Which isn't want I want/need.
Update:
Desired outcome, inside GameScene
doSetupStuff() // does some stuff...
waitForAWhile() // somehow wait, perhaps do somethings in here, while waiting
doSomethingElse() // does this after the waitForAWhile has waited
UPDATE 2:
What I think happens, again, inside didMove(to view...)
func wait(){
let timeToPause = SKAction.wait(forDuration: 3)
run(timeToPause)
}
let wontwait = SKAction.wait(forDuration: 3)
run(wontwait)
thisFunction(willnot: WAIT"it starts immediately")
wait()
thisFunction(forcedToWait: "for wait()'s nested action to complete")
UPDATE 3:
Found a way to get the delay without using SKActions. It's a little crude and brutal, but makes more sense to me than SKActions, so far:
DispatchQueue.main.asyncAfter(deadline: .now() + 10.0) {
print("I waited ten seconds before printing this!")
}
An option, as you cited, is to manage this externally. The way I typically manage this sort of thing is to have an externally run update cycle. One that
To drive this updater, you could use either CADisplayLink (which is what I use right now with my OpenGL renderer) or a dispatch source timer (which I have used with my SpriteKit engine). When you use an updated, you want to calculate the delta time. The tick handler could look something like:
func tickHandler() {
let currTime = NSDate().timeIntervalSince1970
let dt = lastTime - currTime // lastTime is a data member of the class
// Call all updaters here, pretend "updater" is a known updater class
updater.update(dt)
}
And updater's update method would look something like:
func update(deltaTime:NSTimeInterval) {
// Do your magic
}
I typically have a main overall updater running independent of what people are calling scenes. Example usage would be something like having an attract mode like in old school arcade games. There they show title screen, sample game play, high scores, rinse and repeat. Scenes would be title, game play, high score. Here you can your main updater manage the time and coordinate the construction/destruction/switching of the scenes. Note this implies having an overall scene manager (which is actually quite handy to have).
For your case, you could use this updater to drive the GameScene updater. It's updater could look something like:
func update(deltaTime:NSTimeInterval) {
switch state {
case .SetupState:
// noop?
println("I'm in setup") // Shown just so you can see there is a setup state
case .WaitState:
waitTime += deltaTime
if waitTime >= kWaitTime {
// Do whats you gots to do
doSomethingElse()
state = .NextState
}
case .NextState:
// blah blah blah blah
}
}
So the flow to do this call path from your driver (CADisplayLink or dispatch source) would be something like:
tickHandler -> master updater -> game scene updater
Some will def find this is perhaps a little heavy handed. I, on the other hand, find this very helpful. While there is obviously some time management and the loss of being able to fire and forget, it can help provide more control for orchestrating pieces, as well as arbitrarily changing state without having to worry about killing already queued actions. There is also nothing that says you still cannot mix SKAction. When I did use SpriteKit, I did all my updating this way along with some dispatched items. I only used SKAction to update hierarchy. Keep in mind that I used my own animation and physics system. So at least for me I had a lot less dependency on SpriteKit (it effectively was just a renderer for me).
Note you have to have your own means to handle pause and coming to foreground where your timer will need to be resynced (you only need to worry about tickHandler). Breakpoints also will cause time jumps.
You can use below function
#define ANIM_TIME 2
SKAction *customACtion = [SKAction customActionWithDuration: ANIM_TIME actionBlock:^(SKNode *node, CGFloat elapsedTime) {
// Do Something Here
}];
Another way to make something happen after a certain period of time is to make use of the 'current time' parm passed to update(). The following code will spawn a boss at intervals ranging from 20 to 30 seconds.
In your property definitions:
var timeOfLastBoss: CFTimeInterval = -1 //Indicate no boss yet
var timePerBoss = CFTimeInterval()
.
.
.
didMoveToView() {
...
timePerBoss = CFTimeInterval(Int.random(20...30))
'''
}
.
.
.
func update(currentTime: CFTimeInterval) {
...
spawnBossForUpdate(currentTime)
...
}
'
'
'
func spawnBossForUpdate(currentTime : CFTimeInterval) {
if ( timeOfLastBoss == -1 ) {timeOfLastBoss = currentTime}
if (currentTime - timeOfLastBoss < timePerBoss) {return}
// Rest of 'spawnBoss code
self.timePerBoss = CFTimeInterval(Int.random(20...30))
self.timeOfLastBoss = currentTime
}
One way, using SKActions, in Swift 3.0, looks like this:
DEFINE: aPatientlyWaitingFunction() at the top level of
GameScene class.
To cause a delay to happen before calling the above function, inside
didMove(to view...)
three ways I've found to do this using Actions:
All three ways seem to accomplish the exact same thing:
let timeToWait: TimeInterval = 3 // is seconds in SKAction thinking time
let waitSomeTime = SKAction.wait(forDuration: timeToWait)
// 1st way __________________________________________
// with a completion handler, the function can be called after Action
run(waitSomeTime) {self.aPatientlyWaitingFunction()}
// 2nd way __________________________________________
// as a completion to be done after action, in the run invocation:
run(waitSomeTime, completion: aPatientlyWaitingFunction)
// 3rd way __________________________________________
// alternatively, as part of a sequence of actions...
// Create a sequence, by making a run action from waitSomeTime and...
let thenDoThis = SKAction.run(aPatientlyWaitingFunction)
// then activate sequence, which does one action, then the next
run(SKAction.sequence([waitSomeTime, thenDoThis]))
// OR... for something different ____________________
////////////////////////////////////////////////////////
DispatchQueue.main.asyncAfter(deadline: .now() + timeToWait) {
self.aPatientlyWaitingFunction()
print("DispatchQueue waited for 3 seconds")
}

Hovertool Bokeh "Cannot read property"

My problem is that in Chrome, when I have my cursor on my histogram hover my data, I have this error :
Uncaught TypeError: Cannot read property '0'
There is my code :
hist, edges = np.histogram(data,bins=3000)
plot = quad(
top=hist,
bottom=0,
left=edges[:-1],
right=edges[1:],
fill_color="#036564",
line_color="#033649",
tools="pan,wheel_zoom,box_zoom,reset, hover",
x_range=[-0.5,3.5],
plot_width=1100,
title="",
)
hover = plot.select(dict(type=HoverTool))
hover.tooltips = [('index','$index')]
resources = Resources("inline")
plot_script, plot_div = components(plot, resources)
html_script = mark_safe(encode_utf8(plot_script))
html_div = mark_safe(encode_utf8(plot_div))
figure()
return html_script, html_div
"data" is a array like this :
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.24,1,1.32,1,2,3]
I tried to add a "source" in the quad, changed the figure, changed my code for the one on the documentation but I still have my error.
For information, everything is working very well, except the hover tool.
Indeed, in the "hover box" I want another informations then just "index", but it's just for testing.
Thanks for reading !
Sorry I missed this earlier. You have uncovered a small bug with the hover tool that is particular to quad glyphs. In the mean time you can add hover.snap_to_data = False to get it to work.
Here is a GH issue you can track for the full solution:
https://github.com/bokeh/bokeh/issues/1644
A fix should be in the 0.7.1 release next Monday.
Also BTW, you are using a deprecated API. You should now write code like:
p = figure(...)
p.quad(...)

Scilab - calling another GUI within a GUI. Functions not working

I'm quite new to scilab, I have created two GUIs (see example below), with script 2 being called from script 1. However the function in script 2 don't seem to work. Can anyone help?
Script 1
'//////////
f=figure('figure_position',[0,0],'figure_size',[1250,650]);
//////////
delmenu(f.figure_id,gettext('File'))
delmenu(f.figure_id,gettext('?'))
delmenu(f.figure_id,gettext('Tools'))
toolbar(f.figure_id,'off')
handles.dummy = 0 ;
handles.exam=uicontrol(f,'unit','normalized','BackgroundColor', [0.5,1,1],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[14],'FontUnits','points','FontWeight','bold','ForegroundColor',[0,0.5,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.5,0.5,0.1,0.05],'Relief','flat','SliderStep',[0.01,0.1],'String','exam','Style','pushbutton','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','obj102','Callback','exam_callback(handles)')
function exam_callback(handles)
close(f);
clear
exec('costs0-1.sce',-1) ;
endfunction`
Script 2
////////// Defining the figure (size, name etc)/////////////////////////////
f=figure('figure_position',[0,0],'figure_size',[1250,650],'auto_resize','on','background',[8]);
//////////
delmenu(f.figure_id,gettext('File'))
delmenu(f.figure_id,gettext('?'))
delmenu(f.figure_id,gettext('Tools'))
toolbar(f.figure_id,'off')
//Cabinet - TEXT
handles.obj17=uicontrol(f,'unit','normalized','BackgroundColor',[1,1,1],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.15,0.93,0.1,0.05],'Relief','flat','SliderStep',[0.01,0.1],'String','Cabinet','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','obj17','Callback','')
// Cabinet - POP UP MENU
handles.service=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0.5,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.25,0.93,0.15,0.05],'Relief','flat','SliderStep',[0.01,0.1],'String','1|2','Style','popupmenu','Value',[1],'VerticalAlignment','middle','Visible','on','Tag','service','Callback','service_callback(handles)')
// CALCULATE PUSHBUTTON
handles.Calculate=uicontrol(f,'unit','normalized','BackgroundColor',[0,0.8,0],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[16],'FontUnits','points','FontWeight','bold','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.22,0.02,0.15,0.08],'Relief','raised','SliderStep',[0.01,0.1],'String','CALCULATE','Style','pushbutton','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','Calculate','Callback','Calculate_callback(handles)')
// Resources- TEXT
handles.Resourcestxt=uicontrol(f,'unit','normalized','BackgroundColor',[1,1,1],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[14],'FontUnits','points','FontWeight','bold','ForegroundColor',[0,0.5,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.75,0.95,0.20,0.05],'SliderStep',[0.01,0.1],'String','Resources in hours','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','','Callback','')
// TOTAL hours - TEXT
handles.totalhourstxt=uicontrol(f,'unit','normalized','BackgroundColor',[1,1,1],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[14],'FontUnits','points','FontWeight','bold','ForegroundColor',[0,0.5,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.75,0.75,0.12,0.05],'SliderStep',[0.01,0.1],'String','Total Hours','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','','Callback','')
// hardware hours - text
handles.totalhours=uicontrol(f,'unit','normalized','BackgroundColor',[0.95,1,1],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[14],'FontUnits','points','FontWeight','bold','ForegroundColor',[0,0.5,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.88,0.75,0.08,0.05],'SliderStep',[0.01,0.1],'String','','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','totalhours','Callback','')
function Calculate_callback(handles)
if handles.service.value == 1 then
resource_hrs = 2
end
if handles.service.value == 2 then
resource_hrs = 10
end
set(handles.totalhours,'String',string(resource_hrs));
endfunction
Problem
It is a scoping problem. When function exam_callback() gets called it runs the other script with exec('costs0-1.sce',-1).
In that script you define the function Calculate_callback(handles). This goes out of scope and is deleted when exam_callback() is finished and as such can't be called when the button is pressed.
The second problem is that the handles are not globally affected, so when leaving exam_callback() the handles of the second Cost Gui are not added to handles.
Solution
You can move the generating of the GUI into a function createCostGui() and then load script2 at the start of script1 with exec('costs0-1.sce',-1);.
To make Calculate_callback(handles) function discard the handles argument and use the tags to find the handles
function Calculate_callback()
serviceHandle = findobj('tag','service');
if serviceHandle.value == 1 then
resource_hrs = 2
end
if serviceHandle.value == 2 then
resource_hrs = 10
end
totalHoursHandle = findobj('tag','totalhours');
set(totalHoursHandle,'String',string(resource_hrs));
endfunction
Further remarks
Text elements are generally static and thus don't need a Callback argument.
If you want an argument to stay at its default value, you don't need to specify them.
From the Scilab documentation:
h = uicontrol(PropertyName, PropertyValue,...) creates an uicontrol and assigns the specified properties and values to it. It assigns the default values to any properties you do not specify. The default uicontrol style is a "Pushbutton". The default parent is the current figure. See the Properties section for information about these and other properties.
Small remark on your question
Next time an error message could help with making your question more specific.

BOBJ SDK Add Group MemberOf Parent Group

All,
I add a group to be a child of the parent group but, it is not becoming a member of the parent group. I have to go in and set it manually.
Anyone know how this works?
I had to play with it and do a little research on the BOB Forum but I figured it out, though its non-intuitive.
I'm going to assume you know how to get the parent group IUserGroup object.
// get the plugin manager
IPluginMgr pluginMgr = store.getPluginMgr();
// Retrieve the User plugin.
IPluginInfo groupPlugin = pluginMgr.getPluginInfo("CrystalEnterprise.UserGroup");
// Create a new InfoObjects collection.
IInfoObjects newInfoObjects = store.newInfoObjectCollection();
// Add the User plugin to the collection.
newInfoObjects.add (groupPlugin);
// Retrieve the newly created user object.
IUserGroup newUserGroup = (IUserGroup)newInfoObjects.get(0);
// build the new group
String newGroupName = "My Test Group";
newUserGroup.setTitle(newGroupName);
newUserGroup.setDescription("Just for sample test code");
store.commit(newInfoObjects);
// now that things commited associate the parent group
if(parentGroup != null)
{
parentGroup.getSubGroups().add(new Integer(newUserGroup.getID()));
store.commit(parGroupObjs);
}
The big stumper is that you you would expect to just use the setParentID() method. Word of warning this this was only tested under BO XI R2, not R3, so it may not be 100% correct for the current version.