I am using VTS tables for passing data from 1 script to other. Now, I want to get data from all the column for particular row and print that.
I tried couple of VTC commands but unfortunately that did not work.
Command I tried:-
rc = lrvtc_query_row(vuser);
lr_output_message("Col1:- %s", lr_eval_string("{Col1}"));
can you please suggest where I got wrong or provide me a ready code to print he Row from the VTS table.
First you have to enable API access by click the "Enable" button from VTS Web Admin page, then here's the sample:
Action()
{
char* vts_ip = "127.0.0.1";
int vts_port = 8888;
char **colNames = NULL;
char **rowData = NULL;
int row_index = 1;
int i;
PVCI2 pvci = vtc_connect(vts_ip, vts_port, VTOPT_KEEP_ALIVE );
vtc_query_row(pvci, row_index, &colNames, &rowData);
for(i=0; colNames && colNames[i]; ++i){
lr_output_message("%s: %s", colNames[i], rowData[i]);
}
vtc_free_list(colNames);
vtc_free_list(rowData);
return 0;
}
Related
I made a small search box to retrieve values from a datasheet. For some reason it only loops once. Also this is the first time I'm trying something in google sheets, so if I want to search a string in column B, then the SEARCH_COL_IDX should be 1 right?
I put in a few loggers to check the process. I do see Logger.log(str), Logger.log("Check") and Logger.log("Check2). The latter two only once, where it should be multiple times imo. The Logger.log(row[#]) I don't get to see at all, which means it doesn't find anything.
I also tried doing if(row[SEARCH_COL_IDX] = str) { to see where it is looking. Than the Logger.log(row[#]) do come back, but from different rows AND columns. I am doing something wrong, but I can't find it.. any suggestions?
var SPREADSHEET_NAME = "Database";
var SEARCH_COL_IDX = 1;
var RETURN_COL_IDX= 1;
function searchStr(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var formSS = ss.getSheetByName("Userform");
var str = formSS.getRange("d17").getValue();
Logger.log(str);
var values = ss.getSheetByName("Database").getDataRange().getValues();
for (var i = 0; i < values.length; i++) {
Logger.log("check");
var row = values[i];
Logger.log("check2");
if(row[SEARCH_COL_IDX] == str) {
formSS.getRange("d3").setValue(row[0]);
Logger.log(row[0]);
formSS.getRange("d5").setValue(row[1]);
Logger.log(row[1]);
formSS.getRange("d7").setValue(row[2]);
Logger.log(row[2]);
formSS.getRange("d9").setValue(row[3]);
Logger.log(row[3]);
formSS.getRange("d11").setValue(row[4]);
Logger.log(row[4]);
formSS.getRange("d13").setValue(row[5]);
Logger.log(row[5]);
}
Logger.log("nothing found");
return row[RETURN_COL_IDX];
}
Your function has a return command in the last line of your loop block.
I looping through a table and looping through the data of those table in order to compare them. However, I am trying to use break if one of the table data doesn't match to prevent further checking.
I run into a problem here because the break is going to happen inside cy.then, which doesn't work. So now I am trying to find a way to allow the cy.then to set the value then proceed to synchronously check everything else.
Here is what I have tried so far to no avail
cy...then((body)=>{
for (let row = 0; row < body.length; row++) {
//Body is the table, and we get the table len
for (let col = 0; col < 4; col++) {
//Begin looping thru each row's col and compare
// Here I attempt to create sync code because I want to not continue
// to loop thru all 4 col if one doesnt match
let val;
new Cypress.Promise((resolve)=>{
cy.get('...').eq(row)...eq(col).then((txt)=>{
val = txt
resolve(txt
})
})
//Begin to compare using val and break child loop if needed
}
}
})
I keep getting val as undefined. I am new to cypress so any pointers would be cool.
Thanks.
What I have tried pt2:
Using async/await in at
cy...then(async(body)
and awaiting the cypress promise, gets a timeout 4000ms error, increased timeout to 10000ms and still timed out.
Edit: According to your answer, if your code is correct, you can use a should instead of then, because of possible retriability:
cy...should((body)=>{ //over here
for (let row = 0; row < body.length; row++) {
//Body is the table, and we get the table len
for (let col = 0; col < 4; col++) {
//Begin looping thru each row's col and compare
// Here I attempt to create sync code because I want to not continue
// to loop thru all 4 col if one doesnt match
let val;
new Cypress.Promise((resolve)=>{
cy.get('...').eq(row)...eq(col).should((txt)=>{ //or over here
val = txt
resolve(txt
})
})
//Begin to compare using val and break child loop if needed
}
}
})
The cypress cy.type({enter} fails when I use this in a for loop to enter multiple data in text field. If I have to enter only one value then in that case that works.
Please suggest me some solution for this. Here is my code :-
value = cat, bat, mice, fox
enterMultipleValue(value) {
var val = value;
var val_str = val.split(",");
for (var i = 0; i < val_str.length; i++) {
cy.get('input[mat-option="text"]')
.type(val_str[i]+"{enter}", { force: true });
// .wait(3000)
// .type('{enter}');
}
}
The code works ok, but what do you want to see?
const value = "cat, bat, mice, fox"
const vals = value.split(",");
for (var i = 0; i < val_str.length; i++) {
cy.get('input[mat-option="text"]')
.type(val_str[i]+"{enter}")
.wait(3000)
.type('{enter}');
}
This shows "cat bat mice fox" in the input box.
If you want to see them one at a time, add a .clear() command
const value = "cat, bat, mice, fox"
const vals = value.split(",");
for (var i = 0; i < val_str.length; i++) {
cy.get('input[mat-option="text"]')
.type(val_str[i]+"{enter}")
.wait(3000)
.clear();
}
This shows each one for 3 seconds, then the next, etc.
But is this a select box? mat-option is used on an Angular Material Select. Are you trying to do a multiple-select?
I've been trying to export the content data of my ListView control into an Excel application using C#. I've already done this before using VB.NET and I tried to convert my code to C# but it failed but I made a modification on it and seems everything is fine on code below except for the last part which to save the data as an excel file. I need an assistance to modify this code correctly. I would greatly appreciate your helpful response.
The code below that got an error is:
oBook.SaveAs(SaveFileDialog1.InitialDirectory.ToString() + SaveFileDialog1.FileName);
Error 5 No overload for method 'SaveAs' takes '1' arguments
private void Button4_Click(object sender, System.EventArgs e)
{
int row = 0;
int col = 0;
int row2 = 0;
int col2 = 0;
int ch = 0;
int ctr = 0;
ctr = 0;
row2 = 1;
col2 = 3;
row = 3;
col = 3;
Microsoft.Office.Interop.Excel.Application oExcel = new Microsoft.Office.Interop.Excel.Application();
oExcel.Visible = false;
Microsoft.Office.Interop.Excel.Workbook oBook = oExcel.Workbooks.Add(Microsoft.Office.Interop.Excel.XlSheetType.xlWorksheet);
Microsoft.Office.Interop.Excel.Worksheet oSheet = (Microsoft.Office.Interop.Excel.Worksheet)oExcel.ActiveSheet;
SaveFileDialog SaveFileDialog1 = new SaveFileDialog();
SaveFileDialog1.Filter = "Excel File|*.xlsx|Word File|*.doc|Text File|*.txt";
SaveFileDialog1.Title = "Save As";
if (SaveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
switch (SaveFileDialog1.FilterIndex)
{
case 1:
{
for (ch = 1; ch <= ListView1.Columns.Count; ch++)
{
oSheet.Cells[row2, col2] = ListView1.Columns[ctr].Text;
col2 = col2 + 1;
ctr = ctr + 1;
}
foreach (ListViewItem lview in ListView1.Items)
{
foreach (ListViewItem.ListViewSubItem lview2 in lview.SubItems)
{
oSheet.Cells[row, col] = lview2.Text;
col = col + 1;
}
col = 3;
row = row + 1;
}
oBook.SaveAs(SaveFileDialog1.InitialDirectory.ToString() + SaveFileDialog1.FileName);
oExcel.Quit();
SaveFileDialog1.Dispose();
MessageBox.Show("Data has been successfully saved", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information);
break;
}
}
The workbook SaveAs method takes 11 parameters. In C# you have to pass something for these optional parameters even if you do not care about them. The easiest thing to do here is pass System.Reflection.Missing.Value for those you do not care about. It is a pain though.
I have a list of items (potentially large) from which the user must select one. I'd like to allow the user to type the first few letters of the desired item to jump to the correct place in the list. By default, each keypress jumps to the first item starting with that letter, so you can't type the first several letters. Is there any straightforward way to do this? Any CodeProject or other such example?
I've looked for hours, and found any number of samples for IAutocomplete, but that won't help here because I need to guarantee that the result is in the list.
The only way I can think to do this is to derive from CListBox, capture the keystrokes myself, find the item, run a timer so that new keystrokes after a sufficient pause will start a new search... since I'm not an MFC jock, this is daunting. Any tips much appreciated.
One clarifying note: my ultimate goal is actually to get this keyboard behavior for a ComboBox of DropDownList style (i.e. no edit box). The lack of an edit box rules out most autocomplete code, and the need for ComboBox functionality means I can't use CListCtrl by itself.
After much unnecessary pain, I've discovered that the real correct answer is simply to use LBS_SORT. Simply by specifying this style, the basic vanilla listbox supports the incremental search keyboard shortcut style I wanted. Without LBS_SORT (or CBS_SORT for a combobox), you get the irritating and almost-useless jump-to-first-letter-only behavior. I didn't try LBS_SORT because my list contents were added in sorted order anyway.
So the dozen or so hours of investigating custom controls, etc., all for naught because the Microsoft documentation makes no mention of this important behavioral difference in the description of LBS_SORT!!
Thanks to everyone who contributed.
I've implemented such a functionality in core Win32. Heres the code.
Somewhere in your message loop that processes the list box insert:
switch(message)
{
case WM_CHAR:
if(HandleListBoxKeyStrokes(hwnd, wParam) == FALSE)
return FALSE;
....
Heres the code (propably not fully complete):
/* ======================================================================== */
/* ======================================================================== */
#define RETURNr(a, b) // homegrown asserts
BOOLEAN HandleListBoxKeyStrokes(HWND hwnd, UINT theKey)
{
#define MAXCHARCACHEINTERVALL 600.0 // Max. milisecs time offset to consider as typed 'at once'
static char sgLastChars[255] = {'0'};
static double sgLastCharTime = 0.;
static HWND sgLasthwnd = NULL;
if(GetSecs() - sgLastCharTime > MAXCHARCACHEINTERVALL ||
sgLasthwnd != hwnd)
*sgLastChars = 0;
if(theKey == ' ' && *sgLastChars == 0)
return TRUE;
sgLastCharTime = GetSecs();
sgLasthwnd = hwnd;
AppendChar(sgLastChars, toupper(theKey));
if(strlen(sgLastChars) > 1)
{
LONG l = GetWindowLong(hwnd, GWL_STYLE);
Char255 tx;
GetClassName(hwnd, tx, sizeof(tx));
if( (! stricmp(tx, "Listbox") &&
! (l & (LBS_EXTENDEDSEL | LBS_MULTIPLESEL)) ) ||
(! stricmp(tx, "ComboBox") && // combo Box support
l & CBS_DROPDOWNLIST &&
! (l & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) ) )
{
long Count, l, BestMatch = - 1, BestMatchOff = 0;
long LBcmdSet[] = {LB_GETCOUNT, LB_GETTEXTLEN , LB_GETTEXT};
long CBcmdSet[] = {CB_GETCOUNT, CB_GETLBTEXTLEN, CB_GETLBTEXT};
long *cmdSet = (! stricmp(tx, "ComboBox")) ? CBcmdSet : LBcmdSet;
RETURNr((Count = SendMessage(hwnd, cmdSet[0], 0, 0)) != LB_ERR, 0);
for(int i = 0; i < Count; i++)
{
RETURNr((l = SendMessage(hwnd, cmdSet[1], i, 0)) != LB_ERR, TRUE);
RETURNr( l < sizeof(tx), TRUE);
RETURNr((l = SendMessage(hwnd, cmdSet[2], i, (LPARAM)&tx)) != LB_ERR, TRUE);
strupr(tx);
if(! strncmp(tx, sgLastChars, strlen(sgLastChars)))
{
SelListBoxAndNotify(hwnd, i);
return FALSE;
}
char *p;
if(p = strstr(tx, sgLastChars))
{
int off = p - tx;
if(BestMatch == -1 || off < BestMatchOff)
{
BestMatch = i;
BestMatchOff = off;
}
}
}
// If text not found at start of string see if it matches some part inside the string
if(BestMatch != -1)
SelListBoxAndNotify(hwnd, BestMatch);
// Nothing found - dont process
return FALSE;
}
}
return TRUE;
}
/* ======================================================================== */
/* ======================================================================== */
void SelListBoxAndNotify(HWND hwnd, int index)
{
// i am sorry here - this is some XVT-toolkit specific code.
// it has to be replaced with something similar for native Win32
WINDOW win = xvtwi_hwnd_to_window(hwnd);
WINDOW parent = xvt_vobj_get_parent(win);
xvt_list_set_sel(win, index, 1);
EVENT evt;
memset(&evt, 0, sizeof(evt));
evt.type = E_CONTROL;
evt.v.ctl.id = GetDlgCtrlID(hwnd);
evt.v.ctl.ci.v.lbox.dbl_click = FALSE;
xvt_win_dispatch_event(parent, &evt);
}
/* ======================================================================== */
/* ======================================================================== */
double GetSecs(void)
{
struct timeb timebuffer;
ftime(&timebuffer);
return (double)timebuffer.millitm +
((double)timebuffer.time * 1000.) - // Timezone needed for DbfGetToday
((double)timebuffer.timezone * 60. * 1000.);
}
/* ======================================================================== */
/* ======================================================================== */
char AppendChar(char *tx, char C)
{ int i;
i = strlen(tx);
tx[i ] = C;
tx[i + 1] = 0;
return(C);
}
Can you use a CListView CListCtrl instead? They work like that by default.