How can you use the FILEOPEN in BBj to create a Filedialog? - bbj

In the Documentation it is stated like this:
'FILEOPEN'(prompt,path,name,ext[,filters[,mode]])
But what parameters do you need to use to be able to display the dialog?
Any samples?

Parameters are documented in this page
Parameter
Description
prompt
Text to display in the title bar of the dialog.
path
Default directory for the file to be opened in the dialog.
name
Default name for the file to be opened in the dialog. Use the empty string ("") to avoid setting a default filename.
ext
Default extension (usually 3 characters, do not include the dot) for the file to be opened in the dialog. Use the empty string ("") to avoid setting a default extension.
filters
One or more filters in the following format: "text description" + $0a$ + "mask" [+$0a$ + "text description" + $0a$ + "mask" ...] The mask specifies an extension, in the format ".ext" or "."; two or more masks are separated with semicolons. The filter, if included, indicates which files will appear in the list. For example: REM Illustrate the use of the FILEOPEN() function REM Build filters for brc/arc and all files FILTER$="Binary Resource Files"+$0a$+".brc;.brf" FILTER$=FILTER$+$0a$+"ASCII Resource Files"+$0a$+".arc" FILTER$=FILTER$+$0a$+"All Files (.)"+$0a$+"." REM Starting directory is the default Directory FILE_DIR$="" REM Use FILEOPEN() to get name of file to open FILE_NAME$=FILEOPEN("Open Resource File",FILE_DIR$,"","",FILTER$) REM display file name returned PRINT FILE_NAME$
rem ' clientfile.txt
precision 6
tc! = bbjapi().getThinClient()
fs! = tc!.getClientFileSystem()
filter$ = ""
filter$ = filter$ + "Text Files (*.txt)"+$0a$+"*.txt"+$0a$
filter$ = filter$ + "HTML Files (*.htm;*.html)"+$0a$+"*.htm;*.html"+$0a$
filter$ = filter$ + "Image Files (*.png;*.jpg;*.bmp;*.gif)"+$0a$+"*.png;*.jpg;*.bmp;*.gif"+$0a$
filter$ = filter$ + "All Files (*.*)"+$0a$+"*.*"+$0a$
i = msgbox("Test client fileopen + copy file from client to server")
clientfile$ = fileopen("Pick a client file","","","",filter$,mode="client")
i = msgbox(clientfile$,0,"Selected client file")
if pos("::"=clientfile$) then goto eoj
cf! = fs!.getClientFile(clientfile$)
i = msgbox("Copy "+clientfile$+" to the server")
t = tim
serverfile$ = cf!.copyFromClient()
t = tim - t
t = t * 3600
serverfile = unt
open (serverfile)serverfile$
serverfile$ = fid(serverfile)(9)
bytes = dec(fin(serverfile)(1,4))
close (serverfile)
i = msgbox("Copied client file "+clientfile$+" to server file "+serverfile$+" ("+str(bytes)+" bytes; "+str(t)+" seconds)",0,"Copied from client to server")
i = msgbox("Test server fileopen + copy file from server to client")
serverfile$ = fileopen("Pick a server file","","","",filter$)
i = msgbox(serverfile$,0,"Selected server file")
if pos("::"=serverfile$) then goto eoj
clientfile! = new java.io.File(serverfile$)
clientfile$ = clientfile!.getName()
clientfile$ = filesave("Save to client","",clientfile$,"",filter$,mode="client")
if pos("::"=clientfile$) then goto eoj
i = msgbox("Copy server file "+serverfile$+" to client file "+clientfile$)
cf! = fs!.getClientFile(clientfile$)
cf!.copyToClient(serverfile$)
i = msgbox("Copied server file "+serverfile$+" to client file "+clientfile$,0,"Copied from server to client")
eoj:
release

Related

quickfixj DataDictionary Validation Issue

I'm new to Java. Working on QuikcFixJ.
I'm trying to load custom.xml file using datadictionary and later parsing msg string from this datadictionary. Not sure what is wrong with datadictionary , its not throwing any error whether I pass correct fix.xml file path or incorrect one.
Later when I pass msg string to Message object it just parse initial 3 tags irrespective of whatever xml file I mention in datadictionary.
Please give me some pointers to resolve it.
Adding code snippet:
public Message createMsg(String type, String message)
{
message = "35=" + type + "\001" + message;
message = "8=FIX4.2\0019=" + message.length() + "\001"+message ;
String msgCharStr = message.replaceAll("\\|", "\001");
int checksum = MessageUtils.checksum(msgCharStr);
msgCharStr = msgCharStr +"\00110=" + (1 +
MessageUtils.checksum(msgCharStr)) + "\001" ;
quickfix.Message msg = new Message();
msg.fromString(msgCharStr, null,true);
}
This code works fine for regular neworder or quoterequest msgs.
But, when I pass quoterequest msg with custom repeating group which I loaded via UseDictionary config settings, it gives undesired output msg.
e.g: Lets say if I pass input, "35=R|146=1|...|453=2|448=XX|447=G|452=1|448=YY|447=D|452=2|......"
parser gives output as :
"35=R|146=1|...|448=XX|447=G|452=1|453=2|448=YY|447=D|452=2|......"
----Code re-build steps for new custom FIX42.xml ---
Copied quickfixj2.3.1.zip (url: https://github.com/quickfix-j/quickfixj/releases )
Updated xml at path quickfixj-messages/quickfixj-messages-fix42/src/main/resources/FIX42.xml
run mvn build command.
Maven re-build jar for below:
quickfixj-all
quickfixj-core/
quickfixj-messages/
quickfixj-codegenerator/
quickfixj-dictgenerator/
Tried using all above jar files in my RobotFramework with an assumption that it will now refer the modified QuoteRequest msg which has repeating group support.
To my surprise, its output was exactly same. No changes.
After quickfixj rebuild for customised xml file.
Final version of code snippet:
public Message createMsg(String type, String message)
{
message = "35=" + type + "\001" + message;
message = "8=FIX4.2\0019=" + message.length() + "\001"+message ;
String msgCharStr = message.replaceAll("\\|", "\001");
int checksum = MessageUtils.checksum(msgCharStr);
msgCharStr = msgCharStr +"\00110=" + (1 +
MessageUtils.checksum(msgCharStr)) + "\001" ;
DataDictioanry dd = DataDictionary("FIX42.xml");
quickfix.Message msg = new Message();
msg.fromString(msgCharStr, dd ,true);
}

Naming convention for variables containing file path or its parts

What are standard or most self-descripting variable names for variables with following values? (Consider them from perspective of File.Ext)
// Windows environment
var0 = "C:\Folder_A\Folder_B\Folder_C\File.Ext"
var1 = "C:\"
var2 = "C:\Folder_A\"
var3 = "C:\Folder_A\Folder_B\"
var4 = "C:\Folder_A\Folder_B\Folder_C\"
var5 = "File"
var6 = "Ext"
var7 = ".Ext"
This is what comes to my unexperienced mind:
FullPath
Drive
???
???
ParentFolderPath
Filename
Extension
FullExtension
Also what is Windows standard or best practice for storing folder paths - with or without the last \?
Same for extension - with or without .?
filePath = "C:\Folder_A\Folder_B\Folder_C\File.Ext"
rootDirectory = "C:\"
directoryPath = "C:\Folder_A\"
anotherDirectoryPath = "C:\Folder_A\Folder_B\"
aThirdDirectoryPath = "C:\Folder_A\Folder_B\Folder_C\"
filenameSansSuffix = "File"
fileSuffix = "Ext"
anotherDefinitionOfFileSuffix = ".Ext"
It is more natural to define directory paths without a trailing backslash.
When it comes to file extensions I usually include the dot. Also, in Windows Batch scripting, for instance, the modifier ~x results in the file extension including the dot (when i tried it).
%~xI Expands %I to a file name extension only.
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/for

?:0: attempt to perform arithmetic on field 'fileSize' (a nil value)

How to resolved error or possible ways to resolved it?
Guys, i've developed plugin using Lua language which can be integrate or run from Adobe's LightRoom Classic. Currently i need to upload or send a file to server but i can not. Everytime i called the POST API which is multipart/form-data error popup "?:0: attempt to perform arithmetic on field 'fileSize' (a nil value)". Not even API is being called this error pops up before API call. after debug I can assure the possible issue is in creating mimeChunks with file type.
I have developed the code like below, can any one help me out with suggestions so that i can able to resolved issue?
local filePath = assert("C:\Users\Ankit\Desktop\Hangman.PNG")
local fileName = LrPathUtils.leafName(filePath)
local mimeChunks = {}
mimeChunks[#mimeChunks + 1] = {
name = 'api_sig',
value = "test value"
}
mimeChunks[#mimeChunks + 1] = {
name = "file",
filePath = filePath,
fileName = fileName,
contentType = "application/octet-stream"
}
local postUrl = "API endpoint"
local result, hdrs = LrHttp.postMultipart(postUrl, mimeChunks)
if result then
LrDialogs.message("Form Values", result)
else
LrDialogs.message("Form Values", "API issue")
end
Eventually image or file path itself cause the issue, there are no such indications or articles related to this functionality, but yes "add-on backslash" will work out for sure. Kindly review the below code for more detailed bifurcation which pass dynamic selected file or image path.
local function uploadFile(filePath)
local fileName = LrPathUtils.leafName( filePath )
local mimeChunks = {}
mimeChunks[ #mimeChunks + 1 ] = { name = 'api_sig', value = "test value"}
mimeChunks[#mimeChunks + 1] = {
name = "file",
filePath = filePath,
fileName = fileName,
contentType = "image/jpeg" --multipart/form-data --application/octet-stream
}
import "LrTasks".startAsyncTask(
function()
local postUrl = "http://cms.local.com/api/v1/upload"
local result, hdrs = LrHttp.postMultipart(postUrl, mimeChunks)
if result then
LrDialogs.message("Image uploaded.", result)
else
LrDialogs.message("Error", "API issue")
end
end
)
end
Above uploadFile method will automatically call the API and post form-data collection. Below code is for call uploadFile function which select all the images from catalog.
for p, photo in ipairs(LrApplication.activeCatalog()) do
uploadFile(assert(photo:getRawMetadata('path')));
end
Above code will help you out the selection of categlog with Adobe's LightRoom Plugin.

vbscript and prncnfg.vbs inside?

I have a vbscript to get some informations about the system printing of a remote computer. I can get all the drivers installed, the default network printer name and all my results are send in a outputfile.
I want to get informations about my default network printer by the prncnfg.vbs from the printer server (driver, location, etc.) and send these informations in my outputfile.
Maybe there is an other way to do that ?
Thanks for any suggestions
So, I start to understand the way to do that. But something doesn't work.
First I need to read a file and remove 10 caracters to create my variable, this process works very well:
'Read C:\Temp\DefaultPrinter
Dim shortDefaultPrinter
If objFSO.FileExists("\"& strComputer &"\c$\Temp\DefaultPrinter.txt") then
Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile("\"& strComputer &"\c$\Temp\DefaultPrinter.txt",1)
DefaultPrinter = objFileToRead.ReadAll()
'remove text \vangogh\
shortDefaultPrinter = Right(DefaultPrinter, Len(DefaultPrinter) - 10)
'MsgBox(shortDefaultPrinter)
objFileToRead.Close
Set objFileToRead = Nothing
Second I want to use my variable shortDefaultPrinter for my query to find the location of my printer:
'Select DefaultPrinter and show location
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = "Select printerName, serverName, Location from " _
& " 'LDAP://DC=huge,DC=ad,DC=hcuge,DC=ch' where objectClass='printQueue' and printerName='" & shortDefaultPrinter & "' "
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
PrinterLocation = objRecordSet.Fields("Location").Value
MsgBox(PrinterLocation)
objRecordSet.MoveNext
Loop
MsgBox doesn't open, but if I write the name of the printer in place of " & shortDefaultPrinter & ", ex dmed-i714, the process works.
Here I am. If anyone has a suggestion it would be appreciate.

Pythonic URL Parsing

There are a number of questions about how to parse a URL in Python, this question is about the best or most Pythonic way to do it.
In my parsing I need 4 parts: the network location, the first part of the URL, the path and the filename and querystring parts.
http://www.somesite.com/base/first/second/third/fourth/foo.html?abc=123
should parse into:
netloc = 'www.somesite.com'
baseURL = 'base'
path = '/first/second/third/fourth/'
file = 'foo.html?abc=123'
The code below produces the correct result, but is there are better way to do this in Python?
url = "http://www.somesite.com/base/first/second/third/fourth/foo.html?abc=123"
file= url.rpartition('/')[2]
netloc = urlparse(url)[1]
pathParts = path.split('/')
baseURL = pathParts[1]
partCount = len(pathParts) - 1
path = "/"
for i in range(2, partCount):
path += pathParts[i] + "/"
print 'baseURL= ' + baseURL
print 'path= ' + path
print 'file= ' + file
print 'netloc= ' + netloc
Since your requirements on what parts you want are different from what urlparse gives you, that's as good as it's going to get. You could, however, replace this:
partCount = len(pathParts) - 1
path = "/"
for i in range(2, partCount):
path += pathParts[i] + "/"
With this:
path = '/'.join(pathParts[2:-1])
I'd be inclined to start out with urlparse. Also, you can use rsplit, and the maxsplit parameter of split and rsplit to simplify things a bit:
_, netloc, path, _, q, _ = urlparse(url)
_, base, path = path.split('/', 2) # 1st component will always be empty
path, file = path.rsplit('/', 1)
if q: file += '?' + q

Resources