I know that this question has already been answered but the given solution doesn't work for me. The given solution is:
Dim oDoc As Object
Dim Path$
oDoc = ThisComponent
Path$ = oDoc.getURL()
Actually this returns an empty string ("") for me. Is there something I missed?
I'm on LibreOffice 4.3.1.2 on Kubuntu 12.04.
Thanks for your help!
What happens if you run this?
If oDoc.HasLocation() Then
Print "The Document URL is " & oDoc.getURL()
Else
Print "The document has not yet been stored"
End If
It works perfectly if I compile the macro, it doesn't work if I debug the uncompiled macro.
of course, because the debug environment Parent is not the same then your Document Parent.
Related
Programming in Python in Visual Studio Code, I was wondering if there exists a way, given an output, to trace back to the respective input. If, for example, a print is generated by a line in my code, does there exist a command, or a tool of VS Code, such that I can find exactly the line where this output was produced? Maybe it's a trivial question, but it would be useful for me if someone has a suggestion.
If I got your question correctly, you can use a function breakpoint() .
def foo():
a = input()
breakpoint() #Put it and debug interface will be opened in terminal
generated_result = a + 'abc'
return generated_result
Apologies in advance because this is probably fairly stupid.
Basically I was just messing around trying to figure out how to work with inputs (I'm pretty new to coding) and I came across an issue within an if statement.
x=input("What is your name? ")
name=x
print("Hello,", name, "nice to meet you")
y=input("Would you like me to close now? (yes/no) ")
listx=["no","No","NO","nO"]
for response in listx:
if response == y:
input("Why? ")
input("I think you're being rather terse", name, ". ")
input("No, you. ")
input("So that's how it's going to be? ")
input("Well I'm closing anyway. ")
input("Bye then. ")
I kind of just thought it would take me through this funny little exchange and over time I could customise the responses but there's a problem at this point:
input("I think you're being rather terse", name, ". ")
At this juncture the code doesn't seem to recognise name; I defined name because it wasn't working when I just used x either. I'm assuming that the code doesn't recognise it because the if statement is essentially within a vacuum or something but how exactly would I work around this? I want to be able to call back details which happened previously within the conversation to try to make it funnier.
You can't do that with input() statements - it only works with print(). So print() can take any number of strings as an argument, but input() will only take one (and in recent versions of python will raise an error if you try to give it more than one - when I tried to run your code myself, I got a TypeError).
If you want to include name in the text of the input(), you'll need to either concatenate it:
input("I think you're being rather terse " + name + ". ")
or use a format string to insert it:
input(f"I think you're being rather terse {name}. ")
I am trying to understand the perl commands below:
$my = << EOU;
This is an example.
Example too.
EOU
What is the name of this way? Could somebody can explain more about this "multi-line writing" command?
Essentially the syntax is allowing you to put anything unique as a marker so that it won't conflict with your contents. You can do this:
$my = <<ABCDEFG;
This is an example.
Example too.
BLAH
ABCDEFG
Everything between "This.." and "BLAH" will be assigned to the variable. Note that you shouldn't have a space after the << symbols otherwise you will get a syntax error. It helps avoid adding CR characters, or append (.) everywhere, and useful when passing data into another application (eg. ftp session). Here Documents is the correct term for this.
Everything between <<EOU and EOU is a multi-line, non-escapable, string. It's nothing fancy, think of them as start and end quote marks with nothing inside requiring escapes to be literally what you typed...
here are the relevant code lines for a unicode/pyside related problem :
#!/usr/bin/env python
# coding=utf-8
...
msgBox = QtGui.QMessageBox()
msgBox.setText('é')
print 'é'
....
The print does what it should, implying my locale is utf-8, and printenv confirms it. On the other hand, the msgBox shows 'é', unless I prefix the string with 'u'. Is that normal, and do I really have to prefix every string with u in order to use Pyside, when python never raises a problem?
Thanks for your attention.
In Python 2.X there are two data types for strings: byte code and unicode. With u you choose unicode with nothing you choose byte code. If you print bytes('é') you see where PySide/PyQt get their data from. So it probably is normal.
The easy way out is using Python 3.X which just has unicode and won't bother you with the difference.
Not sure who is actually doing something that shouldn't be done, the print function Python 2.X or PySide/PyQt for Python 2.X, so I make it community wiki.
I apologize if this is a newb question, but I have read the documentation here and it says nothing about having to input any command before using substring.
However, when I try to call it as follows:
substring('hello world', 2)
It gives me the error
??? Undefined function or method 'substring' for input arguments of type 'char'.
What is the correct way to invoke this substring?
Not to detract from the OP's answer, which actually more directly adresses the question you ask, but assuming all you want to do is extract a certain number of characters from a string, MATLAB's indexing is all you need:
myString = 'Hello, world!';
mySubstring = myString(3:end)
mySubstring =
llo, world!
substring is not a MATLAB function at all, at least in MATLAB proper. There IS a substring JAVA function, but I have no idea if that is what you are asking.
>> which substring
substring is a Java method % java.lang.String method
The above also tells you what you will need to do. Look here. (Google is your friend. Of course, you could as easily have done exactly what I just did, and gotten this answer far more quickly.)
You may also be talking about some custom code, written by some colleague of yours. In that case, talk to your friend. Very often I hear about tools that were written by someone, then left around as legacy code, unsupported. Eventually, it just disappears due to path issues when new versions of MATLAB are installed.
You might actually want strsplit. This will parse char data by a given or default delimiter and return a cell array of the pieces.