|
voila, je comence un ... machin, et j'ai besoin de définir des effets que je ne lance que plus tard (et je conais pas la durée d'attente ...) donc, ba j'aurai besoin d'un SetLocalEffect ... bon, y en a pas, on le sait, et le systeme de l'objet, si on lance pas l'effet, g fait qq essi, pas long, mais ca a pas l'air de marcher.
donc, g fait un essai, que j'aimerai bien qu'on me dise si c pas trop idiot il semble que ca marche ... jusqu'a maintenant ... donc bon ... mais si vous avez des conseils, des idées, des remarques, des insultes, du café ...
bon, ba voila :
arf, trop longue :/
//:: lib pour un SetLocalEffect //:: fonct_effets //:: Copyright Reyan (c) ^_^ (made for Paorn) /* Bon, alors ouala un essai de truc pour stocker des effets a rutiliser plus tard ... (je ferais p-e mieux de mettre un lien nan ? ) en gros, on transforme un effets en string, qu'on stock, et qu'on retransforme qd on a besoin ...
*/ //:: Created By: Reyan //:: Created On: 11/03/2003
//::////////////////////////////////////////////// //:: Declaration des variables de ma lib (reyan) //::////////////////////////////////////////////// //---------------!!!!!important!!!!!------------------ //ne rien modifier si l'on est pas sur de ce qu'on fait ^_^
//s'arranger pour que la string des location soit !!!====>unique<====!!! //sinon RIEN ne vas marcher, enfin, ca poseras d'enorme pb ^_^ string sBaseLoc="EFFECTPOINT_"; string sBaseObj = "EFFECTTARGET_"; //utiliser dans le onactivateitem string sTok3 = "#"; location lLocLocalEffects = GetStartingLocation(); //GetTaLocationCommeTuVeux
//:: constantes d'effets
int CE_ABILITYDECREASE = 1; int CE_ABILITYINCREASE = 2; int CE_ACDECREASE =3; int CE_ACINCREASE =4; int CE_APPEAR =5; int CE_AREAOFEFFECT =6; int CE_ATTACKDECREASE =7; int CE_ATTACKINCREASE =8; int CE_BEAM =9; int CE_BLINDNESS =10; int CE_CHARMED =11; int CE_CONCEALMENT =12; int CE_CONFUSED =13; int CE_CURSE =14; int CE_CUTSCENEDOMINATED =15; int CE_DAMAGE =16; int CE_DAMAGEDEACREASE =17; int CE_DAMAGEIMMUNITYDECREASE =18; int CE_DAMAGEIMMUNITYINCREASE =19; int CE_DAMAGEINCREASE =20; int CE_DAMAGEREDUCTION =21; int CE_DAMAGERESISTANCE =22; int CE_DAMAGESHIELD =23; int CE_DARKNESS =24; int CE_DAZED =25; int CE_DEAF =26; int CE_DEATH =27; int CE_DISAPPEAR =28; int CE_DISEASE =29; int CE_DISPELMAGICALL =30; int CE_DISPELMAGICBEST =31; int CE_DOMINATED =32; int CE_ENTANGLE =33; int CE_FRIGHTENED =34; int CE_HASTE =35; int CE_HEAL =36; int CE_HITPOINTCHANGEWHENDYING =37; int CE_IMMUNITY =38; int CE_INVISBILTY =39; int CE_KNOCKDOWN =40; int CE_LINKEFFECTS =41; int CE_MISSCHANCE =42; int CE_MODIFYATTACKS =43; int CE_MOVEMENTSPEEDDECREASE =44; int CE_MOVEMENTSPEEDINCREASE =45; int CE_NEGATIVELEVEL =46; int CE_PARALYZE =47; int CE_POISON =48; int CE_POLYMORPH =49; int CE_REGENERATE =50; int CE_RESURRECTION =51; int CE_SANCTUARY =52; int CE_SAVINGTHROWDECREASE =53; int CE_SAVINGTHROWINCREASE =54; int CE_SEEINVISBLE =55; int CE_SILENCE =56; int CE_SKILLDECREASE =57; int CE_SKILLINCREASE =58; int CE_SLEEP =59; int CE_SLOW =60; int CE_SPELLIMMUNITY =61; int CE_SPELLLEVELABSORPTION =62; int CE_SPELLRESISTANCEDECREASE =63; int CE_SPELLRESISTANCEINCREASE =64; int CE_STUNNED =65; int CE_SUMMONCREATURE =66; int CE_SWARM =67; int CE_TEMPORARYHITPOINTS =68; int CE_TIMESTOP =69; int CE_TRUESEEING =70; int CE_TURNED =71; int CE_TURNRESISTANCEDECREASE =72; int CE_TURNRESISTANCEINCREASE =73; int CE_ULTRAVISION =74; int CE_VISUALEFFECT =75;
//:: Declaration des fonctions de ma lib (reyan)
//probably //debuged\\ //spawn nNb creature de resref stemplate a lLocation, avec ou sans animation de spawn //va en spawn maximum nMax, si nMax=0, alors en spawn la valeur dfini par default dans la lib (par default : 5) //void SpawnXStreum( string sTemplate, location lLocation, int nNb=1, int nAnimation=FALSE, int nMax=0); //probably //debuged\\ //renvoi TRUE si lLocation exist dans cette area int GetIsLocationValid( location lLocation); //probably //debuged\\ //a appliquer a sNb, si plus de chiffre que nNorme, alors on enleve les plus a gauche //si plus cours, on rajoute des 0 devant string NormalizeNbStr( string sNbToNormalize, int nNorme); //probably //debuged\\ //transforme une location en string, de la forme sNb, avec 2 chiffres //si oStock invalid : 00 //si lLoc = lNone : 00 string LocationToString(location lLoc, object oStock); //probably //debuged\\ //a partir de sNb, recupere la location sur oStock //!! utilisation de LocationToString indispensable !! pour stockage //si location invalid : retour lNone //idem si oStock invalid location StringToLocation(string sNb, object oStock); //recupere le chiffre a droite d'une string, quelque soit le nb de caracteres string GetStringRightNb(string sString); //recupere le chiffre a gauche d'une string, quelque soit le nb de caracteres string GetStringLeftNb(string sString); //stock l'objet sur oStock //permet de choisir un emplacement vide recuparable par StringToObject //erreur : OBJECT_INVALID string CUSTOMObjectToString(object oObject, object oStock); //recupere un objet stocke sur oStock par CUSTOMObjectToString //erreur : OBJECT_INVALID object StringToObject(string sNb, object oStock); //transforme un effet en string, reconvertible plus tard en effet avec la fonction inverse. // les effets utiliss sont des constante, de la forme CE_EFFECT ou EFFECT est remplace par le nom de l'effet disr en majuscule //ex : CE_CURSE, CE_DAMAGE, etc. //laisser les reglages par default, ils sont les parametre par default des effets (exept EffectCurse, ou la valeur indique est applique, mme si c'est 0) //permet de faire un SetEffect avec un SetLocalString, et de l'executer plus tard. string EffectToSTREffect(int EFFECT, location lLocation, float fParameter = 0.0 , object oTarget = OBJECT_INVALID , int nParametre1 =0 ,int nParametre2 =0 , int nParametre3 =0 ,int nParametre4 =0 , int nParametre5 =0 ,int nParametre6 =0 , string sParametre1 ="~" , string sParametre2 ="~" , string sParametre3 ="~" , string sParametre4 ="~"); ///fonction inverse de EffectToSTREffect //recupere un effet //default : EFFECT_TYPE_INVALIDEFFECT effect STREffectToEffect(string sSTREffect); location lNone; //:: J'utilise la biblio suivante : //:: Gestion avancee des chaines de caracteres //:: inc_strings.nss //:: Copyright (c) Althea 2002 /* Bibliotheques de fonction de traitement avance des chaines de caracteres. */ //:: Créé par : Tynril //:: Créé le : 21/09/2002
// CONSTANTES // Succes de l'operation sur le Tokenizer. int StrTOKENIZER_SUCCESS = 0; // Erreur retournee si l'on essaye d'initialise un Tokenizer existant. int StrTOKENIZER_EXISTS = -1; // Erreur retournee si l'on essaye d'utiliser un Tokenizer non-initialise. int StrTOKENIZER_NOTINITIALIZED = -2; // Erreur retournee si l'on essaye d'utiliser un Tokenizer avec un Token vide. int StrTOKENIZER_EMPTYTOKEN = -3; // Erreur retournee si l'on essaye d'utiliser un Tokenizer avec une chaine vide. int StrTOKENIZER_EMPTYSTRING = -4; // PROTOTYPES DE FONCTIONS ET DECLARATIONS
// Retourne les caracteres se trouvant avant sPattern. // Exemple : StrBefore("Un chien"," ") -> "Un" // Si sPattern n'est pas trouve dans la chaine, celle-ci est retournee entiere. string StrBefore(string sSource, string sPattern); // Retourne les caracteres se trouvant apres sPattern. // Exemple : StrAfter("Un chien"," ") -> "chien" // Si sPattern n'est pas trouve dans la chaine, celle-ci est retournee entiere. string StrAfter(string sSource, string sPattern); // Replaces all instances of sReplaceMe in sSource with sNewText, and return // the altered string. If sReplaceMe is empty, then sSource is immediately // returned unaltered. string StrReplace(string sSource, string sReplaceMe, string sNewText); //::////////////////////////////////////////////// //:: Corps des fonctions de gestion des effets //:://////////////////////////////////////////////
//---------------------------GetIsLocationValid---------------------- debugged int GetIsLocationValid( location lLocation) { object oCowbay = GetNearestObjectToLocation(OBJECT_TYPE_ALL, lLocation); if(GetIsObjectValid(oCowbay)) return TRUE; else return FALSE; } //-------------------------LocationToString------------------------- string LocationToString(location lLoc, object oStock) { string sNb="01"; location lLoc2=GetLocalLocation(oStock, sBaseLoc+sNb); while(GetIsLocationValid(lLoc2)) { int nNb = StringToInt(sNb); nNb++; string s = IntToString(nNb); sNb = NormalizeNbStr(s, 2); lLoc2=GetLocalLocation(oStock, sBaseLoc+sNb); }
//sanity check !! if(!GetIsObjectValid(oStock)) oStock = GetModule(); if(lLoc == lNone) sNb = "00"; else SetLocalLocation(oStock, sBaseLoc+sNb, lLoc); return sNb;
} //-------------------------StringToLocation------------------------- location StringToLocation(string sNb, object oStock) {
//security : string sNb2 = NormalizeNbStr(sNb, 2); location lLoc = GetLocalLocation(oStock, sBaseLoc+sNb2);
//security check !! if(sNb == "00")lLoc = lNone; if(!GetIsLocationValid(lLoc)) lLoc = lNone; if(!GetIsObjectValid(oStock)) lLoc = lNone;
return lLoc;
} //-------------------------GetStringRightNb------------------------------ string GetStringRightNb(string sString) { string sStringF; string s1 = GetStringRight(sString, 1); int nL = GetStringLength(sString); nL--; string sStringM = GetStringLeft(sString, nL); //on recupere la derniere lettre et on l'enleve de la string int nNb=1; while( (s1 == "1") || (s1 == "2" ) || (s1 == "3" ) || (s1 == "4" ) || (s1 == "5" ) || (s1 == "6" ) || (s1 == "7" ) || (s1 == "8" ) || (s1 == "9" )|| (s1 == "0")) { //si la lettre teste est un chiffre, on prend la suivante nNb++; s1 = GetStringRight(sStringM, 1); nL--; //if(nL<0) s1="STOP"; //si on arrive a la fin, on stop //on enleve la lettre prise pour test sStringM = GetStringLeft(sString, nL);
} nNb--; //on recupere la ou c t valid, pas apres //PrintString("***********************nNb a la fin : "+IntToString(nNb)); sStringF = GetStringRight(sString, nNb); return sStringF; } //-------------------------GetStringRightNb------------------------------ string GetStringLeftNb(string sString) { string sStringF; PrintString("***********************String a decouper : "+sString); string s1 = GetStringLeft(sString, 1); int nL = GetStringLength(sString); nL--; string sStringM = GetStringRight(sString, nL); //on recupere la derniere lettre et on l'enleve de la string PrintString("***********************premier chiffre de la string decouper : "+s1); int nNb=1; while( (s1 == "1") || (s1 == "2" ) || (s1 == "3" ) || (s1 == "4" ) || (s1 == "5" ) || (s1 == "6" ) || (s1 == "7" ) || (s1 == "8" ) || (s1 == "9" )|| (s1 == "0")) { //si la lettre teste est un chiffre, on prend la suivante nNb++; s1 = GetStringLeft(sStringM, 1); nL--; //if(nL<0) s1="STOP"; //si on arrive a la fin, on stop //on enleve la lettre prise pour test sStringM = GetStringRight(sString, nL);
PrintString("***********************chiffre de la string decouper : "+s1); PrintString("***********************string decouper moins le chiffre pris pour test : "+sStringM); PrintString("***********************nNb : "+IntToString(nNb)); PrintString("***********************nL : "+IntToString(nL)); } nNb--; //on recupere la ou c t valid, pas apres PrintString("***********************nNb a la fin : "+IntToString(nNb)); sStringF = GetStringLeft(sString, nNb); return sStringF; } //-------------------------EffectToSTREffect------------------------------ string EffectToSTREffect(int EFFECT, location lLocation, float fParameter = 0.0 , object oTarget = OBJECT_INVALID , int nParametre1 =0 ,int nParametre2 =0 , int nParametre3 =0 ,int nParametre4 =0 , int nParametre5 =0 ,int nParametre6 =0 , string sParametre1 ="~" , string sParametre2 ="~" , string sParametre3 ="~" , string sParametre4 ="~") { string sSTREffectF; string sEffect = IntToString(EFFECT); string sFloat = FloatToString(fParameter); string sN1 = IntToString(nParametre1); string sN2 = IntToString(nParametre2); string sN3 = IntToString(nParametre3); string sN4 = IntToString(nParametre4); string sN5 = IntToString(nParametre5); string sN6 = IntToString(nParametre6); string sTarget; string sLoc;
if(lLocation != lNone) sLoc = LocationToString(lLocation, GetModule()); else sLoc = "NONE";
if(oTarget != OBJECT_INVALID) sTarget = CUSTOMObjectToString(oTarget, GetModule()); else sTarget = "NONE";
sSTREffectF = sEffect + sTok3 + sLoc + sTok3 + sFloat + sTok3 + sTarget + sTok3 + sN1 + sTok3 + sN2 + sTok3 + sN3 + sTok3 + sN4 + sTok3 + sN4 + sTok3 + sN5 + sTok3 + sN6 + sTok3 + sParametre1 + sTok3 + sParametre2 + sTok3 + sParametre3 + sTok3 + sParametre4; return sSTREffectF; } //-------------------------EffectToSTREffect------------------------------ effect STREffectToEffect(string sSTREffect) { effect eEffectF; string sEffect = StrBefore(sSTREffect, sTok3); string sStructT = StrAfter(sSTREffect, sTok3); string sLoc = StrBefore(sStructT, sTok3); string sStructT2 = StrAfter(sStructT, sTok3); string sFloat = StrBefore(sStructT2, sTok3); sStructT = StrAfter(sStructT2, sTok3); string sTarget = StrBefore(sStructT, sTok3); sStructT2 = StrAfter(sStructT, sTok3); string sN1 = StrBefore(sStructT2, sTok3); sStructT = StrAfter(sStructT2, sTok3); string sN2 = StrBefore(sStructT, sTok3); sStructT2 = StrAfter(sStructT, sTok3); string sN3 = StrBefore(sStructT2, sTok3); sStructT = StrAfter(sStructT2, sTok3); string sN4 = StrBefore(sStructT, sTok3); sStructT2 = StrAfter(sStructT, sTok3); string sN5 = StrBefore(sStructT2, sTok3); sStructT = StrAfter(sStructT2, sTok3); string sN6 = StrBefore(sStructT, sTok3); sStructT2 = StrAfter(sStructT, sTok3); string sParametre1 = StrBefore(sStructT2, sTok3); sStructT = StrAfter(sStructT2, sTok3); string sParametre2 = StrBefore(sStructT, sTok3); sStructT2 = StrAfter(sStructT, sTok3); string sParametre3 = StrBefore(sStructT2, sTok3); sStructT = StrAfter(sStructT, sTok3); string sParametre4 = StrBefore(sStructT, sTok3); object oTarget; int N1 = StringToInt(sN1); int N2 = StringToInt(sN2); int N3 = StringToInt(sN3); int N4 = StringToInt(sN4); int N5 = StringToInt(sN5); int N6 = StringToInt(sN6); int nEffect = StringToInt(sEffect); float fFloat = StringToFloat(sFloat); location lLoc;
if(sTarget != "NONE") oTarget = StringToObject(sTarget, GetModule()); else oTarget = OBJECT_INVALID;
if(sLoc != "NONE") lLoc = StringToLocation(sLoc, GetModule()); else lLoc = lNone; switch(nEffect) { case 1: eEffectF = EffectAbilityDecrease( N1, N2); break; case 2: eEffectF = EffectAbilityIncrease(N1, N2); break; case 3: if(N2==0)N2 = AC_DODGE_BONUS; if(N3 == 0) N3 = AC_VS_DAMAGE_TYPE_ALL; eEffectF = EffectACDecrease(N1, N2, N3); break; case 4: if(N2==0)N2 = AC_DODGE_BONUS; if(N3 == 0) N3 = AC_VS_DAMAGE_TYPE_ALL; eEffectF = EffectACIncrease(N1, N2, N3); break; case 5: eEffectF = EffectAppear(); break; case 6: if(sParametre1 == "~") sParametre1 =""; if(sParametre2 == "~") sParametre2 =""; if(sParametre3 == "~") sParametre3 =""; eEffectF = EffectAreaOfEffect(N1, sParametre1, sParametre2, sParametre3); break; case 7: if(N2 == 0) N2 = ATTACK_BONUS_MISC; eEffectF = EffectAttackDecrease(N1, N2); break; case 8: if(N2 == 0) N2 = ATTACK_BONUS_MISC; eEffectF = EffectAttackIncrease(N1, N2); break; case 9: if(N3 == 0) N3 = FALSE; eEffectF = EffectBeam( N1, oTarget, N2, N3); break; case 10: eEffectF = EffectBlindness(); break; case 11: eEffectF = EffectCharmed(); break; case 12: eEffectF = EffectConcealment(N1); break; case 13: eEffectF = EffectConfused(); break; case 14: eEffectF = EffectCurse(N1, N2, N3, N4, N5, N6); break; case 15: eEffectF = EffectCutsceneDominated(); break; case 16: if(N2 == 0) N2 = DAMAGE_TYPE_MAGICAL; if(N3 == 0) N3 = DAMAGE_POWER_NORMAL; eEffectF = EffectDamage(N1, N2, N3); break; case 17: if(N2 == 0) N2 = DAMAGE_TYPE_MAGICAL; eEffectF = EffectDamageDecrease(N1, N2); break; case 18: eEffectF = EffectDamageImmunityDecrease(N1, N2); break; case 19: eEffectF = EffectDamageImmunityIncrease(N1, N2); break; case 20: if(N2 == 0) N2 = DAMAGE_TYPE_MAGICAL; eEffectF = EffectDamageIncrease(N1, N2); break; case 21: eEffectF = EffectDamageReduction(N1, N2, N3); break; case 22: eEffectF = EffectDamageResistance(N1, N2, N3); break; case 23: eEffectF = EffectDamageShield(N1, N2, N3); break; case 24: eEffectF = EffectDarkness(); break; case 25: eEffectF = EffectDazed(); break; case 26: eEffectF = EffectDeaf(); break; case 27: if(N2 == 0) N2 = TRUE; eEffectF = EffectDeath(N1, N2); break; case 28: eEffectF = EffectDisappear(); break; case 29: eEffectF = EffectDisappearAppear(lLoc); break; case 30: eEffectF = EffectDisease(N1); break; case 31: eEffectF = EffectDispelMagicAll(N1); break; case 32: eEffectF = EffectDispelMagicBest(N1); break; case 33: eEffectF = EffectEntangle(); break; case 34: eEffectF = EffectFrightened(); break; case 35: eEffectF = EffectHaste(); break; case 36: eEffectF = EffectHeal(N1); break; case 37: eEffectF = EffectHitPointChangeWhenDying(fFloat); break; case 38: eEffectF = EffectImmunity(N1); break; case 39: eEffectF = EffectInvisibility(N1); break; case 40: eEffectF = EffectKnockdown(); break; case 41: break; case 42: eEffectF = EffectMissChance(N1); break; case 43: eEffectF = EffectModifyAttacks(N1); break; case 44: eEffectF = EffectMovementSpeedDecrease(N1); break; case 45: eEffectF = EffectMovementSpeedIncrease(N1); break; case 46: eEffectF = EffectNegativeLevel(N1); break; case 47: eEffectF = EffectParalyze(); break; case 48: eEffectF = EffectPoison(N1); break; case 49: eEffectF = EffectPolymorph(N1); break; case 50: eEffectF = EffectRegenerate(N1, fFloat); break; case 51: eEffectF = EffectResurrection(); break; case 52: eEffectF = EffectSanctuary(N1); break; case 53: if(N3 ==0) N3 = SAVING_THROW_TYPE_ALL; eEffectF = EffectSavingThrowDecrease(N1, N2, N3); break; case 54: if(N3 ==0) N3 = SAVING_THROW_TYPE_ALL; eEffectF = EffectSavingThrowIncrease(N1, N2, N3); break; case 55: eEffectF = EffectSeeInvisible(); break; case 56: eEffectF = EffectSilence(); break; case 57: eEffectF = EffectSkillDecrease(N1, N2); break; case 58: eEffectF = EffectSkillIncrease(N1, N2); break; case 59: eEffectF = EffectSleep(); break; case 60: eEffectF = EffectSlow(); break; case 61: if(N1 == 0) N1 = SPELL_ALL_SPELLS; eEffectF = EffectSpellImmunity(N1); break; case 62: if(N3 == 0) N3 = SPELL_SCHOOL_GENERAL; eEffectF = EffectSpellLevelAbsorption(N1, N2, N3); break; case 63: eEffectF = EffectSpellResistanceDecrease(N1); break; case 64: eEffectF = EffectSpellResistanceIncrease(N1); break; case 65: eEffectF = EffectStunned(); break; case 66: if(N1 == 0) N1 = VFX_NONE; eEffectF = EffectSummonCreature(sParametre1, N1, fFloat); break; case 67: if(sParametre2 == "~") sParametre2 =""; if(sParametre3 == "~") sParametre3 =""; if(sParametre4 == "~") sParametre4 =""; eEffectF = EffectSwarm(N1, sParametre1, sParametre2, sParametre3, sParametre4); break; case 68: eEffectF = EffectTemporaryHitpoints(N1); break; case 69: eEffectF = EffectTimeStop(); break; case 70: eEffectF = EffectTrueSeeing(); break; case 71: eEffectF = EffectTurned(); break; case 72: eEffectF = EffectTurnResistanceDecrease(N1); break; case 73: eEffectF = EffectTurnResistanceIncrease(N1); break; case 74: eEffectF = EffectUltravision(); break; case 75: eEffectF = EffectVisualEffect(N1, N2); break; default: break; } return eEffectF; } //-------------------------CUSTOMObjectToString------------------- string CUSTOMObjectToString(object oObject, object oStock) { string sNb="01";
object oObject2 =GetLocalObject(oStock, sBaseObj+sNb); while(GetIsObjectValid(oObject2)) { int nNb = StringToInt(sNb); nNb++; string s = IntToString(nNb); sNb = NormalizeNbStr(s, 2); oObject2 = GetLocalObject(oStock, sBaseObj+sNb); }
//sanity check !! if(!GetIsObjectValid(oStock)) oStock = GetModule(); if(oObject == OBJECT_INVALID) sNb = "00"; else SetLocalObject(oStock, sBaseObj+sNb, oObject); return sNb; } //-------------------------StringToObject------------------------- object StringToObject(string sNb, object oStock) { //security : string sNb2 = NormalizeNbStr(sNb, 2); object oObject = GetLocalObject(oStock, sBaseObj+sNb2); //security check !! if(sNb == "00")oObject == OBJECT_INVALID; return oObject; } //-------------------------NormalizeNbStri--------------------- debugged string NormalizeNbStr( string sNbToNormalize, int nNorme) { string sF; int nTaille=GetStringLength(sNbToNormalize); if(nTaille > nNorme) { sF = GetStringRight(sNbToNormalize, nNorme); } else { int nDif = nNorme; nDif -= nTaille; sF=sNbToNormalize; string sF2 = sNbToNormalize; while(nDif > 0) { sF = "0"+sF2; nDif--; sF2 = "0"+sF2; } } return sF; } string StrBefore(string sSource, string sPattern) { int iMarker; string sResult;
// Sanity check! if ((sPattern == "") || (sSource == "")) return sSource;
iMarker = FindSubString(sSource,sPattern);
if (iMarker >= 0) { sResult = GetSubString(sSource,0,iMarker); } else { sResult = sSource; }
return sResult; } string StrAfter(string sSource, string sPattern) { int iMarker, iMarkerLength; string sResult;
// Sanity check! if ((sPattern == "") || (sSource == "")) return "";
iMarkerLength = GetStringLength(sPattern); iMarker = FindSubString(sSource,sPattern);
if (iMarker >= 0) { sResult = GetSubString(sSource,iMarker + iMarkerLength, GetStringLength(sSource) - (iMarker + iMarkerLength)); } else { sResult = ""; }
return sResult; } string StrReplace(string sSource, string sReplaceMe, string sNewText) { string sResult; int marker;
// Sanity check! if (sSource == "") return "";
// Sanity check! if (sReplaceMe == "") return sSource;
sResult = sSource; while ((marker = FindSubString(sResult, sReplaceMe)) >= 0) {
// Isn't it nice to be able to reuse your own library functions? sResult = StrBefore(sResult, sReplaceMe) + sNewText + StrAfter(sResult, sReplaceMe);
}
return sResult; }
bon, g amputé de certain trucs et de qq annotations, pour la faire passer ... donc si c illisible .. ba je réanoterais :-/
|