LordJashin Posted October 23, 2012 Share Posted October 23, 2012 (edited) One thing me and Shadow did good with GMRL was having a change log. I modeled this one after Freddy's for SCAR a bit. IMHO It looks easy enough to read without being overkill in most situations. OSI's Change Log is located on Github: https://github.com/OSI1/OSI1/blob/master/Change%20Log.txt Recent Changes: Lots of additions from MSSL, Thanks Jani! Maybe I should've mentioned that in the recent changes, but all the functions in the files have your credits so its all good there. ------------------------- LordJashin - 10/23/2012 : ------------------------- Added: Divi/Bitmap.scar: - function GetBitmapSize(bmp: TSCARBitmap; var width, height: Integer): Boolean; Divi/Integer.scar: - function StrIsInt(s: string): Boolean; Divi/Math.scar: - function RandomAbs(Range: Integer): Integer; - function RandomRangeAbs(AFrom, ATo: Integer): Integer; Divi/Point.scar: - function PointToStr(P: TPoint): string; Divi/String.scar: - function StrCount(SubStr, s: string; overlap: Boolean): Integer; - function StrSplit(text, separator: string; ID: Integer): string; - function StrSplitEx(text, separator: string; IDs: TIntArray): TStrArray; - function StrReplaceEx(Text, FindS, ReplaceS: string; Offset: Integer): string; - function StrClosestPos(SubStr, s: string; iFrom: Integer): Integer; - function StrFarthestPos(SubStr, s: string; iFrom: Integer): Integer; - function StrContainsC(x: Char; s: string): Boolean; File: - Divi/Extended.scar: - function StrIsExt(s: string): Boolean; - Change Log.txt !!! Improvements: - StrInStr => StrContains - StrInStrMulti => StrContainsEx - StrCopy => StrCopyEx - StrBetween => StrBetweenEx - StrStuff: - StrStuff(SubStr, s: string; iFrom, iCount: Integer): string; - StrStuffEx: - StrStuffEx(SubStr, s: string; pos1, pos2: Integer): string; - Other param name changes, mostly from s => SubStr, and str => s - Updated OSI with new function/procedure names - Updated Dates ------------------------- Edited October 23, 2012 by LordJashin Quote Link to comment Share on other sites More sharing options...
Janilabo Posted October 24, 2012 Share Posted October 24, 2012 Nice work LJ! Also, good job with those logging features (Logging.scar). Keep up the good work, buddyy! -Jani Quote Link to comment Share on other sites More sharing options...
LordJashin Posted October 24, 2012 Author Share Posted October 24, 2012 Thanks, about those string functions. There is one called I think: StrEndsWith, but I never found the StrBeginsWith or StrStartsWith. lol. Thought maybe you should add that. What I've been doing with the naming is since it is like almost the same as StartsWith function, I'll add Ex to the end of them if I add them to OSI. That's what I did with StrCopy, StrReplace, etc. that I got from MSSL's string functions. Also I've been wondering about all the array functions there is. There is like TPAAdd, TExtAdd, and etc. forever and ever. Could we make one function that could handle most of the array types? I think Variant array functions are good, but could we make a larger function to do it for all of them? Maybe like if Type(Arr) = TPA then x; You too! -LJ Quote Link to comment Share on other sites More sharing options...
Janilabo Posted October 24, 2012 Share Posted October 24, 2012 (edited) Also I've been wondering about all the array functions there is. There is like TPAAdd, TExtAdd, and etc. forever and ever. Could we make one function that could handle most of the array types? I think Variant array functions are good, but could we make a larger function to do it for all of them? Maybe like if Type(Arr) = TPA then x;I really wish we could do that, but so far I haven't found out a way. TVariantArray is simply an array of Integers/Strings/Booleans/Extendeds, whereas, what you (and me) are dreaming about is something totally different, only Freddy could do that.. But yeah, it would be great in future to have functions with combination of variables/array types (built-in to SCAR). It would be just AWESOME. Here is StrStartWith: function StrStartWith(suffix: string; var s: string): Boolean; var p, l: Integer; begin l := Length(suffix); if ((s = '') or (l > Length(s))) then Exit; p := Pos(suffix, s); Result := (p > 0); if Result then s := Copy(s, p, (Length(s) - (p - 1))); end; var str: string; begin ClearDebug; str := 'Janilabo is a newbie! TEST to see if this works, so TESTING now...'; if StrStartWith('TEST', str) then WriteLn('YAY, str now: "' + str + '"') else WriteLn('FAIL!'); end. Edited October 24, 2012 by Janilabo Quote Link to comment Share on other sites More sharing options...
LordJashin Posted October 24, 2012 Author Share Posted October 24, 2012 (edited) What about these functions? VarArrayGet VarType Nice I will add those to OSI! EDIT: VarType, I dont think works for arrays, keep getting 8204 as result. But couldn't we do that to figure out if its an array? Then do Arr[0] to find out what type of array? [scar] program New; var bbb: TStrArray; aaa: String; begin SetLength(bbb, 1); WriteLn(VarType(bbb)); WriteLn(VarType(bbb[0])); WriteLn(VarType(aaa)); end. [/scar] Still need some clarification, going to google it. http://www.delphibasics.co.uk/RTL.asp?Name=VarType Edited October 24, 2012 by LordJashin Quote Link to comment Share on other sites More sharing options...
Janilabo Posted October 24, 2012 Share Posted October 24, 2012 (edited) Good thinking there, but what if the array is TVariantArray or just an empty array of [string, Integer, Extended, Boolean, etc..], then we couldn't use Arr[*]. + array of TVarType <> TVariantArray / TStrArray / TIntArray / TExtArray / etc.. Also, TVariantArray doesn't work with TPoints/TBoxes: var p: TPoint; v: TVariantArray; begin p := Point(1, 1); v := [p]; end. EDIT: We would need some functions/procedures like this in SCAR.. +Variant would need to have full support for arrays. But but, I am sure adding these in SCAR is not very easy task, at all. Maybe for SCAR Titan in future? Edited October 24, 2012 by Janilabo Quote Link to comment Share on other sites More sharing options...
LordJashin Posted October 24, 2012 Author Share Posted October 24, 2012 http://www.delphibasics.co.uk/RTL.asp?Name=VarType This works great! But I haven't figured out how to tell if a variable is a Variant. I don't think you can. Also I read that operations with variables of Variant type are more intensive. Yeah we would have to create our own thing for this. Looks challenging - http://docwiki.embarcadero.com/RADStudio/XE3/en/Creating_a_Class_to_Enable_the_Custom_Variant_Type But hey not all is lost here. This is still a great idea! It just would fail if there was ever a Variant passed into it. Anyway, got so close to loading RSC into SMART: [scar] program TestRSC; {$DEFINE RS2} {$DEFINE SMART} {$I OSI/OSI.scar} var SMART_RSCClient: TSCARClient; i: Integer; begin if InitSmartLib(IncludesPath + 'OSI\RS2\Misc\libsmartremote32.dll') then SMART_Path := IncludesPath + 'OSI\RS2\Misc\' else if InitSmartLib(ScriptPath + 'OSI\RS2\Misc\libsmartremote32.dll') then SMART_Path := ScriptPath + 'OSI\RS2\Misc\' else if InitSmartLib(ScriptPath + 'RS2\Misc\libsmartremote32.dll') then SMART_Path := ScriptPath + 'RS2\Misc\' else begin OSI_WriteAndLog('OSI: RS2: Couldn''t load SMART (libsmartremote32.dll)'); OSI_WriteAndLog('OSI: RS2: Try restarting SCAR Divi, SMART, or Re-installing OSI'); OSI_WriteAndLog('OSI: RS2: If problems persist post a thread on the forums at http://www.scar-divi.com'); TerminateScript; end; i := SmartSpawnClient(SMART_Path, 'http://classic3.runescape.com/', 'j0,a1', 500, 500, 's', '', '', -1); WriteLn(ExceptionToString(ExceptionType, ExceptionParam)); SMART_RSCClient := CreateSmartClient(i); end. [/scar] Quote Link to comment Share on other sites More sharing options...
LordJashin Posted October 24, 2012 Author Share Posted October 24, 2012 Only got to this point with the RSC loading into SMART: Shared Memory mapped to 0x88 Trying port 4200 Remote socket listening Client socket connected: 152 Running SMART Constructor SMART Initialized! Library: 0x6c780000 SmartSetup Entered Attempting to load default server JVM Attempting to load default client JVM Created a Java Runtime Environment object reading decrypting defining: smart/Client$4 = 0x25e8f38 reading decrypting defining: smart/Client$3 = 0x25e8f3c reading decrypting defining: smart/Client = 0x25e8f40 reading decrypting defining: smart/EventNazi = 0x25e8f44 reading decrypting defining: smart/UnblockedEvent = 0x25e8f48 reading decrypting defining: smart/EventRedirect = 0x25e8f4c reading decrypting defining: java/awt/Canvas$AccessibleAWTCanvas = 0x25e8f50 reading decrypting defining: smart/EventNazi$KeySender = 0x25e8f54 reading decrypting defining: smart/Client$1 = 0x25e8f58 reading decrypting defining: smart/Client$2 = 0x25e8f5c reading decrypting defining: java/awt/Canvas = 0x25e8f60 reading decrypting defining: smart/ClientStub = 0x25e8f64 reading decrypting defining: smart/BlockingEventQueue = 0x25e8f68 Classes unpacked, loaded, and reflected Using preallocated image swap area(s) Registration Response: 38 JVM Garbage Collection Invoked Java Initilized - SMART Starting Applet Loader Parsed Using jar: http://classic3.runescape.com/rsclassic68603135.jar Applet Parameters Forwarded Setting up Frame Client INIT GET PARAM: nodeid=>5003 GET PARAM: modewhere=>0 GET PARAM: modewhat=>0 Started applet Client START Client WAITING Anyway, the VarType thing is a good idea, but hard to implement and doesn't support Variant and maybe other issues. I think we should put the common array functions all in one file though. So then if we have like TExtAdd, TSAAdd, we could put them both in Array.scar or w/e. Quote Link to comment Share on other sites More sharing options...
Janilabo Posted October 25, 2012 Share Posted October 25, 2012 Anyway, the VarType thing is a good idea, but hard to implement and doesn't support Variant and maybe other issues. I think we should put the common array functions all in one file though. So then if we have like TExtAdd, TSAAdd, we could put them both in Array.scar or w/e. Yeah, I agree it is indeed a great idea - maybe something for the future? Involves a little too many problems for now (+speed would become way slower, if we would have to check arrays for the types manually, looping through every item). Agree with you on Array.scar, that definitely would work. Not sure how big the file would grow, though. (In MSSL String.scar & Point.scar are already a little too big) -Jani Quote Link to comment Share on other sites More sharing options...
LordJashin Posted October 25, 2012 Author Share Posted October 25, 2012 (edited) The idea would definitely work! But if anyone puts in there a variant type or array of variant, the function will collapse and die lol. I'm not gonna make it loop through each thing lol, that is wasteful. The array of variant would kill it. But I think variant would do fine. Because variant won't change, while the variant array could have different types in every slot. EDIT: Seems much harder, probably impossible. Because we can't see if the type is a TPoint for example. And TPoint can't be put into a variant. As I think you said above. I though you could make your own type some how though... Edited October 25, 2012 by LordJashin Quote Link to comment Share on other sites More sharing options...