Click here to Skip to main content
15,887,464 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Familiarity : Trimming leading and trailing spaces from a string... Pin
Jecc28-Sep-12 0:46
Jecc28-Sep-12 0:46 
GeneralRe: Familiarity : Trimming leading and trailing spaces from a string... Pin
Blake Miller28-Sep-12 4:08
Blake Miller28-Sep-12 4:08 
GeneralRe: Familiarity : Trimming leading and trailing spaces from a string... Pin
RafagaX28-Sep-12 6:01
professionalRafagaX28-Sep-12 6:01 
GeneralRe: Familiarity : Trimming leading and trailing spaces from a string... Pin
Brady Kelly29-Sep-12 6:39
Brady Kelly29-Sep-12 6:39 
GeneralRe: Familiarity : Trimming leading and trailing spaces from a string... Pin
Jamercee28-Sep-12 4:23
Jamercee28-Sep-12 4:23 
GeneralRe: Familiarity : Trimming leading and trailing spaces from a string... Pin
Blake Miller28-Sep-12 4:52
Blake Miller28-Sep-12 4:52 
GeneralRe: Familiarity : Trimming leading and trailing spaces from a string... Pin
Martin081528-Sep-12 4:24
professionalMartin081528-Sep-12 4:24 
GeneralRe: Familiarity : Trimming leading and trailing spaces from a string... Pin
Chris Boss28-Sep-12 4:35
professionalChris Boss28-Sep-12 4:35 
One of the best languages for string manipulation is PowerBasic. You can use it to write 32 bit DLL's callable from other languages.

To trim leading spaces: LTRIM$(AnyStringVar)
To trim any character from left: LTRIM$(AnyStringVar, SomeCharacter)
To trim any of multiple characters from left: LTRIM$(AnyStringVar, ANY SomeCharacters)
To trim trailing edge spaces: RTRIM$(AnyStringVar)
To trim any trailing character: RTRIM$(AnyStringVar,SomeCharacter)
To trim any of multiple trailing characters: RTRIM$(AnyStringVar, ANY SomeCharacters)
Trim both leading and trailing spaces: TRIM$(AnyStringVar)
Trim any character leading or trailing: TRIM$(AnyStringVar, SomeCharacter)
Trim any of multiple characters leading and trailing: TRIM$(AnyStringvar, ANY SomeCharacters)

PowerBasic supports pointers too !

PowerBasic has many other powerful string functions (both ANSI and UNICODE) such as:

ACODE$ - Translate a Unicode string into an ANSI string.

BIN$ - Return a string with the binary (base 2) representation of a value.

BITS$ - Copies string contents without modification.

BUILD$ - Concatenate multiple strings with high efficiency.

CHOOSE$ - Return one of several values, based upon the value of an index.

CHR$ - Convert one or more character codes into ASCII character(s).

CHR$$ - Convert one or more character codes into Unicode character(s).

CHRBYTES - Determine the size of a single character in a string variable.

ChrToOem$ - Translates a string of ANSI/WIDE characters to OEM byte characters.

ChrToUtf8$ - Translates a string of ANSI/WIDE characters to UTF-8 byte characters.

CLIP$ - Deletes characters from a string.

CLSID$ - Return a 16-byte (128-bit) GUID string containing a CLSID.

CSET - Center a string within the space of another string or UDT.

CSET$ - Return a string containing a centered (padded) string.

DEC$ - Convert an integral value to a decimal string.

EXTRACT$ - Return up to the first occurrence of a specified character.

FORMAT$ - Return a string containing formatted numeric data.

GUID$ - Return a 16-byte (128-bit) Globally Unique Identifier GUID.

GUIDTXT$ - Return a 38-byte human-readable GUID/UUID string.

HEX$ - Hexadecimal (base 16) string representation of an argument.

INSTR - Search a string for the first occurrence of a character or string.

JOIN$ - Return a string consisting of all of the strings in a string array.

LCASE$ - Return a lowercase version of a string argument.

LEFT$ - Return the left-most n characters of a string.

LEN - Return the logical length of a variable, UDT, or Union.

LSET - Left-align a string within the space of another string or UDT.

LSET$ - Return a string containing a left-justified (padded) string.

MAX$ - Return the argument with the largest (maximum) value.

MCASE$ - Return a mixed case version of a string argument.

MID$ - Return a portion of a string.

MID$ - Replace characters in a string with characters from another string.

MIN$ - Return the argument with the smallest (minimum) value.

MKBYT$ - Convert a Byte value into a binary encoded string.

MKCUR$ - Convert a Currency value into a binary encoded string.

MKCUX$ - Convert an Extended Currency value into a binary encoded string.

MKD$ - Convert a Double-precision value into a binary encoded string.

MKDWD$ - Convert a Double-word value into a binary encoded string.

MKE$ - Convert an Extended-precision value into a binary encoded string.

MKI$ - Convert a integral value into a binary encoded string.

MKL$ - Convert a Long-integer value into a binary encoded string.

MKQ$ - Convert a Quad-integer value into a binary encoded string.

MKS$ - Convert a Single-precision value into a binary encoded string.

MKWRD$ - Convert a Word value into a binary encoded string.

NUL$ - Return a string containing a specified number of $NUL characters.

OCT$ - Return a string that is a octal (base 8) representation of a value.

OemToChr$ - Translates a byte string of OEM characters into ANSI/WIDE characters.

PARSE - Parse a string and extract all delimited fields into an array.

PARSE$ - Return a delimited field from a string expression.

PARSECOUNT - Return the count of delimited fields in a string expression.

PEEK$ - Returns consecutive 1-byte characters starting at a specific memory location.

PEEK$$ - Returns consecutive 2-byte wide characters starting at a specific memory location.

POKE$ - Store a sequence of bytes starting at a specific memory location.

POKE$$ - Store a sequence as 2-byte wide characters starting at a specific memory location.

PROGID$ - Return the alphanumeric PROGID string (text) of a given CLSID.

REGEXPR - Scan a string for a matching "wildcard" or regular expression.

REGREPL - Scan a "wildcard" match in a string with a new string.

REMAIN$ - Returns the portion of a string which follows the first occurrence of a character or group of characters.

REMOVE$ - Return a copy of a string with characters or strings removed.

REPEAT$ - Return a string consisting of multiple copies of a specified string.

REPLACE - Replace all occurrences of one string with another string.

RETAIN$ - Return a string with all non-specified characters removed.

RIGHT$ - Return the rightmost n characters of a string.

RSET - Right justify a string into the space of a string variable or UDT.

RSET$ - Return a string containing a right-justified (padded) string.

SHRINK$ - Shrinks a string to use a consistent single character delimiter.

SIZEOF - Return the total or physical length of any PowerBASIC variable.

SPACE$ - Return a string consisting of a specified number of spaces.

SPLIT - Splits a string into two parts.

STR$ - Return the string representation of a number in printable form.

STRDELETE$ - Delete a specified number of characters from a string expression.

STRING$ - Returns an ANSI string consisting of multiple copies of a specified character.

STRING$$ - Returns a WIDE string consisting of multiple copies of a specified character.

STRINSERT$ - Insert a string at a specified position within another string.

STRPTR - Return the address of the data held by a variable length string.

STRREVERSE$ - Reverse the contents of a string expression.

SWAP - Exchange the values of two strings, pointers, or pointer targets.

SWITCH$ - Return one item of a series based upon a True/False evaluation.

TAB$ - Return a string with TAB characters expanded with spaces.

TALLY - Count the number of occurrences of specified characters/strings.

UCASE$ - Return an all-uppercase (capitalized) version of a string.

UCODE$ - Translate an ANSI string into a Unicode string.

UNWRAP$ - Removes paired characters from the beginning and end of a string.

USING$ - Format string/numeric expressions using a mask string.

Utf8ToChr$ - Translates a byte string of OEM characters into ANSI/WIDE characters.

VERIFY - Determine if each character of a string is in another string.

WRAP$ - Adds paired characters to the beginning and end of a string.

PowerBasic string functions are fast, fast, fast. The compiler was written in assembler and the generated machine code is optimized for speed.
QuestionRe: Familiarity : Trimming leading and trailing spaces from a string... Pin
Julien Villers2-Oct-12 23:57
professionalJulien Villers2-Oct-12 23:57 
GeneralRe: Familiarity : Trimming leading and trailing spaces from a string... Pin
Joe_Dert20-Oct-12 21:09
Joe_Dert20-Oct-12 21:09 
JokeParsing string to Integer with try and catch??? Pin
Marco Bertschi25-Sep-12 1:27
protectorMarco Bertschi25-Sep-12 1:27 
GeneralRe: Parsing string to Integer with try and catch??? PinPopular
Pete O'Hanlon25-Sep-12 2:04
mvePete O'Hanlon25-Sep-12 2:04 
GeneralRe: Parsing string to Integer with try and catch??? Pin
Marco Bertschi25-Sep-12 2:57
protectorMarco Bertschi25-Sep-12 2:57 
GeneralRe: Parsing string to Integer with try and catch??? Pin
dojohansen2-Oct-12 3:34
dojohansen2-Oct-12 3:34 
GeneralRe: Parsing string to Integer with try and catch??? Pin
OriginalGriff25-Sep-12 3:32
mveOriginalGriff25-Sep-12 3:32 
GeneralRe: Parsing string to Integer with try and catch??? Pin
Marco Bertschi25-Sep-12 3:36
protectorMarco Bertschi25-Sep-12 3:36 
GeneralRe: Parsing string to Integer with try and catch??? Pin
KP Lee28-Sep-12 22:17
KP Lee28-Sep-12 22:17 
AnswerRe: Parsing string to Integer with try and catch??? Pin
Marco Bertschi30-Sep-12 21:01
protectorMarco Bertschi30-Sep-12 21:01 
GeneralRe: Parsing string to Integer with try and catch??? Pin
dojohansen2-Oct-12 3:48
dojohansen2-Oct-12 3:48 
GeneralRe: Parsing string to Integer with try and catch??? PinPopular
BobJanova25-Sep-12 3:53
BobJanova25-Sep-12 3:53 
GeneralRe: Parsing string to Integer with try and catch??? Pin
Marco Bertschi25-Sep-12 4:05
protectorMarco Bertschi25-Sep-12 4:05 
AnswerRe: Parsing string to Integer with try and catch??? Pin
Julien Villers25-Sep-12 23:45
professionalJulien Villers25-Sep-12 23:45 
GeneralRe: Parsing string to Integer with try and catch??? Pin
BobJanova26-Sep-12 0:12
BobJanova26-Sep-12 0:12 
GeneralRe: Parsing string to Integer with try and catch??? Pin
Julien Villers26-Sep-12 1:15
professionalJulien Villers26-Sep-12 1:15 
GeneralRe: Parsing string to Integer with try and catch??? Pin
dojohansen2-Oct-12 3:51
dojohansen2-Oct-12 3:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.