Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004
    Posts
    2

    Problems trimming filename string

    I am trying to cutdown similar file names to these

    comp - nameabc11 - pr_code11.txt
    to pr_code11

    comp - nameaaaadbc21 - pd_code21.txt
    to pd_code21

    I end up getting results like this

    - pr_code11
    and
    c21 - pd_code21


    I tried doing this way


    Code:
    --================================================
    -- Get Selected Item Number from this Listbox
    --================================================
    		nSelected = ListBox.GetSelected(this)[1];
    
    	if nSelected then
    --=================================================
    -- Getting Original Full name and Path
    --=================================================
    
    		org_name = ListBox.GetItemData(this, nSelected);
    
    --=================================================
    -- Splitting up Path, Name, and Ext 
    --=================================================
    
    		splt_path = String.SplitPath(org_name);
    
    --=================================================
    -- Assining the Filename to a varible
    --=================================================
    	
    		file_name = splt_path.Filename
    
    --=================================================
    -- Removing the "comp - " out of the filename
    --=================================================
    	
    		rem_comp = String.Replace(file_name, "comp - ", "", false);
    
    --=================================================
    -- Find Position number of the next  " - "
    --=================================================
    
    		pos_no = String.Find(rem_comp, "-", false);
    		--pos_no = String.ReverseFind(rem_comp, "-", false);
    		
    --=================================================
    -- Creating a new word to the right of the position number
    --=================================================
    
    		final_name = String.Right(rem_comp, pos_no);
    
    
    --=================================================
    -- Getting Values From INI
    --=================================================
    
    		price_1 = INIFile.GetValue("myinifile.ini", final_name, "price");
    		image_1 = INIFile.GetValue("myinifile.ini", final_name, "image");
    		name_1 = INIFile.GetValue("myinifile.ini", final_name, "name");
    
    --=================================================
    -- Set Values From INI To Objects
    --=================================================
    		Input.SetText("Input2", price_1);
    		Label.SetText("Label1", name_1);
    		Image.Load("Image2", image_1);
    		
    --=================================================
    -- Create a global variable and assign a string to it
    --=================================================
    			--current_sel = result1;
    			gl_image = image_1
    			
    --=================================================
    -- A Test Just to see results of file renameing
    --=================================================
    			Label.SetText("Label3", pos_no);
    			Input.SetText("Input1", final_name);
    	end

  2. #2
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    Look at the action String.ReverseFind and search for the "-". Once you find it use the returned position and the String.Mid action to cut from there to the end of the line (-1).

    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

  3. #3
    Join Date
    Jan 2004
    Posts
    2

    Thanks

    That help alot thanks.

Similar Threads

  1. Function : Validate String (Great for passwords, etc.)
    By Corey in forum AutoPlay Media Studio 5.0 Examples
    Replies: 3
    Last Post: 04-28-2005, 02:42 AM
  2. attempt to index a string value
    By csd214 in forum AutoPlay Media Studio 5.0
    Replies: 8
    Last Post: 08-08-2004, 01:23 AM
  3. String Trimming
    By Bruce in forum AutoPlay Media Studio 5.0
    Replies: 6
    Last Post: 01-03-2004, 06:50 PM
  4. "Get Delimited String" -- Delimiter can be a string?
    By Bishal in forum Setup Factory 6.0
    Replies: 1
    Last Post: 10-16-2003, 10:40 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