* iup.GetFile in FH Plugin Help

For users to report plugin bugs and request plugin enhancements; and for authors to test new/new versions of plugins, and to discuss plugin development (in the Programming Technicalities sub-forum). If you want advice on choosing or using a plugin, please ask in General Usage or an appropriate sub-forum.
Post Reply
User avatar
DavidNewton
Superstar
Posts: 462
Joined: 25 Mar 2014 11:46
Family Historian: V7

iup.GetFile in FH Plugin Help

Post by DavidNewton » 27 Jan 2015 10:26

In the help file for iup.GetFile I am having difficulty understanding the Syntax. The example below it does not seem to match.

I would welcome some expert help

My best guess is that it should read

Code: Select all

strFileName, strReturn = iup.GetFile(strFileName)
or possibly this

Code: Select all

strEndingText, strReturn = iup.GetFile(strStartingText)
I have searched the Forums and Knowledgebase and found no definitive answer.

Coul

User avatar
tatewise
Megastar
Posts: 27089
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: iup.GetFile in FH Plugin Help

Post by tatewise » 27 Jan 2015 11:07

[EDIT: See later explanation of where the SYNTAX problem exists in the FH Help page.]

The IUP syntax for Lua does need a little interpretation, but you have effectively got it correct.
The -> symbol means "these are the output parameters".
Each input and output parameter has a bold name (but you can use any valid variable name) followed by a type specifier such as 'string' or 'number'.

Follow the Browse for Example Files link and select Lua/, then look for a Name that might match, and in this case getfile.lua is best.

This worked for me:

Code: Select all

require "iuplua"      -- not strictly needed
strFileName = "*.*"   -- string needs value else get 'bad argument #1'
strFileName, intStatus = iup.GetFile(strFileName)
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
DavidNewton
Superstar
Posts: 462
Joined: 25 Mar 2014 11:46
Family Historian: V7

Re: iup.GetFile in FH Plugin Help

Post by DavidNewton » 27 Jan 2015 11:39

Thanks for the reply Mike. Comparing my guess with your example I think the main difference is that my strReturn should be intReturn to identify that the return is an integer not a string.

David

Added in Edit: the evidence suggests that the syntax in the FH help file is in fact incorrect. The interpretations of the returns are correct. I would speculate that the help file page is an incomplete rewrite.

User avatar
tatewise
Megastar
Posts: 27089
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: iup.GetFile in FH Plugin Help

Post by tatewise » 27 Jan 2015 12:11

David, in Lua the name syntax of all the variables is irrelevant.
I only used intStatus as an aide memoir to remind me it is an integer number.
If as I suggested you browse to the example getfile.lua file it uses:
f, err = iup.GetFile("*.txt")
Your variable names will work OK - what problem did you experience running your script?

You would do well to study the plugins:index|> Family Historian Plugins Developer Guide.
In particular plugins:getting_started|> Getting Started Writing Plugins and the Lua Language References.
Quote from Lua 5.1 Ref Manual: 2.2 Values and Types: "variables do not have types; only values do".
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
DavidNewton
Superstar
Posts: 462
Joined: 25 Mar 2014 11:46
Family Historian: V7

Re: iup.GetFile in FH Plugin Help

Post by DavidNewton » 27 Jan 2015 12:41

Mike, sorry to give the impression that I have a problem writing a specific script. I am still in the early stages of using iup and what i am doing is working through the iup section in the help file to try and get a feel for what is possible and to ensure that I understand the syntax. I know that indicating type in variable names is totally optional but at the learning stage it is useful.

David

User avatar
tatewise
Megastar
Posts: 27089
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: iup.GetFile in FH Plugin Help

Post by tatewise » 27 Jan 2015 13:02

No, I must apologise David, I misunderstood your orginal query, and now have identified the problem.

You were NOT talking about the IUP online documentation syntax, but the FH Tools > Plugins > How to Write Plugins > Create User Interfaces with IUP > iup.GetFile page.

Yes, it does have a SYNTAX mistake and should read:
strFileName, strReturn = iup.GetFile(strFileName)
but as discussed above intReturn would be better!

I think the strEndingText and strStartingText come from a cut & paste from iup.GetText.

I shall add this Help mistake to the list for Calico Pie to fix.

I also plan to redact the earlier dialogue to make it clearer where the problem lies.
Is that OK David?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

Post Reply