This sounds like a ridiculous question but I cannot for the life of me make a directory on ios using codenameone. Has anyone done it ? Here is what I try (some dumb tests some not so dumb, im getting desperate here):
FileSystemStorage fs = FileSystemStorage.getInstance();
fs.mkdir("ZZZTESTA");
fs.mkdir("ZZZTESTB");
String testpath = fs.getAppHomePath()+"/xxxtesta";
fs.mkdir(testpath);
String testpathb = fs.getAppHomePath()+"xxxtestb";
fs.mkdir(testpathb);
String testpathC = fs.getAppHomePath()+"xxxtest/";
fs.mkdir(testpathC);
String nativetest = fs.toNativePath(testpathb);
fs.mkdir(nativetest);
String nativetestb = fs.toNativePath(testpathC);
fs.mkdir(nativetestb);
I have done all kinds of experiments but ALWAYS I get : Failed to create directory xxxxx.. I will fly to your location and shower you with gifts if you can help :)
These would work:
String testpathb = fs.getAppHomePath()+"xxxtestb";
fs.mkdir(testpathb);
String testpathC = fs.getAppHomePath()+"xxxtest/";
fs.mkdir(testpathC);
Related
Today 07/07/2022, I am working in Geemap trough Google Colab. I have been working with some codes that have been performed OK, however, today the interactive map is not displayed.
Also I have tried with other public codes, and the issue remains. Has someone experienced this kind of problem? Thanks for help.
A sample of code is given:
rgb2 = ['B8_median','B11_median','B4_median']
# set some thresholds
rgbViz2 = {"min":0.0, "max":3000,"bands":rgb2}
collectionx = ee.ImageCollection('COPERNICUS/S2_SR').filterDate("2020-06-25","2020-09-11").filterBounds(aoi2).filter(ee.Filter.lt("CLOUDY_PIXEL_PERCENTAGE",6))
collectionrgb = collectionx.select('B8','B11','B4', 'B3','B2')
medianx = collectionrgb.reduce(ee.Reducer.median());
#Get information about the bands as a list.
bandNames = medianx.bandNames()
print('Band names: ', bandNames.getInfo())
# initialize our map
map6 = geemap.Map()
map6.centerObject(aoi2, 8)
map6.addLayer(medianx.clip(aoi2), rgbViz2, "S2")
map6.addLayerControl()
map6
I am trying to write a GUI that will display the name of the sketch it was generated from using a simple text() command. However, I am running into trouble getting any of the general JS solutions to work for me. Many solutions I have found use the filename reserved word but that does not seem to be reserved in Processing 3.5.4. I have also tried parsing the strings using a similar method to what can be found here. I am very new to processing and this is only my 2nd attempt at using Processing.
Any advice would be greatly appreciated
You can get the path (as a string) to the sketch with sketchPath().
From there you could either parse the string (pull off everything after the last slash) to get the sketch name, or you can use sketchFile() to get a reference to the file itself and get the name from there:
String path = sketchPath();
File file = sketchFile(path);
String sketchName = file.getName();
println(sketchName);
You could combine this all into one line like so:
String sketchName = sketchFile(sketchPath()).getName();
Question: I need to manually call an object listener event (e.g. key pressed) to trigger a function. I used to do it in Access but haven't found the documentation for it in LibreOffice Base.
Context: Having retired from software development 7 years ago, I am doing a favour for a friend by building a database in LibreOffice Base. Previously experienced in Access - but more with Oracle, PL/SQL, APEX, etc! I am struggling a little in getting it to do what I know can be done!
Here is the code I've tried so far.
Sub CauseKeyPressedEventToBeFired
oDoc = ThisComponent
oController = oDoc.getCurrentController()
oVC = oController.getViewCursor()
oForm = oDoc.getDrawpage().getForms().getByName("Form")
oTextBox = oForm.getByName("Text Box 1")
oControlView = oController.getControl(oTextBox)
oControlView.setFocus()
Dim oEvent As New com.sun.star.awt.KeyEvent
oEvent.Source = oControlView
oEvent.KeyCode = com.sun.star.awt.Key.A
oControlView.keyPressed(oEvent)
End Sub
However, it doesn't seem to work on my system (LibreOffice 6.4.3.2 on Windows). I also found this post, but that code doesn't seem to work for me either.
I searched for com.sun.star.awt.XToolkitRobot, but it's not in the API documentation, perhaps because the functionality is not fully supported. Presumably, it can be obtained from com.sun.star.awt.Toolkit.
For more help, post a question on ask.libreoffice.org. I'd suggest explaining why you want to do this, because there may be a different kind of solution. Ratslinger has a lot of experience solving various database problems, and he'll probably direct you toward a simpler solution that doesn't involve this kind of event hacking.
a function (i.e. a procedure that returns a value)
Yes, that is what a function is. But "an object listener event" implies, correctly I think, that we're talking about the method of an object instead. That's what LibreOffice event listeners are in Python or Java, although in Basic, they're a little strange, using the object name as some kind of magic to determine what they apply to. Anyway, that's getting off track, because your question isn't about listening for events, but rather about triggering them.
EDIT:
The following Python code works. The problem with my earlier attempts was that oEvent.KeyChar needs to be set, and that doesn't seem to work in Basic. I can't imagine why, unless I am ignoring some obvious mistake in the Basic code.
def causeKeyPressedEventToBeFired(oEvent=None):
oDoc = XSCRIPTCONTEXT.getDocument()
oController = oDoc.getCurrentController()
oForm = oDoc.getDrawPage().getForms().getByName("Form")
oTextBox = oForm.getByName("Text Box 1")
oControlView = oController.getControl(oTextBox)
oControlView.setFocus()
oEvent = uno.createUnoStruct("com.sun.star.awt.KeyEvent")
oEvent.Source = oControlView
from com.sun.star.awt.Key import A
oEvent.KeyCode = A
oEvent.KeyChar = "a" # works in Python but strangely not in Basic
simulate_KeyPress(oEvent)
def simulate_KeyPress(oKeyEvent):
oDoc = XSCRIPTCONTEXT.getDocument()
oWindow = oDoc.CurrentController.Frame.getContainerWindow()
oKeyEvent.Source = oWindow
oToolkit = oWindow.getToolkit()
oToolkit.keyPress(oKeyEvent)
oToolkit.keyRelease(oKeyEvent)
EDIT 2:
Finally, here is working Basic code. In the earlier attempt, the type was wrong.
Sub CauseKeyPressedEventToBeFired
oDoc = ThisComponent
oController = oDoc.getCurrentController()
oForm = oDoc.getDrawpage().getForms().getByName("Form")
oTextBox = oForm.getByName("Text Box 1")
oControlView = oController.getControl(oTextBox)
oControlView.setFocus()
Dim oEvent As New com.sun.star.awt.KeyEvent
oEvent.KeyCode = com.sun.star.awt.Key.A
oEvent.KeyChar = CByte(97)
simulate_KeyPress(oEvent)
End Sub
Sub simulate_KeyPress(oKeyEvent As com.sun.star.awt.KeyEvent)
oWindow = ThisComponent.CurrentController.Frame.getContainerWindow()
oKeyEvent.Source = oWindow
oToolkit = oWindow.getToolkit()
oToolkit.keyPress(oKeyEvent)
oToolkit.keyRelease(oKeyEvent)
End Sub
I had implemented the following curl code using RESTSharp to find the language of sentence "What is your name?".
I followed the "Identify language" under : http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/language-translation/api/v2/#identify
string source = "What is your name?";
string credentials;
string auth = string.Format("{0}:{1}", tuid, tpwd);
string auth64 = Convert.ToBase64String(Encoding.ASCII.GetBytes(auth));
credentials = string.Format("{0} {1}", "Basic", auth64);
var langDet = new RestClient(detURL);
var requestDet = new RestRequest("?text={authToken}",Method.POST);
requestDet.Credentials = new NetworkCredential(tuid, tpwd);
requestDet.AddParameter("text", source, ParameterType.UrlSegment);
IRestResponse responseDet = langDet.Execute(requestDet);
However, when this code is executed I get a list of languages and confidence level while I still am not sure how to accurately specify which language the above sentence goes to. Please help me where I am wrong.
My detUrl variable above is: https://gateway.watsonplatform.net/language-translation/api/v2/identify
you can get what you want using the Alchemy API, which is also available in Bluemix. Here's an example using Java + Watson SDK
AlchemyLanguage service = new AlchemyLanguage();
service.setApiKey("XXXXXXXXX");
Map<String,Object> params = new HashMap<String, Object>();
params.put(AlchemyLanguage.TEXT, "What is your name?");
Language language = service.getLanguage(params);
System.out.println(language);
I use this Java SDK above, but there's a .NET port for it here
https://github.com/dennyboy/WatsonCSharp
Thank you !
I found the answer.
(1) In my code above, I have been passing the {authtoken} instead of the string I had wanted to send (string source in example below
var requestDet = new RestRequest("?text=" + source, Method.POST);
(2) Once done, I had to deserialize the output from "responseDet" and filter the first value (as below). I had used Jsonconvert class.
DataSet data = JsonConvert.DeserializeObject<DataSet>(responseDet.Content);
return data.Tables[0].Rows[0][0].ToString();
My code is working fine. Thanks for your help !
i want to show the assembly version number on the form and i am stuck. the code will compile without errors and yet does not run. when i remove the lines below then the code will compile and run. i know that i am missing something here and i cannot see what it is. can someone point me in the right direction?
string Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
string version = "Version: " + Version;
Form1.ActiveForm.Text = Version;
I always use this method to get the version number.
versionInfo contains much more info than just the productversion so I am sure you can get from it what you need.
private string GetAppVersion()
{
var versionInfo = FileVersionInfo.GetVersionInfo(Application.ExecutablePath);
return versionInfo.ProductVersion;
}