0 Members and 1 Guest are viewing this topic.
Debug(VarPar : Variant; Name, Script : String);
SomeIntegers : Array of Integer;SetArraySize.... blahblah give them some values...Debug(SomeIntegers, 'SomeIntegers', ScriptName);
GetArrayLenght(VarPar); //Runtime: Could not call proc//---------------ArrayHigh(VarPar); //Runtime: Type Mismatch//---------------while (VarPar[i] <> NULL) do inc(i, 1); //Runtime: Invalid variant type conversion//---------------VarParArray : Array of Variant;VarParArray := VarPar //Runtime: Type Mismatch//---------------for i:= 0 to $FFFF do begin try Dummy := VarPar[i]; except break; end; end; //no errors (try-method), but i is always 0 (probably also type conversion error);
(VarPar as Array of Variant) //Compile: syntax error(VarPar as TvariantArray) //Runtime: type MismatchTvariantArray(VarPar) //Runtime: type Mismatch
Debug(VarPar : Variant; Name, Script: String);DebugA(VarParArray : TvariantArray; Name, Script: String);
SomeIntegers : Array of Integer;SetArraySize(Some...blahblah give them some values...Procedure SwallowVariant(Var : Variant);begin WriteLn('Hello World!');end;Procedure SwallowVariantArray(VarArray: TvariantArray);begin WriteLn('Hello Hell!')'end;SwallowVariant(SomeIntegers); //Will nicely output "Hello World", but i wont be able to use the array anymore (as stated before)SwallowVariantArray(SomeIntegers); //Gives me a runtime-error: Type Mismatch
DebugAI(IntArray : Array of Integer; Name, Script : string);varVarParArray : TvariantArray;Index : integer;begin Index := GetArrayLength(IntArray); SetArrayLength(VarParArray, Index); for i:=0 to (Index-1) do VarParArray[i] := IntArray[i]; DebugA(VarParArray, Name, ScriptName);end;
TestVar : Boolean;TestVar := true; Function VarToString(VarPar : Variant): String; //there actually exist a vartostr() procedure in delphi, but not in soldat...varParType : integer;ParValue : string;begin ParType := VarType(VarPar) and VarTypeMask; //will return an integer that is the type of variabe. VarTypeMask removes the pointer and array info. //-----some more conversions for int flt and str which DO work btw. if (ParType = 17) then begin //17 is the value for boolean if (VarPar = true) then ParValue := 'True' else ParValue := 'False'; end; Result := ParValue;end;WriteLn(VartoStr(TestVar)); //will give me a runtime: Invalid variant type conversion