How to get new line in Run Results Viewer Version 11 - vbscript

We recently upgraded to ALM 11 at work and I am trying to add some formatting to the run details field in the HP Run Results Viewer application. We have existing code from older versions of ALM that displays the info on multiple lines:
pass =
fail =
warning =
The code we used was like this:
Stats = "Passed = " & vbCrLf & "Failed = " & vbCrLf & "Warning = "
Reporter.ReportEvent micFail, "Test", stats
In ALM 11's viewer it shows up as pass= fail= warning= all on one line.
Is there a way to add the new line to the results? This is our most simple example and much of the results are currently unreadable.

Unfortunately, I do not have any good explanation for why your code doesn't work. It looks OK to me. However, I have an alternative approach that might do the trick: Have you tried to use ASCII and Unicode Character Codes instead of the VBScript built-in "vbCrLf"?
Using the ASCII approach, your code would look like this:
Stats = "Passed = " & Chr(10) & "Failed = " & Chr(10) & "Warning = "
Chr(10) equals an NL line feed, i.e. a new line. Chr(13) would do a carriage return, if you want to try that instead, or in addition to, the line feed.
More information on the Chr function can be found here: https://msdn.microsoft.com/en-us/library/ws6aa3sf(v=vs.84).aspx.
UPDATE:
It looks like this is a known defect in QTP 11 - see http://h30499.www3.hp.com/t5/Unified-Functional-Testing/QTP-run-result-viewer-issue-with-VBCRLF/td-p/5898077.
There is another approach you could try (unless upgrading QTP is an option), using HTML and LogEvent - see http://www.joecolantonio.com/2014/11/06/revealed-four-secret-functions-hidden-in-qtp-and-uft/, but beware of the limitations mentioned in the comments section.

Related

NeoVim: Broken Syntax Highlighting after heredoc "lua << EOF" in VimScript

I'm facing the problem that my init.vim becomes not highlighted properly after the line with lua << EOF in NeoVim. The weird behaviour is 1) paired brackets are colored differently; 2) After lua << EOF a Lua context does begin, yet it doesn't seem to be ended after the next EOF, instead it continues being highlighted in a Lua syntax (all lines later on are affected). From the screenshot below you can see that the brackets in line 59 are displayed as white and red separately, and the Lua syntax stays after line 60.
The code itself is assumed as okay, since it can be sourced without any error or warning, and the editing functions normally. It should namly only be a problem with the highlighting.
Sadly I can't tell the context of this problem. I first noticed it today without doing anything special (e.g. installing a new plugin) and I'm not sure when it occured. I have no clue what is causing this, even after doing research on Google for more than one hour - I haven't seen any post describing a similar situation.
The problem remains with the default color scheme.
I was guessing the CoC extension coc-vimlsp could be relevant, but the problem remains after I disabled it. Otherwise I can't remember any NeoVim plugin that could have something to do with the highlighting.
EDIT: I noticed that the broken highlighting after EOF is relevant to the broken brackets. If I write no brackets in the heredoc block, the highlighting will work correctly. Looks like the Lua highlighting remains after the heredoc block because it thinks the brackets aren't closed properly. And this is only about round brackets (), other brackets like [] {} "" would cause no problem.
My init.vim:
" Indentation
set shiftwidth=4
set ai
set si
" Show line numbers
set nu
" Show command at the bottom right of the screen
set sc
" Limit the number of items shown in popup
set ph=20
" Set the minimal number of lines below the cursor
set so=15
" Disable auto comment insertion
au Filetype * setlocal fo-=c fo-=o fo-=r
" vim-plug config
call plug#begin()
" Themes
Plug 'catppuccin/nvim', {'as': 'catppuccin'}
Plug 'tiagovla/tokyodark.nvim'
" Icon support
Plug 'ryanoasis/vim-devicons'
" Statusbar
Plug 'nvim-lualine/lualine.nvim'
" Fish support
Plug 'dag/vim-fish'
" Makrdown support
Plug 'preservim/vim-markdown'
" Markdown preview
Plug 'iamcco/markdown-preview.nvim', { 'for': ['markdown', 'vim-plug'] }
" TeX support
Plug 'lervag/vimtex'
" Auto close XML-like tags
Plug 'alvan/vim-closetag'
" Auto close brackets
Plug 'jiangmiao/auto-pairs'
" CoC completion engine
Plug 'neoclide/coc.nvim', { 'branch': 'release' }
call plug#end()
" catppuccin config
let g:catppuccin_flavour = "mocha" " latte, frappe, macchiato, mocha
lua << EOF
require("catppuccin").setup()
EOF
" Set colorscheme
colorscheme catppuccin
" lualine config
lua << EOF
require('lualine').setup({
options = {
theme = "horizon"
}
})
EOF
" vim-markdown config
let g:tex_conceal = ""
let g:vim_markdown_math = 1
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_frontmatter = 1
let g:vim_markdown_new_list_item_indent = 0
" Enable vimtex for Markdown files
" Not ideal, since this enables ALL features of vimtex
au Filetype md,markdown call vimtex#init()
" VimTeX config
let g:vimtex_compiler_latexmk = {'continuous': 0}
" CoC config
exe 'so ~/.config/nvim/coc_config.vim'
Operating system: MacOS Monterey 12.4
Output of nvim -v:
NVIM v0.8.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew#Monterey
Features: +acl +iconv +tui
See ...
The issue raised in both of Neovim and Vim repository.
Neovim side: https://github.com/neovim/neovim/issues/20456
Vim side: https://github.com/vim/vim/issues/11277
Workaround from the comment: reverting to v0.7.2 lua syntax:
curl -sS https://raw.githubusercontent.com/neovim/neovim/v0.7.2/runtime/syntax/lua.vim > $VIMRUNTIME/syntax/lua.vim

while running vba script through cmd prompt getting error [duplicate]

This question already has an answer here:
While Running the vba script i am getting error Microsoft VBScript runtime error: object required : 'DoCmd'
(1 answer)
Closed 8 years ago.
Hi Any one please help me..
while running the vba script i am getting error--object DoCmd need to create.
My script is given below..
ExecuteInsert
Sub ExecuteInsert()
Dim sheetPath
Dim dbs, DbFullName, acc
Set acc = CreateObject("Access.Application")
DbFullName = "D:\G\Diamond\FINAL MS-Access\Demo\MS-Access project.accdb"
Set dbs = acc.DBEngine.OpenDatabase(DbFullName, False, False)
dbs.Execute "Delete from TempRoadMap"
sheetPath = "C:\Users\270784\Desktop\CSPRV scheduled work - 2014 through 1-26-14.xlsx"
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel97, "TempRoadMap", sheetPath, True
MsgBox "Imported Sheet1 from " & sheetPath & " Successfully!"
dbs.Execute "Delete from RoadMap"
dbs.Execute "INSERT INTO [RoadMap] ( Release_Name,SPRF,SPRF_CC,Estimate_Type,PV_Work_ID,SPRF_Name,Estimate_Name,Project_Phase,CSPRV_Status,Scheduling_Status,Impact_Type,Onshore_Staffing_Restriction,Applications,Total_Appl_Estimate,Total_CQA_Estimate,Estimate_Total,Requested_Release,Item_Type,Path) SELECT [TempRoadMap.Release Name], [TempRoadMap.SPRF], [TempRoadMap.Estimate (SPRF-CC)],[TempRoadMap.Estimate Type],[TempRoadMap.PV Work ID],[TempRoadMap.SPRF Name],[TempRoadMap.Estimate Name],[TempRoadMap.Project Phase],[TempRoadMap.CSPRV Status],[TempRoadMap.Scheduling Status],[TempRoadMap.Impact Type],[TempRoadMap.Onshore Staffing Restriction],[TempRoadMap.Applications],[TempRoadMap.Total Appl Estimate],[TempRoadMap.Total CQA Estimate],[TempRoadMap.Estimate Total],[TempRoadMap.Requested Release],[TempRoadMap.Item Type],[TempRoadMap.Path] FROM [TempRoadMap] "
dbs.Close
MsgBox "Done"
End Sub
Assuming that by "...through cmd prompt..." you mean to imply that you are running this script as part of a VBScript file, here are the changes you would want to make:
DoCmd is a child of an Access.Application, and it can only be referenced globally in the scope of an Access database. To reference it in VBScript, you must explicitly use an Access.Application instance, which you have as variable acc. Modify the beginning of the DoCmd line like so:
acc.DoCmd.TransferSpreadsheet
VBScript won't recognize Access constants like acImport or acSpreadsheetTypeExcel97, so you will have to replace them with their actual values. A quick look through msdn reveals that acImport is 0 and acSpreadsheetTypeExcel97 doesn't exist, but acSpreadsheetTypeExcel8 (Excel 97 format) is 8. So now the DoCmd line looks like:
acc.DoCmd.TransferSpreadsheet 0, 8, "TempRoadMap", sheetPath, True
VBScript does not have MsgBox - this is only available through VBA. Instead, you can use Wscript.Echo. For example, the last line would be: WScript.Echo "Done"
If you still have issues after making those changes, please let me know with a comment below.
VBScript certainly does have msgbox and echo is not part of vbscript but of Windows Scripting Host.

Adding image from URL in Word 2011 for Mac OSX using VBA

I am working on porting a project in Windows over to OSX. I have overcome issues with VBA for OSX Word 2011 not allowing you to send POSTs to a server and have figured out how to return a string result from an external script. Now I have to insert an image in my Word file from a URL that is built using the return of my external script.
The current attempt is as follows, and works in Windows but crashes Word in OSX:
Selection.InlineShapes.AddPicture FileName:=File_Name, _
LinkToFile:=False, SaveWithDocument:=True
After doing some research, it looks like MS may have disabled this functionality in OSX as a "security risk". I still need to make it work. Does anybody know of a way within VBA for Office 2011 to make this work, or barring that a workaround? I am trying to avoid writing the image file to the disk if possible.
UPDATE: I have created a Python script for getting the image file from a URL, but I still do not know how to get this image from the Python script into VBA, and from there into the Word document at the location of the cursor. The important bits of the script are below. The image is read in as a PIL object and I can show it using img.show() just fine, but I am not sure what filetype this is or how to get VBA to accept it.
# Import the required libraries
from urllib2 import urlopen, URLError
from cStringIO import StringIO
from PIL import Image
# Send request to the server and receive response, with error handling!
try:
# Read the response and print to a file
result = StringIO(urlopen(args.webAddr + args.filename).read())
img = Image.open(result)
img.show()
except URLError, e:
if hasattr(e, 'reason'): # URL error case
# a tuple containing error code and text error message
print 'Error: Failed to reach a server.'
print 'Reason: ', e.reason
elif hasattr(e, 'code'): # HTTP error case
# HTTP error code, see section 10 of RFC 2616 for details
print 'Error: The server could not fulfill the request.'
print 'Error code: ', e.code
Note that in the above, args.webAddr and args.filename are passed to the script using the argparse library. This script works, and will show the image file that I expect. Any ideas on how to get that image into Word 2011 for OSX and insert it under the cursor?
Thanks a lot!
Edit: updated the link to the project since migrating to github.
Old question, but no answer, and I see the same crash here when the image is at an http URL. I think you can use the following workaround
Sub insertIncludePictureAndUnlink()
' Put your URL in here...
Const theImageURL As String = ""
Dim f As Word.Field
Dim r As Word.Range
Set f = Selection.Fields.Add(Range:=Selection.Range, Type:=wdFieldIncludePicture, Text:=Chr(34) & theImageURL & Chr(34), PreserveFormatting:=False)
Set r = f.Result
f.Unlink
Set f = Nothing
' should have an inlineshape in r
Debug.Print r.InlineShapes.Count
' so now you can do whatever you need, e.g....
r.Copy
Set r = Nothing
End Sub

Mac Office 2011 VBA - calling a server script

I'm porting a large VBA project over from Windows to the new Mac Word 2011. It's actually going very well...almost all of the code is working.
My code needs to call scripts on my server. On Windows, I call the system function InternetOpenUrl to call a script and InternetReadFile to read the results returned by the script. For example, I call a script like:
"http://www.mysite.com/cgi-bin/myscript.pl?param1=Hello&param2=World
and it returns a string like "Success"
What's the best way to do the equivalent on the Mac? Is using Applescript (via the vba MacScript function) the answer? I do that to display the file chooser dialog, but I can't find what the applescript to call an online script would look like. Or is there a better/faster way to do this?
Thanks in advance,
gary
You can try the URL Access Scripting library, which is a front-end for curl, or go to the script via a browser and reading the text through there.
I recently figured this out for making a call to a server to convert a user-defined LaTeX string to an image of the equation. The call is made through VBA via the MacScript command as:
command = "do shell script """ & pyPath & "python " & getURLpath & "getURL.py --formula '" _
& Latex_Str & "' --fontsize " & Font_Size & " " & WebAdd & """"
result = MacScript(command)
Which looks ugly, but this is just building the command do shell script /usr/bin/python {path to script}/getURL.py --formula '{LaTeX formula string}' --fontsize {int} {myurl} and passing it to the command. My Python script then uses argparse to parse the arguments sent to it, and urllib and urllib2 to handle sending the request to the server. The MacScript command read the stdout of my Python script and returns it as a string to result.
This guide on urllib2 should help you get the Python script up and running.
EDIT: Sorry, my answer was incomplete last time. The Python script I used to finish the job is below.
# Import the required libraries
from urllib import urlencode
from urllib2 import Request, urlopen, URLError, ProxyHandler, build_opener, install_opener
import argparse
# Set up our argument parser
parser = argparse.ArgumentParser(description='Sends LaTeX string to web server and returns meta data used by LaTeX in Word project')
parser.add_argument('webAddr', type=str, help='Web address of LaTeX in Word server')
parser.add_argument('--formula', metavar='FRML', type=str, help='A LaTeX formula string')
parser.add_argument('--fontsize', metavar='SIZE', type=int, default=10, help='Integer representing font size (can be 10, 11, or 12. Default 10)')
parser.add_argument('--proxServ', metavar='SERV', type=str, help='Web address of proxy server, i.e. http://proxy.server.com:80')
parser.add_argument('--proxType', metavar='TYPE', type=str, default='http', help='Type of proxy server, i.e. http')
# Get the arguments from the parser
args = parser.parse_args()
# Define formula string if input
if args.formula:
values = {'formula': str(args.fontsize) + '.' + args.formula} # generate formula from args
else:
values = {}
# Define proxy settings if proxy server is input.
if args.proxServ: # set up the proxy server support
proxySupport = ProxyHandler({args.proxType: args.proxServ})
opener = build_opener(proxySupport)
install_opener(opener)
# Set up the data object
data = urlencode(values)
data = data.encode('utf-8')
# Send request to the server and receive response, with error handling!
try:
req = Request(args.webAddr, data)
# Read the response and print to a file
response = urlopen(req)
print response.read()
except URLError, e:
if hasattr(e, 'reason'): # URL error case
# a tuple containing error code and text error message
print 'Error: Failed to reach a server.'
print 'Reason: ', e.reason
elif hasattr(e, 'code'): # HTTP error case
# HTTP error code, see section 10 of RFC 2616 for details
print 'Error: The server could not fulfill the request.'
print 'Error code: ', e.code

Highlight under-cursor code block?

I'm looking for a way to highlight the code block currently under the cursor while in normal mode.
This would work kinda like the set showmatch config options does, but the detection and highlighting would stretch over the entire block.
Any way to achieve this functionality either with config options or a (preferably existing) script ?
Short answer: no.
Long answer: there are ways to achieve this, but you'll have to sacrifice a lot of other fairly essential highlighting features.
There is certainly no way to do it with a simple option. The problem that you may come across is that Vim doesn't allow overlapping regions, so if you have rainbow.vim installed or anything else that makes a region in the area of your block, it's lost. It's also difficult (although I'd welcome any corrections) to have multiple highlighted groups, so one that sets the background colour and another that sets the foreground. This is very limiting as you'll see.
However, if fancy playing around, read on.
I'm making the assumption here that you're using C code in the same coding style as me, but this could easily be changed...
Here's a simple function that should help show you what's involved:
function! HighlightBlock()
" Search backwards and forwards for an opening and closing brace
" at the start of the line (change this according to your coding
" style or how you define a block).
let startmatch = search('^{', 'bcnW')
let endmatch = search('^}', 'cnW')
" Search in the other direction for each to catch the situation
" where we're in between blocks.
let checkstart = search('^{', 'cnW')
let checkend = search('^}', 'bcnW')
" Clear BlockRegion if it exists already (requires Vim 7 probably)
try
syn clear BlockRegion
catch
endtry
" If we're not in a block, give up
if ((startmatch < checkstart) && (endmatch > checkstart))
\ || ((startmatch < checkend) && (endmatch > checkend))
\ || (startmatch == 0)
\ || (endmatch == 0)
return
endif
" Create a new syntax region called "BlockRegion" that starts
" on the specific lines found above (see :help \%l for more
" information).
exec 'syn region BlockRegion'
\ 'start=' . '"\%' . startmatch . 'l"'
\ 'end=' . '"\%' . (endmatch+1) . 'l"'
" Add "contains=ALL" onto the end for a different way of
" highlighting, but it's not much better...
" Define the colours - not an ideal place to do this,
" but good for an example
if &background == 'light'
hi default BlockRegion guibg='#AAAAAA'
else
hi default BlockRegion guibg='#333333'
endif
endfunction
To use the function, source it from somewhere and then create an autocmd to call it whenever something changes, e.g.
au CursorMoved *.c call HighlightBlock()
See the following for some autocommands you may want to consider:
:help CursorHold
:help CursorHoldI
:help CursorMoved
:help CursorMovedI

Resources