Forum Replies Created
-
AuthorPosts
-
Hi Tony,
What version of HTBasic are you using and what driver are you loading (GPIBNI or VISA)? Could you also show us what you are using in your LOAD BIN statement?
Thanks,
Pat
Hi Dongxu,
I setup a similar test where I created an unmanaged C++ dll and from it called into a managed C# dll. Loading the unmanaged C++ dll from HTBasic and calling the unmanaged function that calls into the managed dll, I was able to reproduce the same exception you are seeing. I have spent some time looking into it and finally found a solution. There were two steps I needed to take before i was able to call the unmanaged dll function from HTBasic successfully.
First, make sure that your unmanaged DLL and Managed DLL are both targeting x86 since that is what HTBasic targets.
Second, put the managed dll into the same folder that the HTBwin.exe file is in.
Hopefully this will allow it to work for you.
Thanks,
Pat
Here is a simple program that simply loads the VISA driver for the instrument at ASRL3::INSTR. It outputs *IDN to the instrument and then enters the response and stores it in a string variable. Finally it prints out the returned value in the string variable.
LOAD BIN "VISA;DEV ASRL3::INSTR ISC 7" OUTPUT 7;"*IDN?"; ENTER 7;S$ PRINT "The connected device is: ",S$ ENDAn alternative to loading the driver in code is to use the Device Setup under the tools menu.
Hi ZeRider,
I wanted to see if I could reproduce the failure at line 16379. Using your program in HTBasic 2021 I could not get it to fail. It completed successfully every time. I did see that you were using HTBasic 10.0 and HTBasic 10.1 so I tried those versions and immediately get an error in each and they shutdown which is very odd. If I get the time I will look into it, although since it works fine in our latest release, my recommendation is to use it.
Ralphs suggestion is a good one and will be much faster than going through Excel, but if you need to go through Excel for some reason, I would recommend using HTBasic 2021.
Concerning how I entered my code in my post, I use the HTML CODE tags provided on the toolbar above and put my code between them.
If you do get a copy of HTBasic 2021, I would be interested to know if HTBDDE works successfully for you, or you still hit the same issue.
Thanks!
Hi ZeRider,
I put together a sample program and a sample excel file to try and reproduce the issue you are seeing above. I am able to consistently read all 200 rows of 259 cells. The difference could be in the data being read in since I am not certain the format of your data. Here is a link to the excel file I am using:
And here is my sample program:
my sample program:
CONFIGURE LONGFILENAMES ON DLL UNLOAD ALL LONG Hconvexcel! Excel conversation handle LONG Retval ! Return value for the DLL functions DLL LOAD "HTBdde" DLL GET "LONG HTBdde:Ddeconnect" DLL GET "SHORT HTBdde:Ddeterminate" DLL GET "LONG HTBdde:Ddetimeout" DLL GET "SHORT HTBdde:Ddeexecute" DLL GET "SHORT HTBdde:Ddepoke" DLL GET "CHARPTR HTBdde:Dderequest" DLL GET "SHORT HTBdde:Runexe" ! Connect to the Excel System topic Hconvexcel=FNDdeconnect("Excel","System") IF Hconvexcel=0 THEN ! If we couldn't connect, lauch Excel and try again Retval=FNRunexe("C:\Program Files\Microsoft Office\root\Office16\Excel.exe",1) WAIT 2 Hconvexcel=FNDdeconnect("Excel","System") ! If we still couldn't connect, Exit IF Hconvexcel=0 THEN GOTO Exit END IF ELSE ! Create a new workbook Retval=FNDdeexecute(Hconvexcel,"[Open(""C:\Program Files (x86)\HTBasic 2021\DLL Toolkit\Samples\HTBDde\sample.xlsx"")]") IF NOT Retval THEN PRINT "didn't open" GOTO Exit END IF ! END IF IF Hconvexcel=0 THEN GOTO Exit END IF DIM C$[20] DIM Return$[50] DIM Data$(1:200,1:259)[20] Row$="L" Total=0 FOR Line=1 TO 200 FOR Column=1 TO 259 C$="" C$=Row$&VAL$(Line)&"C"&VAL$(Column) Return$="" Return$=FNDderequest$(Hconvexcel,C$) Total=Total+1 Data$(Line,Column)=Return$ DISP Total,C$,Data$(Line,Column) NEXT Column NEXT Line PRINT "Finished" Exit:! ! Terminate the connection with Excel IF (Hconvexcel) THEN Retval=FNDdeterminate(Hconvexcel)!Terminate the excel DDE conversation END IF ! Unload the DDE DLL DLL UNLOAD "HTBdde" ENDThe latest released version of HTBasic 2021 now contains a native VISA driver. This can be loaded in Device Setup and will allow you to communicate with instruments natively in HTBasic using standard ENTER and OUTPUT statements, greatly simplifying your programming.
-
AuthorPosts