How to change value in a QTP data table? - vbscript

Could anyone help me figure out how to enter a value into a QTP data table using VBScript? I'm trying the following line, but it doesn't seem to work:
datatable.Value(D,"sheetName")="A"
What is wrong? I am used to other languages and just cannot see any problem here.

What is the D you're using? Is it a variable holding the column name? If not and you mean to use the D column then you have to quote it so that QTP (VBScript actually) knows you mean the string "D".
datatable.Value("D","sheetName")="A"

I know zilch about QTP tool. However, your syntax looks correct based on this example. (see heading Adding Value to you a local sheet
Based on the information given, I would take a stab that you may have not referenced the QTP DLL, you have ON ERROR RESUME NEXT in your code AND you do not have OPTION EXPLICIT set at the top of your module.
Start by making sure you have the correct DLL referenced and adding this line to the top of the code:
OPTION EXPLICIT
If you've done that, then add more information that could help one deduce the problem (e.g. full code sample).

The way that you get data from datatable in QTP is, first import the Excel sheet into your datatable (Either Global or Local), then try to get data from datatable using following Syntax
Datatable(columnName,dtGlobalSheet) if imported in Global sheet
Datatable(columnName,dtLocalSheet) if imported in Local sheet
Importing Data
myFile = "C:\datasheet\excelone.xls"
datatable.Importsheet myFile,1,Global
Enter Value
DataTable("Coumn1Data", dtGlobalSheet)
This way you can get data from Excel sheet.
Thanks,
Karthik

Related

Power Automate create folder from excel cell

I'm trying to create a folder as part of a flow, based upon an excel cell value.
The flow works if I use a cell value from the excel sheet that is a straight value such as "Folder 1", but just comes up blank when I use a cell that is a formula such as "=B2 & " RFE " & ROW(2:2)".
Is there a way to get past this? Am I right in thinking that it's not working because I'm referencing a formula and not a value?
I can't speak to your flow specifically and the issue you're seeing with the way you're retrieving that value (you haven't shown it) but another way to pull data from Excel and be a lot more specific about it is to use Office Scripts.
If you've never used them before, this can help you get started.
https://support.microsoft.com/en-us/office/introduction-to-office-scripts-in-excel-9fbe283d-adb8-4f13-a75b-a81c6baf163a#:~:text=Getting%20started,steps%20you%20want%20to%20automate.
In relation to a script that can help you, if you create a new script called Get Cell Value and paste this code in ...
function main(workbook: ExcelScript.Workbook, worksheetName: string, cellAddress: string)
{
return workbook.getWorksheet(worksheetName).getRange(cellAddress).getText();
}
... you can then call it from PowerAutomate and it will give you the right answer.
You can see in my example, the first cell is a formula. From PowerAutomate using the Run script action, it works as expected.
You can then use the resulting value to create your folder.

cypress:Allow reading non-existent files in cy.readFile

I have dropdown with many items which is coming from an other module first column.
so,Those column value is created dynamically.I am trying to write those column values in JSON file so that i can click on the dropdown item without hardcoding.Before writing I am reading file using readfile() but that file does not exist for the first time so how to check if cypress/fixtures/xxx.json file exist before writing into it.Any help is appreciated.Thanks in advance.
I'm facing a similar issue and I see that cy.readfile() fails if file doesn't exist so cypress docs suggests using cy.task() to read a file that may not exist and I think we can use cy.task() so that if the file doesn't exist we create an empty file, this is the idea and I'll try implementing it and share code.
Reference

XPath query for importing web content

Can anyone please suggest how to import '500112' and 'SBIN' from https://www.moneycontrol.com/india/stockpricequote/banks-public-sector/statebankindia/SBI in Google spreadsheet using importData or importXML functions?
Try using
=IMPORTXML(A1,"//ctag[#class='mob-hide']//span") #where A1 is the url
this should get you both.
adding, for example:
=IMPORTXML(A1,"//ctag[#class='mob-hide']//span[1]")
at the end should output just
500112
Edit:
Since the question was asked, the site started using dynamically loaded data which GS can't handle. Using the tools in your browser's Developer tab, you can find out that the target data is loaded from a different site (see below) and that it is in json format.
So you need to use GS's importJSON() function for that:
A1 = https://priceapi.moneycontrol.com/pricefeed/bse/equitycash/SBI
A2 =importJSON(A1)
Make sure there's enough space on the sheet to expand the output. Once you do, you'll find the two target items under the columns Data Bseid and Data Nseid, probably in columns AL and AM.

How to get entry text in glade3 in Ruby?

Its first my first time in stackoverflow to get help.
Im making a Ruby GUI with glade3, but i dont really now how to get texts from an entry box?
It should read the text from entry box and write it in an excel sheet.
I hope you can help me :)
See example here: https://xrob.wordpress.com/2007/04/20/creating-a-gui-application-using-glade-and-ruby/
We want to change something in the application so we will need to assign a variable to the widget that we want to alter. We want to alter “label1” and so we insert this code in the button1_clicked function.
#myEntryBox = #glade.get_widget(“myEntryBox”)
# You can now access properties like '#myEntryBox.text'
# Refer to documentation for exact name of the attribute

Pass variable and its contents from workspace to GUI function in MATLAB

I have a variable in the MATLAB workspace and I want to pass the variable name and its contents to a function in my GUI.
How do I achieve this task?
I'm not totally sure what you mean when you say "pass the variable name and its contents", but here's one possible solution. After you pass a set of data to a function like so:
some_function(data); %# Pass the variable "data" to a function
You can get the variable name of the input argument from inside the function using INPUTNAME:
function some_function(inputArgument)
name = inputname(1); %# Will return "data" as the name of the input variable
end
EDIT: As pointed out in a comment by High Performance Mark, the variable inputArgument inside the function will contain the values stored in the variable data in the workspace of the caller.
If this question is related to your other most recent question, then why not build the operation into your GUI? You can use guide to create a pushbutton, and place the code under the callback function.
I am assuming that you have created the figure with GUI using the GUIDE, and that you know the 'Tag' names of the GUI objects.
((1)) Open the figure using the GUIDE, ((2)) Open the Property Inspector for the figure (select the background, the light-gray gridded area of the figure, and double-click over it, to make the Property Inspector for the figure to pop-up), ((3)) Turn the 'HandleVisibility' 'on' (by default, it may be set as 'callback'), ((4)) Save the figure and close the GUIDE, and finally ((5)) set the GUI property values from the MATLAB Console (or "Command Window") using some parameters that are currently available on your workspace.
I hope this helps.
Best,
Y.T.

Resources