Short: Strings Library for programmers... Author: Kåre Johansen (kaarej@barentsnett.no) Uploader: Kåre Johansen (kaarej barentsnett no) Type: dev/misc Version: v1.8 Architecture: m68k-amigaos Program: strings.library (E example source included) Prologue -------- Welcome to another release of strings.library.. This library was meant for dos/shell purposes only when I first released v1.0.. This library can be used to everything.. I use this library in doors coding, and other utilities that needs these kinds of commands. I'm sure these commands will come in hand for you aswell.. I have put alot of time within this library, and I would apreachiate if anyone sent me bugs reports, features what ever you want to see in strings.library.. My E-MAIL can be found at the end of this documentation... 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)... Arexx Kinda Commands -------------------- 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 () What about the syntax!? ----------------------- Here are a list of the supported commands.. strings.library/StrCentre() v1.0 bugFixed in v1.7 strings.library/StrWord() v1.0 bugFixed in v1.7 strings.library/StrRight() v1.0 bugFixed in v1.7 strings.library/Str2Number() v1.0 bugFixed in v1.7 strings.library/StrReplace() v1.1 bugFixed in v1.7 strings.library/StrCopies() v1.2 bugFixed in v1.7 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 strings.library/Str2Upper() v1.6 bugFixed in v1.7 strings.library/Str2Lower() v1.6 bugFixed in v1.7 strings.library/Num2Dec() v1.7 strings.library/VersionDate() v1.7 strings.library/GetTime() v1.8 TIME/DATE command strings.library/GetTicks() v1.8 TIME/DATE command strings.library/Tick2Time() v1.8 TIME/DATE command strings.library/SetTimer() v1.8 TIME/DATE command strings.library/GetTimer() v1.8 TIME/DATE command 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 Str2Upper() strings.library/Str2Upper() Str2Upper() -- This will convert a string to uppercase SYNOPSIS result=Str2Upper(text) FUNCTION This command will convert a text to uppercased, this command will also handle the norwegian letters: Æ, Ø and Å... result:=Str2Upper('aBCøæÅ') The result will be: ABCØÆÅ INPUT/OUTPUT result - Result text - The text you want to convert to uppercase.. Str2Lower() strings.library/Str2Lower() Str2Lower() -- This will convert a string to lowercase SYNOPSIS result=Str2Lower(text) FUNCTION This command will convert a text to lowercase, this command will also handle the norwegian letters: Æ, Ø and Å... result:=Str2Lower('aBCøæÅ') The result will be: abcøæå INPUT/OUTPUT result - Result text - The text you want to convert to lowercase.. Num2Dec() strings.library/Num2Dec() Num2Dec() -- This will convert a string number to a fixed number SYNOPSIS result=Num2Dec(number,fix) FUNCTION This command will convert a number to a fixed number, e.g: result:=Num2Dec(1000000,3) result:=Num2Dec(100000,3) result:=Num2Dec(100000,2) The result will be: 1.000.000 The result will be: 100.000 The result will be: 10.00.00 INPUT/OUTPUT result - Result number - The number you want to be fixed in Amiga E : StringF(number,'\s fix - How many digits before a comma (.) (from the right) VersionDate() strings.library/VersionDate() Version() -- This will result the date of creation of library SYNOPSIS date=VersionDate() FUNCTION OUTPUT Date - Date (time) of creation of strings.library (when compiled) GetTime() strings.library/GetTime() GetTime() -- This will result the day, date, time as an argument SYNOPSIS result=GetTime() FUNCTION This function will get the current day, date and time as an argument. To separate them, use StrWord() to get them! :) OUTPUT result - day, date and time (eg: Monday 01-Jan-1997 00:01:30) GetTicks() strings.library/GetTicks() GetTicks() -- This will result the day, date, time as an argument SYNOPSIS result=GetTicks() FUNCTION This function will get the current day, date and time as an argument, but as dayticks, dateticks and ticks.. To separate them, use StrWord() to get them! :) OUTPUT result - day, date and time (eg: 6925 698 859) Tick2Time() strings.library/GetTicks() Tick2Time() -- This will result the day, date, time as an argument SYNOPSIS result=GetTicks(dayticks, dateticks, timeticks) FUNCTION This function will get the current day, date and time as an argument, using dayticks, dateticks and timeticks values, useful for BBS coders when converting "timestamp" to a date.. To separate them use StrWord() to get them! :) INPUT dayticks - Timestamp Dayticks (see output) dateticks - Timestamp Dateticks (see output) timeticks - Timestamp Timeticks (see output) OUTPUT result - day, date and time as a string argument.. Ticks Converted Ticks --------------------------------------------- 6925 698 859 Tuesday 17-Dec-96 11:38:17 SetTimer() strings.library/SetTimer() SetTimer() -- This command will reset or set a timer for you SYNOPSIS SetTimer(mins,secs) FUNCTION This command will calculate a timer/counter that will count from the values you enter in the parameters.. e.g: SetTimer(59,30) will set the timer to: 00:59:30 INPUT mins - How many minutes/hours the timer should be set to.. secs - How many seconds/minutes the timer should be set to.. GetTimer() strings.library/GetTimer() GetTimer() -- This command will get the timer you set with SetTimer.. If you don't set anything with the SetTimer(), the GetTimer() will use the real timer (your clock :))... SYNOPSIS result:=GetTimer() FUNCTION This function will calculate the new timer as the new result. OUTPUT result - The new timer result (e.g: 00:00:00) Bugs/news/Hisory ---------------- v1.8 - Added new command SetTimer() - Added new command GetTimer() The following 3 date/time commands results a 3 args string, to get them use StrWord() or FindArg() from DOS.LIBRARY... - Added new command GetTime() - Added new command GetTicks() - Added new command Tick2Time() v1.7 - Rewrote StrWord() again !... (Gosj, I'm getting tired of this).. - Added new command Num2Dec() - Fixed a major bug in all Str commands!!... If used more than one (1) time after each other, the value would be the same as the last one, eg word:='Hello again' Printf('\s (word 1) \s (word 2)\n',StrWord(word,1),StrWord(word,2)) Results : Word 1 = "again" Word 2 = "again" All commands has been prefixed.. v1.6 - Added new command Str2Upper() - Added new command Str2Lower() - Internal release v1.5 - StrWord() did something weird with the "in variable" if there was more than 1 StrWord(); Eg -------------- buff:='Hello my friend' var1:=StrWord(buff,1) var2:=StrWord(buff,2) var3:=StrWord(buff,3) The var1, var2 and var3 contained ALL the same value -> FRIEND.. -------------- - Rewrote some of the StrWord() routine once again 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... ------------------------------------------------------------------------------- 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. ------------------------------------------------------------------------------ For contacting me ----------------- E-MAIL: kaarej@barentsnett.no OR BBS: Key Stroke BBS +47-7847-1042 ------------------------------------------------------------------------------ That should be all... Happy programming.. :)