PDA

View Full Version : Argument 2 must be of type string :(


rosncrnz
02-13-2006, 05:49 PM
I must first start off by saying I am just a beginner at this programming thing... I used Setup Factory six and had no trouble using it... I am now pulling our media installs forward and finding it difficult. I have gotten a long ways but recently I am having a problem. Here is an example of what I am trying to do (and all the help files/forums say it should work):

DocLocation = INIFile.GetValue(_SourceFolder .. "\\Settings.ini" , "[Documentation]" , "DocLocation");

But later when I try to use 'DocLocation' it comes up empty. So I put a dialog in right after the above line to display a message if it gets an error (right out of the help file) So the code would look like this:


DocLocation = INIFile.GetValue(_SourceFolder .. "\\Settings.ini" , "[Documentation]" , "DocLocation");
if (error ~=0) then
Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
end


At this point, upon running the built exe I get an error "Argument 2 must be of type string" which I have narrowed down to anytime I use Dialog.Message with a Variable in the "message" position.

Can anyone please advise :huh

TJS
02-13-2006, 06:06 PM
Be careful with the dialog.message action. If you are going to use a variable in the message, it has to contain a string. If it contains a table, boolean (true/false) or nil value you will get an error.

In this case, it looks like you haven't populated your error variable with a value yet... so it is currently nil. Try this:

DocLocation = INIFile.GetValue(_SourceFolder .. "\\Settings.ini" , "[Documentation]" , "DocLocation");
if (error ~=0) then
error = Application.GetLastError();
Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
end

BTW, the reason your DocLocation is coming up empty is that you do not need the []'s in your INIFile.GetValue() argument. Try this instead:

DocLocation = INIFile.GetValue(_SourceFolder .. "\\Settings.ini" , "Documentation" , "DocLocation");

rosncrnz
02-13-2006, 06:16 PM
That makes total sense, thank you very much!