Author Topic: EZGPIB - return a value in functions  (Read 4449 times)

0 Members and 1 Guest are viewing this topic.

Offline peluleTopic starter

  • Frequent Contributor
  • **
  • Posts: 513
  • Country: de
  • What is business? It’s other people’s money
EZGPIB - return a value in functions
« on: January 31, 2016, 12:52:47 pm »
Hi I have opened a new topic, hope did it at the correct group.
Short description of EZGPIB:
EZGIP is a Windows running free PASCAL like script processing software to control tools via VISA/GPIB/RS232 easily. It does not create an executable.
The creator of that sw unfortunately passed away, but that tool is still in use in the community.


My question: is EZGPIB unable, to return a value of a function?
When i detected that issue, I used a simple in PASCAL fully correct test function
Quote
Function fAdd (A, B : Integer) : Integer;
Begin
 fAdd := A + B;
        ^position of 1st error
End;
EZGPIB stops at marked position and claims "invalid number of parameters"
Anyone, having experiance with EZGPIB, able to confirm my finding & conclusion?
BR
PeLuLe
You will learn something new every single day
 

Offline Earendil

  • Regular Contributor
  • *
  • Posts: 102
  • Country: hu
Re: EZGPIB - return a value in functions
« Reply #1 on: January 31, 2016, 03:50:15 pm »
What happens if instead of  fAdd := A + B; you write Result := A + B; ?
I would also try declaring the function this way: Function fAdd (A : Integer; B : Integer) : Integer;
 

Offline peluleTopic starter

  • Frequent Contributor
  • **
  • Posts: 513
  • Country: de
  • What is business? It’s other people’s money
Re: EZGPIB - return a value in functions
« Reply #2 on: January 31, 2016, 05:43:43 pm »
Thanks for the tip.
Will try and report the findings...

PeLuLe
You will learn something new every single day
 

Offline edpalmer42

  • Super Contributor
  • ***
  • Posts: 2260
  • Country: ca
Re: EZGPIB - return a value in functions
« Reply #3 on: January 31, 2016, 05:45:08 pm »
Did you look through the example programs for a similar function?

 

Offline peluleTopic starter

  • Frequent Contributor
  • **
  • Posts: 513
  • Country: de
  • What is business? It’s other people’s money
Re: EZGPIB - return a value in functions
« Reply #4 on: January 31, 2016, 06:15:52 pm »
Quote
Did you look through the example programs for a similar function?
Yepp, that was the first I checked, as I thought it may a user failure. But I found no example using a function returning a value.
Aslo check the manual. Doid not find any information on.
Thus my question to the community...

EZGPIB is actual running on a measurment log (noise measure) so need to wait to test the tip, until finished.

PeLuLe
You will learn something new every single day
 

Offline edpalmer42

  • Super Contributor
  • ***
  • Posts: 2260
  • Country: ca
Re: EZGPIB - return a value in functions
« Reply #5 on: January 31, 2016, 07:34:35 pm »
This doesn't look right, but it works.  EZGPIB uses a 'magic' variable called Result to return results from a function - it's shown in some of the examples.  Not sure why you can't specify the calling parameters.  I think that the Pascal engine in EZGPIB is Remobjects ( http://www.remobjects.com/ps.aspx ) with some custom extensions.  I don't know if there's any documentation on the specific syntax for Remobjects.  I do know that there are some errors in the syntax of the extensions - things like commas and semicolons, so step carefully.

If you want to run a second copy of EZGPIB, just do it.  As long as you're not fighting for specific hardware, I think it works okay.  Worst case, copy the relevant files to a different directory and run the second copy from there.

Code: [Select]
Program TestFunction;
Const
  A = 2;
  B = 9;
 
Function fAdd : Integer;
Begin
 Result := A + B;
End;

 Begin
 EZGPIB_ScreenWriteln(fAdd);
End.
 

Offline peluleTopic starter

  • Frequent Contributor
  • **
  • Posts: 513
  • Country: de
  • What is business? It’s other people’s money
Re: EZGPIB - return a value in functions
« Reply #6 on: January 31, 2016, 08:12:16 pm »
Great tips and good hint for the scripting source (May help in future for specific issues).

The "Result" as function return value work, have noted in my manual printout.

I guess they did it as a quick solution without having problems on type checking and stack manipulation.
That's not trivial as I know (have written C and PASCAL compiler in my early times myself).

BR
PeLuLe

You will learn something new every single day
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf