Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 10 of 10
  1. #1
    Join Date
    Oct 2004
    Location
    East, South & West Asia
    Posts
    1,020

    Reiteration Issue

    Hi,

    I am stuck with REITERATION. I can't find anything wrong with this set of codes but it won't work.

    Code:
    	local tMyStringValue = {sEmail,sPhone1,sPhone2,sHomeAddress,sHomeCity};
    
    	-- step through fields table
    	for nMyValueIndex, sMyStringValue in tMyStringValue do
    		-- Check for blanks and change it to "-"
    		if sMyStringValue == "" or sMyStringValue==nil then
    		   sMyStringValue = " - ";
    		end
    	end
    When I used IF...END for each field, it works. I have about 20 fields to reiterate, hence not economical to apply IF END for every field.

    What could possibly be wrong with the Code above?

    Thanks
    Last edited by azmanar; 12-29-2005 at 10:30 AM. Reason: missed

  2. #2
    Join Date
    Jan 2000
    Posts
    2,002
    You will need to assign the value back to the original table. I imagine that the iterator is by value, not reference. I have not tried it, but what about:

    Code:
    local tMyStringValue = {sEmail,sPhone1,sPhone2,sHomeAddress,sHomeCity};
    
    -- step through fields table
    for nMyValueIndex, sMyStringValue in tMyStringValue do
    	-- Check for blanks and change it to "-"
    	if sMyStringValue == "" or sMyStringValue==nil then
    	   tMyStringValue[nMyValueIndex] = " - ";
    	end
    end

  3. #3
    Join Date
    Oct 2004
    Location
    East, South & West Asia
    Posts
    1,020

    Error Prompt

    Quote Originally Posted by Brett
    You will need to assign the value back to the original table. I imagine that the iterator is by value, not reference. I have not tried it, but what about:

    Code:
    local tMyStringValue = {sEmail,sPhone1,sPhone2,sHomeAddress,sHomeCity};
    
    -- step through fields table
    for nMyValueIndex, sMyStringValue in tMyStringValue do
    	-- Check for blanks and change it to "-"
    	if sMyStringValue == "" or sMyStringValue==nil then
    	   tMyStringValue[nMyValueIndex] = " - ";
    	end
    end
    Using tMyStringValue[nMyValueIndex] I got an ERROR immediately, with the following message:

    ATTEMPT TO INDEX LOCAL "myStringValue" , (a string value).

    What does it mean?

  4. #4
    Join Date
    Jan 2000
    Posts
    2,002
    You probably did:

    sMyStringValue[nMyValueIndex] = " - ";

    instead of:

    tMyStringValue[nMyValueIndex] = " - ";

  5. #5
    Join Date
    Oct 2004
    Location
    East, South & West Asia
    Posts
    1,020

    Corrected as adviced

    Quote Originally Posted by Brett
    You probably did:

    sMyStringValue[nMyValueIndex] = " - ";

    instead of:

    tMyStringValue[nMyValueIndex] = " - ";
    Indeed. I made the mistake and corrected it as adviced. No error prompt occurred.

    However, the empty fields refused to change to "-" or to whatever I tried.

    So I setup a dialog.message prompt for each fields during the iteration to be sure it has no value. Yup, the fields has no value, yet it will not change as intended.

    Any other cause of such problem?

  6. #6
    Join Date
    Jan 2000
    Posts
    2,002
    Have you tried using String.Length() to determine if the string is empty? Maybe you could post a full set of code that we could test here. Perhaps dumb down the code into a small example that illustrates the problem.

  7. #7
    Join Date
    Oct 2004
    Location
    East, South & West Asia
    Posts
    1,020
    Quote Originally Posted by Brett
    Have you tried using String.Length() to determine if the string is empty? Maybe you could post a full set of code that we could test here. Perhaps dumb down the code into a small example that illustrates the problem.
    Hi,

    I will try with String.Length(). Then I will follow up here.

    Anyway, your tip here solved my other problem related to a ComboBox. hehehe.

    Thanx

  8. #8
    Join Date
    Oct 2004
    Location
    East, South & West Asia
    Posts
    1,020
    Quote Originally Posted by azmanar
    Hi,

    I will try with String.Length(). Then I will follow up here.

    Anyway, your tip here solved my other problem related to a ComboBox. hehehe.

    Thanx
    Hi,

    I tested with the following and it too doesn't work. Probably, my variables that follows the function are incorrect. I will try until I can resolve it.

    Code:
    			-- step through required fields table
    				for nMyValueIndex, sMyStringValue in tMyStringValue do
    				-- Check that required fields are blank and variables are nil
    				nCheckStringLength = String.Length(tMyStringValue[nMyValueIndex]);
    					if nCheckStringLength == 0 then
    					-- mark field with "-"
    		   			tMyStringValue[nMyValueIndex]=" - ";
    					end
    				end
    Thanks for giving me the tips.

  9. #9
    Join Date
    Dec 2003
    Location
    Location! Location!
    Posts
    6,137

    Thumbs up

    Try this:
    Code:
    -- step through required fields table
    for nMyValueIndex, sMyStringValue in tMyStringValue do
    	-- Check that required fields are blank and variables are nil
    	nCheckStringLength = String.Length(sMyStringValue);
    		if nCheckStringLength == 0 then
    			-- mark field with "-"
    		   	tMyStringValue[nMyValueIndex]=" - ";
    		end
    end
    See if my minds okay this holiday evening.
    Intrigued

  10. #10
    Join Date
    Oct 2004
    Location
    East, South & West Asia
    Posts
    1,020

    Strange

    Quote Originally Posted by Intrigued
    Try this:
    Code:
    -- step through required fields table
    for nMyValueIndex, sMyStringValue in tMyStringValue do
    	-- Check that required fields are blank and variables are nil
    	nCheckStringLength = String.Length(sMyStringValue);
    		if nCheckStringLength == 0 then
    			-- mark field with "-"
    		   	tMyStringValue[nMyValueIndex]=" - ";
    		end
    end
    See if my minds okay this holiday evening.
    Well Intrigue ....it didnt work either.

    I went back to basic with the following code and it wont work too:

    Code:
    	-- Get result from Input Fields
    	local sEmail = Input.GetText("InputEmail");
    	local sPhone1 = Input.GetText("InputPhone1");
    	local sPhone2 = Input.GetText("InputPhone2");
    	local sHomeAddress = Input.GetText("InputHomeAddress");
    	local sHomeCity = Input.GetText("InputHomeCity");
    	local sHomePostCode = Input.GetText("InputHomePostCode");
    	local sHomeState = Input.GetText("InputHomeState");
    	local sMemberRegNum = Input.GetText("InputMemberRegNum");
    			-- this is to avoid errors when displaying ViewAll List Page
    			-- set empty variables to string "-" or UNKNOWN 
    	local tMyStringTable = {sEmail, sPhone1, sPhone2, sHomeAddress, sHomeCity, sHomePostCode, sHomeState, sMemberRegNum};
    			-- step through fields table
    			-- Check blank variables
    				for nValueIndex, sMyStringValue in tMyStringTable do
    					if sMyStringValue == "" or sMyStringValue == nil then
    					   sMyStringValue = " - ";
    					end
    				end
    As though the code above is not passing new values. Same problem with other ways.

    Strange enough, if I do the long way below, it works and passed the " - ".
    Code:
    if sEmail=="" then sEmail=" - "; end
    if sPhone1=="" then sPhone1=" - "; end
    if sPhone2=="" then sPhone2=" - "; end
    if sHomeAddress=="" then sHomeAddress=" - "; end
    if sHomeCity=="" then sHomeCity=" - "; end
    if sHomePostCode=="" then sHomePostCode=" - "; end
    if sHomeState=="" then sHomeState=" - "; end
    if sMemberRegNum=="" then sMemberRegNum==" - "; end
    The values are then passed to a SQLite query, which worked well.
    Code:
    sQuery = "INSERT into "..mydbTable.." values(NULL,"..sEmail.."', '"..sPhone1.."', '"..sPhone2.. "', '"..sHomeAddress.."', '"..sHomeCity.."', '"..sHomePostCode.."', '"..sHomeState.."', '"..sMemberRegNum.."')";
    
    SQLite.Query(myDB,sQuery);
    I'm perplexed. What other ways can I do it?

Similar Threads

  1. About Popup Menu issue?
    By pierre in forum AutoPlay Media Studio 5.0
    Replies: 7
    Last Post: 04-20-2004, 07:20 AM
  2. Who can help I solve my confuse for this issue?
    By pierre in forum AutoPlay Media Studio 5.0
    Replies: 4
    Last Post: 04-15-2004, 01:36 AM
  3. The dreaded Submit to web PHP issue!
    By Bruce in forum AutoPlay Media Studio 4.0
    Replies: 2
    Last Post: 09-19-2003, 03:00 PM
  4. Issue with MP3Pro?
    By georallim in forum AutoPlay Media Studio 4.0
    Replies: 6
    Last Post: 07-10-2003, 04:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts