SRL Archive - OSR Help

Problem with arrays


weequ

2010-07-20 14:35:47

  ClanChats[19].Name := 'hunt4stars';
ClanChats[19].Msg[0][0] := 'Join "Merch Item" to make millions while hunting stars!';
ClanChats[19].Msg[1] := DefaultMsg;//PROBLEM HERE
[Runtime Error] : Type Mismatch in line 29 in script C:\Program Files\SCAR 3.23\Scripts\CCStealerLobby.scar

type
CCInfo = record
Name: String;
Msg: Array[0..5] of Array[0..5] of String;
end;

var
Viestit: Array of String;
DefaultMsg: Array[0..5] of String;
ClanChats: Array[0..50] of CCInfo;
StartIndex, ChatIndex, Pmed: Integer;
Name: String;
[Runtime Error] : Type Mismatch in line 29 in script C:\Program Files\SCAR 3.23\Scripts\CCStealerLobby.scar

Shuttleu

2010-07-20 14:37:16

what line is line 29?

~shut

EDIT: oh i see
ClanChats[19].Msg[1] := DefaultMsg;
should be
ClanChats[19].Msg[1][0] := DefaultMsg;
the second 0 could be another number, but it must be in the array

what you were trying to do is assign a string to a array of string

weequ

2010-07-20 18:14:52

From: Shuttleu
what line is line 29?

~shut

EDIT: oh i see
ClanChats[19].Msg[1] := DefaultMsg;
should be
ClanChats[19].Msg[1][0] := DefaultMsg;
the second 0 could be another number, but it must be in the array

what you were trying to do is assign a string to a array of string

Check again becouse DefaultMsg is an array of String.

Narcle

2010-07-20 18:20:53

Try SetArrayLength instead of preset lengths when you declare them.

Edit:
I'm thinking bc its Declared with a set length its giving that error. So if you set just the array length to 5 then leave the sub array length to its own device instead.

Frement

2010-07-20 18:28:50

How about
ClanChats[19].Msg := DefaultMsg;

Narcle

2010-07-20 18:34:48

From: Frement
How about
ClanChats[19].Msg := DefaultMsg;


Msg is a 2DArray, DefaultMsg is just a single Array.

Edit:
Yeah I was right here:

Works
program new;

var
Arr1: array of string;
AAR: array of array of string;

begin
Arr1 := ['hi', 'yo', 'sup', 'kk', 'om nom nom'];

SetArrayLength(AAR, 5);
AAR[1] := Arr1;
end.

Does NOT Work
program new;

var
Arr1: array of string;
AAR: array of array [0..4] of string;

begin
Arr1 := ['hi', 'yo', 'sup', 'kk', 'om nom nom'];

SetArrayLength(AAR, 5);
AAR[1] := Arr1;
end.

weequ

2010-07-21 00:58:05

OK thanks ill try it today.

Markus

2010-07-21 05:50:28

I reported this bug some time ago to Carlo (developer of scripting engine), and he's looking into it.