Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

How To Remove Underscores....


3 replies to this topic

elliottrb

elliottrb
  • Members
  • 70 posts

Posted 22 February 2002 - 16:54

Does anyone have a function that I can use to remove underscores from a variable that is passed into my one click install?  The variable name is similar to "Robbie's_SOBE_Custom_Radio_Player" and we need it to say "Robbie's SOBE Custom Radio Player" without the underscores.

What is the best way of accomplishing this?

Thanks,


elliottrb

elliottrb
  • Members
  • 70 posts

Posted 22 February 2002 - 17:33

Oops, I meant the variable value is "Robbie's_SOBE_Custom_Radio_Player" and we need it to say "Robbie's SOBE Custom Radio Player", not the variable name.  This value is used to name the shortcuts.

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 22 February 2002 - 17:34

The easist thing would be to do a basic find/replace of the characters.

For the find, nPosition = StrFind(szText, "_");
For the replace, szText[nPosition] = " ";

Just keep doing that until you run out in which case nPosition < 0.


elliottrb

elliottrb
  • Members
  • 70 posts

Posted 22 February 2002 - 21:22

Here's what I ended up doing and it works nicely.

prototype RemoveUnderScores();


#include "ifx.h"

function OnBegin()
STRING szTestString, szMsg;
NUMBER nPosition, nFlag, nChars;
                   
begin
szTestString = "This_Is_A_Test.";
nChars = StrLengthChars (szTestString);
MessageBox(szTestString, INFORMATION);
   szMsg = "String '%s' is %d characters long.";
   SprintfBox (INFORMATION, "Number of Characters", szMsg, szTestString, nChars);
   nFlag = 0;
   while nFlag = 0
   nPosition = StrFind(szTestString, "_");
    if nPosition = -1
    then nFlag = 1;
    else
      szTestString[nPosition] = " ";
    endif;
   endwhile;  
   MessageBox(szTestString, INFORMATION);
end;

The MessageBox and SPrintFBox are in for diagnosing issues.

Thanks TacoBell.