Why does this array definition get the "only one-dimensional" error?

This array definition was copied and then adapted from C code in a testing function. IDN2_OK is a constant defined as 0. The definition of Punycode_Data is: (matching Var specification order)

Name As Text
Input_Length As UInt32
Input_Data() As UInt32
Expected_Output as Text
Expected_Return_Code As Integer

Var testData As Punycode_Data = Array(Array(_
“(A) Arabic (Egyptian)”, 17, Array(&h0644, _
&h064A, &h0647, &h0645, &h0627, &h0628, _
&h062A, &h0643, &h0644, &h0645, &h0648, _
&h0634, &h0639, &h0631, &h0628, &h064A, _
&h061F), “egbpdaj6bu4bxfgehfvwxn”, IDN2_OK), _
Array("(B) Chinese (simplified)", 9, Array(&h4ED6, _
&h4EEC, &h4E3A, &h4EC0, &h4E48, &h4E0D, _
&h8BF4, &h4E2D, &h6587), _
“ihqwcrb4cv8a8dqg056pqjye”, IDN2_OK), _
Array(“© Chinese (traditional)”, 9, Array(&h4ED6, _
&h5011, &h7232, &h4EC0, &h9EBD, &h4E0D, _
&h8AAA, &h4E2D, &h6587), _
“ihqwctvzc91f659drss3x8bo0yb”, IDN2_OK), _
Array("(D) Czech: Proprostnemluvesky", _
22, Array(&h0050, &h0072, &h006F, &h010D, _
&h0070, &h0072, &h006F, &h0073, &h0074, _
&h011B, &h006E, &h0065, &h006D, &h006C, _
&h0075, &h0076, &h00ED, &h010D, &h0065, _
&h0073, &h006B, &h0079), _
“Proprostnemluvesky-uyb24dma41a”, IDN2_OK), _
Array("(E) Hebrew:", 22, Array(&h05DC, &h05DE, _
&h05D4, &h05D4, &h05DD, &h05E4, &h05E9, _
&h05D5, &h05D8, &h05DC, &h05D0, &h05DE, _
&h05D3, &h05D1, &h05E8, &h05D9, &h05DD, _
&h05E2, &h05D1, &h05E8, &h05D9, &h05EA), _
“4dbcagdahymbxekheh6e0a7fei0b”, IDN2_OK), _
Array("(F) Hindi (Devanagari):", 30, Array(&h092F, _
&h0939, &h0932, &h094B, &h0917, &h0939, _
&h093F, &h0928, &h094D, &h0926, &h0940, _
&h0915, &h094D, &h092F, &h094B, &h0902, _
&h0928, &h0939, &h0940, &h0902, &h092C, _
&h094B, &h0932, &h0938, &h0915, &h0924, _
&h0947, &h0939, &h0948, &h0902), _
“i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd”, _
IDN2_OK), _
Array("(G) Japanese (kanji and hiragana):", 18, _
Array(&h306A, &h305C, &h307F, &h3093, _
&h306A, &h65E5, &h672C, &h8A9E, &h3092, _
&h8A71, &h3057, &h3066, &h304F, &h308C, _
&h306A, &h3044, &h306E, &h304B), _
“n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa”, _
IDN2_OK), _
Array("(H) Korean (Hangul syllables):", 24, Array( _
&hC138, &hACC4, &hC758, &hBAA8, &hB4E0, _
&hC0AC, &hB78C, &hB4E4, &hC774, &hD55C, _
&hAD6D, &hC5B4, &hB97C, &hC774, &hD574, _
&hD55C, &hB2E4, &hBA74, &hC5BC, &hB9C8, _
&hB098, &hC88B, &hC744, &hAE4C), _
“989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5jpsd879ccm6fea98c”, _
IDN2_OK), _
Array("(I) Russian (Cyrillic):", 28, Array(&h043F, _
&h043E, &h0447, &h0435, &h043C, &h0443, _
&H0436, &h0435, &h043E, &h043D, &h0438, _
&h043D, &H0435, &h0433, &h043E, &H0432, _
&h043E, &h0440, &h044F, &h0442, &h043F, _
&h043E, &h0440, &h0443, &h0441, &h0441, _
&h043A, &h0438), _
“b1abfaaepdrnnbgefbadotcwatmq2g4l”, IDN2_OK), _
Array("(J) Spanish: PorqunopuedensimplementehablarenEspaol", _
40, Array(&h0050, &h006F, &h0072, &h0071, _
&h0075, &h00E9, &h006E, &h006F, &h0070, _
&h0075, &h0065, &h0064, &h0065, &h006E, _
&h0073, &h0069, &h006D, &h0070, &h006C, _
&h0065, &h006D, &h0065, &h006E, &h0074, _
&h0065, &h0068, &h0061, &h0062, &h006C, _
&h0061, &h0072, &h0065, &h006E, &h0045, _
&h0073, &h0070, &h0061, &h00F1, &h006F, _
&h006C), _
“PorqunopuedensimplementehablarenEspaol-fmd56a”, _
IDN2_OK), _
Array("(K) Vietnamese:", 31, Array(&h0054, _
&h1EA1, &h0069, &h0073, &h0061, &h006F, _
&h0068, &h1ECD, &h006B, &h0068, &h00F4, _
&h006E, &h0067, &h0074, &h0068, &h1EC3, _
&h0063, &h0068, &h1EC9, &h006E, &h00F3, _
&h0069, &h0074, &h0069, &h1EBF, &h006E, _
&h0067, &h0056, &h0069, &h1EC7, &h0074), _
“TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g”, _
IDN2_OK), _
Array("(L) 3B", 8, _
Array(&h0033, &h5E74, &h0042, &h7D44, _
&h91D1, &h516B, &h5148, &h751F), _
“3B-ww4c5e180e575a65lsy2b”, IDN2_OK), _
Array("(M) -with-SUPER-MONKEYS", _
24, Array(&h5B89, &h5BA4, &h5948, &h7F8E, _
&h6075, &h002D, &h0077, &h0069, &h0074, _
&h0068, &h002D, &h0053, &h0055, &h0050, _
&h0045, &h0052, &h002D, &h004D, &h004F, _
&h004E, &h004B, &h0045, &h0059, &h0053), _
“-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n”, _
IDN2_OK), _
Array("(N) Hello-Another-Way-", _
25, Array(&h0048, &h0065, &h006C, &h006C, _
&h006F, &h002D, &h0041, &h006E, &h006F, _
&h0074, &h0068, &h0065, &h0072, &h002D, _
&h0057, &h0061, &h0079, &h002D, &h305D, _
&h308C, &h305E, &h308C, &h306E, &h5834, _
&h6240), _
“Hello-Another-Way–fc4qua05auwb3674vfr0b”, _
IDN2_OK), _
Array("(O) 2", 8, _
Array(&h3072, &h3068, &h3064, &h5C4B, _
&h6839, &h306E, &h4E0B, &h0032), _
“2-u9tlzr9756bt3uc0v”, IDN2_OK), _
Array("§ MajiKoi5", _
13, Array(&h004D, &h0061, &h006A, &h0069, _
&h3067, &h004B, &h006F, &h0069, &h3059, _
&h308B, &h0035, &h79D2, &h524D), _
“MajiKoi5-783gue6qz075azm5e”, IDN2_OK), _
Array("(Q) de", 9, Array(&h30D1, _
&h30D5, &h30A3, &h30FC, &h0064, &h0065, _
&h30EB, &h30F3, &h30D0), “de-jg4avhby1noc0d”, _
IDN2_OK), _
Array(“® “, 7, _
Array(&h305D, &h306E, &h30B9, &h30D4, _
&h30FC, &h30C9, &h3067), “d9juau41awczczp”, _
IDN2_OK), _
Array(”(S) -> $1.00 <-”, 11, Array(&h002D, _
&h003E, &h0020, &h0024, &h0031, &h002E, _
&h0030, &h0030, &h0020, &h003C, &h002D), _
“-> $1.00 <–”, IDN2_OK) )

Don’t do this. Just create your data as JSON and then use JSON functions in Xojo to parse to arrays/dictionaries.

3 Likes

You will have to tell me EXACTLY step-by-step how to convert the C array definition to JSON if you want me to do that. My sole knowledge of JSON is that is means “JavaScript Object Notation”. I’ve never even had a reason to LOOK at JS code or JSON, much less study it.

I majored in CS from 2000 to 2003. A misdiagnosed broken back forced me to drop out without completing my degree and prevents me from returning to University as well.

The array() function in Xojo is quite simple.
it doesn’t work well with nested array() calls.

Workaround could be to read text file with CSV; JSON or XML.

You can’t mix data types in an array. You’ll have to use a different data structure.

Can you please recommend an alternative structure? All I’m familiar with is Arrays and Dictionaries.

Create a class with these properties and then parse the puny string into an array of class instances.

1 Like

I have one. I was trying to use the code I first posted as an initializer in the Class’s Constructor.

How should I go about crerating the array of class objects now?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.