Short: Strings Library for programmers... Author: Kåre Johansen - Dr. Ice/GMS^LSC Version: v1.5 Type: dev/misc Program: strings.library (E example source included) Prologue -------- Welcome to my first library made.. This library was just a test when I first started on it, but it seems like it has grown much bigger than I thought.. :) This library has no purpose really.. I just wrote it for fun, and because of converting an E MODULE to a system friendly .LIBRARY :)... If you are a shell programmer, I'm sure this lib will come in handy for you.. Some of these commands like: StrWord() - Converted cmd from Arexx called : Word () Str2Number() - Converted cmd from Arexx called : C2D () StrReplace() - Converted cmd from Arexx called : Translate () StrCopies() - Converted cmd from Arexx called : Copies () Fexists() - Converted cmd from Arexx called : Exists () These arexx commands is not supported in Amiga E, so.. I made an E Module for this.. :) Now that E module has become a Library ! :))... Enjoy.. :) Bugs/news --------- v1.4 - Found a bug in the StrWord() command, this command added more than one word to the result string, fixed.. - Optimized the Fexists() command. When using this, Fexists will no longer open a requester when a path doesn't exist. Rewrote the return result codes: 0 = File not found 1 = File exists 2 = Device not mounted - Optimized/fixed the StrReplace() command, now you can replace more than ONE char in a text... Replace/insert words/sentences or a single char... What is this!? -------------- Well.. This library is based on a MODULE I made for AMIGA E for some time back.. This lib is a tool based library, at this very moment I have just made a few commands.. But, there will be more in the future.. :) (Read the syntax for more info)... What about the syntax!? ----------------------- Here are a list of the supported commands.. strings.library/StrCentre() v1.0 strings.library/StrWord() v1.0 Bugfixed in v1.5 strings.library/StrRight() v1.0 strings.library/Str2Number() v1.0 strings.library/StrReplace() v1.1 Improved in v1.5 strings.library/StrCopies() v1.2 strings.library/Version() v1.2 strings.library/Fexists() v1.3 Improved in v1.5 strings.library/PowNum() v1.4 strings.library/Asc2Num() v1.4 strings.library/Num2Bin() v1.5 StrCentre() strings.library/StrCentre() NAME StrCentre() -- Will center a text in SHELL/CLI SYNOPSIS res:=StrCentre(text,length) FUNCTION - This command will center a text in your SHELL/CLI window.. INPUT/OUTPUTS res - Result text - The text you want to center on the screen length - The length of your screen.. (Default 79) THIS -> WAY :) StrWord() strings.library/StrWord() NAME StrWord() -- Will locate a word in a text specified by you SYNOPSIS res:=StrWord(text,word) FUNCTION - This command will get the word you want to collect from a text e.g : StrWord('Hello, this is a test',3) would be: IS INPUT/OUTPUTS res - Result text - The text you want to get a word from word - The word number you want to get BUGS Somehow there has been a bug all the time when using this command. The result sometimes produced more than ONE word, fixed in v1.5 StrRight() strings.library/StrRight() NAME StrRight() -- Will write the text to the right in your SHELL window. SYNOPSIS res:=StrRight(text,pos) FUNCTION This command will print a text to the right of your SHELL/CLI window.. INPUT/OUTPUTS res - Result text - The text you want to print to the right pos - The position on your screen (Default: 79) Str2Number() strings.library/Str2Number() NAME Str2Number() -- This command will convert a string to a number SYNOPSIS res:=Str2Number(text) FUNCTION This command will convert a text of 4 characters maximum to a number.. E.g.: STRING NUMERIC: DOS 4476755 TEST 1413829460 JOHN 1246709838 INPUT/OUTPUTS res - Result text - The text you want to convert to a number... StrReplace() strings.library/StrReplace() NAME StrReplace() -- Will replace one character with another one SYNOPSIS str:=StrReplace(text,repchar,repwith) FUNCTION - This command will replace/or translate a text into the character you want to replace in a text e.g: str:=StrReplace('testing_a_little_bit','_',' ') Will output: testing a little bit INPUT/OUTPUTS str - Result text - The text you want to replace from repchar - The letter you want to remove repwith - The letter you want to insert instead of repchar StrCopies() strings.library/StrCopies() NAME StrCopies() -- Will copy a char number of times to a string.. SYNOPSIS str:=StrCopies(copychar,times) FUNCTION - This command will copy a char to a string x number of times.. e.g: str:=StrCopies('DOC',6) Will output: DOCDOCDOCDOCDOCDOC INPUT/OUTPUTS str - Result copychar- The char you want to copy to the string times - How many times this you want the char to be copied Version() strings.library/Version() Version() -- This will result version and revision version of SLIB This command should have been created long time ago, sorry about this... SYNOPSIS version,revision=Version() FUNCTION OUTPUT version - The version number of strings.library revision - The revision number of strings.library Fexists() strings.library/Fexists() Fexists() -- This command will result FALSE or TRUE if a file exists or not.. SYNOPSIS result=Fexists() FUNCTION This command will result back TRUE OR FALSE (-1/0), depending if the file exists or not. result:=Fexists(filename) INPUT/OUTPUT filename - Will be the name of the file you are checking for result - Result will be -1 or 0 PowNum() strings.library/PowNum() PowNum() -- This command will elevate 2 numbers.. SYNOPSIS result=PowNum(num1,num2) FUNCTION This command will elevate num1 and num2.. Lets say I want to know the square of num1 and num2 (e.g : 4^5 = 1024) then you can do like this: result:=PowNum(4,5) In math it will look like this: 4*4*4*4*4 = 1024 INPUT/OUTPUT Result - Result num1 - Will be the number you want to elevate with num2 - The number of times you want to multiply num1 result - Will be the sum of the calculation Asc2Num() strings.library/Asc2Num() Asc2Num() -- This command will produce the ascii value of a char SYNOPSIS result=Asc2Num(char) FUNCTION This command will produce the ascii value of a char, lets say I want to know what ascii value the letter/char A are.. ONLY one (1) character is allowed... result:=Asc2Num('A') The result will be: 65 INPUT/OUTPUT result - Result char - This will be the character you want to convert to a number Num2Bin() strings.library/Num2Bin() Num2Bin() -- This will convert a number value into a binary number SYNOPSIS result=Num2Bin(number) FUNCTION This command will convert a DEC number to binary result:=Num2Bin(173) The result will be: 10101101 INPUT/OUTPUT result - Result Number - The number you want to convert to binary ------------------------------------------------------------------------------- That should be all... Happy programming.. :) Programmers Notice! ------------------- Libraries created by E should be opened/closed by any one task EXACTLY ONCE, not more, not less (this shouldn't pose any problems though). Strange things WILL happen if you don't obey this rule. ============================= Archive contents ============================= Original Packed Ratio Date Time Name -------- ------- ----- --------- -------- ------------- 2584 1483 42.6% 03-May-96 23:05:56 +strexample 461 142 69.1% 06-Feb-96 10:06:34 +strings_pragmas.h 4728 2658 43.7% 03-May-96 23:04:38 +strings.library 125 103 17.6% 03-May-96 23:04:38 +strings.m 1693 717 57.6% 06-Feb-96 10:02:50 +strexample.e 8070 2766 65.7% 03-May-96 23:13:10 strings.readme -------- ------- ----- --------- -------- 17661 7869 55.4% 07-May-96 11:47:00 6 files