Indigo Rose Software

Professional Software Development Tools

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

    How to Delete blank spaces from variables

    Hi,

    Anyone has a function to delete blank spaces from an INPUT variable?

    Say, a user entered an INPUT EMAIL object with this "hello its me@genome.com" by mistake. When it should be "helloitsme@genome.com".

    The objective of deleting the blanks is to launch an email software with the correct email address from an AMS objects such as the Browser Object.
    Newbie Examples
    ------> AMS 7.5 : amstudio.azman.info
    ----> AMS 6 & 5: www.azman.info/ams/
    ----> FB: facebook.com/GuideToWealth

    ----> Content Development Blog: www.AZMAN.asia

  2. #2
    Join Date
    Mar 2004
    Location
    Toronto, ON CANADA
    Posts
    696
    I think rather than allowing the spaces to be input, since you have control of the input, is to not allow spaces in the first place. Email addresses do not contain spaces so this is the logical approach in my opinion.

    Here is a dirty way of doing it. Use this in the 'On Key' event screen:

    Code:
    result = Input.GetText("Input1");
    if e_Key == 32 then
    	resulttrimmedright = String.TrimRight(result, nil);
    	resulttrimmedleft = String.TrimLeft(resulttrimmedright, nil);
    	Input.SetText("Input1", resulttrimmedleft);
    	Input.SetSelection("Input1", 1, -1);
    end
    Last edited by Tek; 08-10-2006 at 03:20 PM.

  3. #3
    Join Date
    Oct 2005
    Location
    MI
    Posts
    524
    I like Tek's solution better but here's another way to do it using the DelimitedStringToTable function from:

    Code:
    Program Files\AutoPlay Media Studio 6.0\Gallery\Scripts
    GLOBAL FUNCTIONS
    Code:
    --[[
    Function: DelimitedStringToTable
    Purpose: Breaks up a string given a delimiter into a table
    Arguments:	DelimitedString - The string to parse
    			Delimiter - The delimiter
    Returns: A numerically indexed table with the string elements
    Example:
    
    string = "Brett,Mark,Darryl,Lorne,Adam";
    tbResults = DelimitedStringToTable(string,",");
    for i, name in tbResults do
    	Dialog.Message("Name",name);
    end
    
    ]]--
    
    function DelimitedStringToTable(DelimitedString, Delimiter)
    	tbReturn = {};
    	local strWorking;
    	local nPos = nil;
    	local strData;
    	local nTableIndex = 1;
    	local nDelimiterLength = String.Length(Delimiter);
    	
    	if(nDelimiterLength < 1)then
    		tbReturn[nTableIndex] = DelimitedString;
    		return tbReturn;
    	end
    	
    	strWorking = DelimitedString;
    	nPos = String.Find(strWorking,Delimiter);
    	while(nPos ~= -1)do
    		strData = String.Left(strWorking,nPos-1);
    		tbReturn[nTableIndex] = strData;
    		nTableIndex = nTableIndex + 1;
    		local nLength = String.Length(strWorking);
    		strWorking = String.Right(strWorking,nLength - (nPos + (nDelimiterLength-1)));
    		nPos = String.Find(strWorking,Delimiter);
    	end
    	if(strWorking ~= "")then
    		tbReturn[nTableIndex] = strWorking;
    	end
    	
    	return tbReturn;
    end
    ON CLICK
    Code:
    str_Input = Input.GetText("Input1");
    str_SpacesRemoved = "";
    
    tbl_Parts = DelimitedStringToTable(str_Input, " ");
    
    for i, v in tbl_Parts do
    	str_SpacesRemoved = str_SpacesRemoved .. v;
    end
    
    Label.SetText("Label1", str_SpacesRemoved);
    Yeah right. Who's the only one here who knows the illegal ninja moves from the government?

    ()))))))))o)))))))==============================================

  4. #4
    Join Date
    Dec 2003
    Location
    Location! Location!
    Posts
    6,137
    How about this, it's short and gets the job done:

    Code:
    strOriginal = Input.GetText("Input1")
    	strNoSpaces = String.Replace(strOriginal, " ", "", false)
    		Dialog.Message("String without spaces...", strNoSpaces)
    Intrigued

  5. #5
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    I-Man was quick on the draw and beat me to it. D'oh.

    Why not use

    strEmail = String.Replace(strEmail, " ", "", false);

    Replace in the string strEmail all spaces with nothing.

    Tigg
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  6. #6
    Join Date
    Dec 2003
    Location
    Location! Location!
    Posts
    6,137
    heh, heh. Maybe you just let me have that one. (smirk)

    Nice job on the Quiz app. Tig'. Looking good there.
    Intrigued

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

    Thanks ye all. Good solutions
    Newbie Examples
    ------> AMS 7.5 : amstudio.azman.info
    ----> AMS 6 & 5: www.azman.info/ams/
    ----> FB: facebook.com/GuideToWealth

    ----> Content Development Blog: www.AZMAN.asia

Similar Threads

  1. Delete blank lines from a text file
    By G Mills in forum Setup Factory 7.0
    Replies: 9
    Last Post: 03-11-2005, 04:04 AM
  2. Help passing screen variables
    By swilk in forum Setup Factory 7.0
    Replies: 2
    Last Post: 12-06-2004, 11:07 AM
  3. Delete files/recurse dir -- desktop went blank.
    By jassing in forum Setup Factory 6.0
    Replies: 1
    Last Post: 05-04-2003, 11:04 AM
  4. INFO: Setting Environment Variables
    By Support in forum Setup Factory 6.0 Knowledge Base
    Replies: 0
    Last Post: 10-10-2002, 12:07 PM
  5. "Delete Text Line" also adds a blank line at EOF
    By alian007 in forum Setup Factory 6.0
    Replies: 1
    Last Post: 07-30-2002, 11:00 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