Can't edit root_blip of fetched wavelet - google-wave

When i edit root_blip of wavelet everything works fine, but if i fetch the wavelet nothing happens neither in googleWave nor logs (no errors occured), although "wave_list.reply(text)" works. I have made myRobot.setup_oauth()
def OnWaveletSelfAdded(event, wavelet):
text = "123"
wave_list = myRobot.fetch_wavelet(wave_id="googlewave.com!w+O5yFQIteC", wavelet_id="googlewave.com!conv+root")
wave_list.submit_with(wavelet)
root_blip = wave_list.root_blip
root_blip.all().delete()
root_blip.append("WaveList\n" + text)
logging.info("root_blip.wave_id: %s" % root_blip.wave_id)
What am I doing wrong? I've tried myRobot.submit(wave_list) - also no results

wave_list = myRobot.fetch_wavelet(wave_id = wave_id, wavelet_id="googlewave.com!conv+root")
root_blip = wave_list.root_blip
root_blip.all().delete()
root_blip.append("WaveList:\n")
myRobot.submit(wave_list)
solved...

Related

Error: Can't Assign Function Call / Don't want to

It's friday and I'm tired and my brain obvs doesn't want to find this answer. Please help.
I want to assign the value to an array. It works in subsequent lines but not in one particular line, even though syntax seems the same to me? It seems to think I'm calling a function??
for entry in PROJECT:
i = i + 1
#A
if entry.startswith("A") :
ProjectA(i) = entry
#B
elif entry.startswith("B"):
ProjectB(i)= entry
#C
elif entry.startswith("C") :
ProjectC(i) = entry
# and Programme
elif entry.startswith("D") :
ProjectD(i) = entry
I'm told the problem is the last line: "ProjectD(i) = entry". Which to me seems like a replica of "ProjectC(i) = entry"
ProjectA(i) looks like you are calling a function; ProjectA[i] looks like an array element.

How to use arrays created by loop? Matlab

The code I'm using imports data from multiple files and saves them into an array of cells, the code is as follows:
[FileName,PathName,FilterIndex] = uigetfile('*.txt*','MultiSelect','on');
numfiles = size(FileName,2);
FileData= cell(1,numfiles);
for ii = 1:numfiles
FileName{ii};
A=[];
entirefile =fullfile(PathName,FileName{ii});
fid = fopen(entirefile);
tline = fgets(fid);
while ischar(tline)
parts = textscan(tline, '%f;');
if numel(parts{1}) > 0
A = [ A ; parts{:}' ];
end
tline = fgets(fid);
end
fclose(fid);
FileData{ii} = A;
A = FileData{ii};
X = A(:,1);
Y = A(:,5);
DataToUse = [X,Y];
end
Now my issue is I want to use the first DataToUse created by the loop, which will be data from the first file, seperatley to the other files but I can not issolate it. I have tried DataToUse(1), DataToUse(1,1) and DataToUse(:,[1,2]) but none are working for me. An example of the type of data would be:
DataToUse=
0.0762 0.0271
0.0763 0.2671
0.0764 0.4079
0.0765 0.0510
0.0766 0.0087
0.0767 0.0099
0.0768 0.0067
0.0769 0.0047
0.0770 0.0047
0.0771 0.0349
0.0772 0.2094
0.0773 0.2740
0.0774 0.0294
0.0775 0.0100
0.0776 0.0159
I have different numbers of this kind of data depending on how many files are selected but I would like to only use the first initially and use the others later. Anybody know how I can go about doing this? Many thanks in advance
The solution is to use cell arrays, like so:
DataToUse{ii} = [X, Y]
To get the desired output put this after your for-loop:
firstLoopXY = DataToUse{1}
Enjoy!

insert URLs in kunamed.bst

I am using LyX and would like to add URLs to my #misc entries in my bibtex bibliography. I am using the kunamed.bst style for my bibliography. My bibtex entries looks like this
#misc{RFA2011,
author = {RFA},
booktitle = {Statistics},
title = {{Renewable Fuels Association}},
url = {http://www.ethanolrfa.org/pages/statistics},
urldate = {Jan 13th 2014},
year = {2014}
}
I have tried to change the FUNCTION {misc} in the kunamed.bst file like from this:
FUNCTION {misc}
{ output.bibitem
format.authors output
author format.key output
output.year.check
format.title output
format.date output
new.block
howpublished output
new.block
note output
fin.entry
}
to this
FUNCTION {misc}
{ output.bibitem
format.authors output
author format.key output
output.year.check
format.title output
format.date output
format.url output % <------
new.block
howpublished output
new.block
note output
fin.entry
}
No change is happening in my bibliography. Any ideas how to fix this?
I solved the problem myself by changing the way the url is written in the bibtex entry
#misc{RFA2011,
author = {RFA},
booktitle = {Statistics},
title = {{Renewable Fuels Association}},
howpublished = "\url{http://www.ethanolrfa.org/pages/statistics}", % <---
year = {2014},
note = "[Accessed online: 13-Jan-2014]"

Arranging the fields of a structure into order

I am trying find away of ordering a polynomial in the form a structure so that the exponent fields are in ascending order. I don't want to use a built in sort function to do this.
for example the polynomial:
p = struct('exponent',{2,3,2,9},'coeff',{1,2,91,40})
represents the polynomial:
p = 1(x^2) + 2(x^3) + 91(x^2)+ 40(x^9)
I want to rearrange it so that it becomes (the exponents are now in ascending order)
p = 1(x^2) + 91(x^2) + 2(x^3) + 40(x^9)
my code to do this is:
function [ output ] = myMergepoly2( p )
h=1;
output(1,length(p))=struct('exponent',{},'coeff',{});
while (h<length(p))
if p(1,h+1).exponent<p(1,h).exponent
output(1,h).exponent = p(1,h+1).exponent;
output(1,h).coeff = p(1,h+1).coeff;
h=h+1;
else
output(1,h).exponent = p(1,h).exponent;
output(1,h).coeff = p(1,h).coeff;
end
end
end
However when I try to run this function MATLAB remote has 'busy' written out with no error message. I am unsure what is causing this and how to fix it, any help would be appreciated.
In the else section of the loop, you don't increment h, so it goes like this:
h=1 --> if p(1,h+1).exponent<p(1,h).exponent is false --> skip to else loop and set output(1,1).exponent --> h=1 (while loop keeps going).
Using MATLAB inbuilt sort I'd just do something along the lines of:
exponent = [p.exponent];
coeff = [p.coeff];
[exponent idx] = sort(exponent);
output.exponent = exponent;
output.coeff = coeff(idx);
Replace this line :
output(1,length(p))=struct('exponent',{},'coeff',{});
With this line :
output = struct('exponent',cell(1,length(p)),'coeff',cell(1,length(p)));
Also put this instead:
while (h<length(p))
if p(1,h+1).exponent<p(1,h).exponent
output(1,h).exponent = p(1,h+1).exponent;
output(1,h).coeff = p(1,h+1).coeff;
else
output(1,h).exponent = p(1,h).exponent;
output(1,h).coeff = p(1,h).coeff;
end
h=h+1;
end
However I'm still not getting the right output, I'm working on it.

Am I using 'ontimer' incorrectly in Vizard?

I am very new to programming in Vizard, but I am a pretty strong .js programmer. I have an art gallery and I want a man to walk from picture to picture. He needs to wait for a few seconds at each picture.
So I have a number of walking sequences and I'm trying to use the 'ontimer' function to call the next walk sequence and also add a few seconds of delay.
It works perfectly the first time it is called, in dostuff(), but doesn't work at all in dostuff2(). I assume I am using 'ontimer' incorrectly, could anyone explain where I am going wrong?
Any help or advice would be hugely appreciated!
walkOne = vizact.walkto(4, -0.5, 4)
turnOne = vizact.turn(60)
walking_sequence = vizact.sequence( [walkOne, turnOne])
walkTwo = vizact.walkto(5.350, -0.5, -2)
turnTwo = vizact.turn(60)
walking_sequenceTwo = vizact.sequence( [walkTwo, turnTwo])
def dostuff():
male.addAction(walking_sequence)
vizact.ontimer(10,dostuff2)
def dostuff2():
male.addAction(walking_sequenceTwo)
print(vizact.ontimer)
vizact.ontimer(20,dostuff)
Cracked it!! Got rid of the ontimer completely and used waittimer instead, seems to work ok.
walkOne = vizact.walkto(4, -0.5, 4)
turnOne = vizact.turn(60)
walking_sequence = vizact.sequence(walkOne, turnOne, vizact.waittime(10))
walkTwo = vizact.walkto(5.350, -0.5, -2)
turnTwo = vizact.turn(60)
walking_sequenceTwo = vizact.sequence(walkTwo, turnTwo, vizact.waittime(10))
def dostuff():
male.addAction(walking_sequence)
dostuff2()
def dostuff2():
male.addAction(walking_sequenceTwo)
dostuff3()

Resources