Strings

15 views
Skip to first unread message

FraserSmith51

unread,
Aug 20, 2021, 9:07:01 AM8/20/21
to jallist
Hi
I want to use variables to store some short text strings. In fact I would like to have an array of those strings. I have looked through the JalV2 document but I cannot see a way of doing so.
Is it possible to do this and if so could someone please tell me how to do this?
Thanks in advance
Fraser

Rob CJ

unread,
Aug 20, 2021, 1:02:57 PM8/20/21
to jal...@googlegroups.com
Hi Fraser,

If you want to make an array of strings in a variable you cannot use the count function so when you store the string, you also need to store the length of the string with it. You can do it by using a record to keep it together.

Below something that I think should work. In this program I fill the string with spaces and make the length 0.

const byte max_strings = 5
const byte max_string_length = 10

-- Record defining string
record my_record is
   byte string[max_string_length]
   byte length
end record

-- Variable declaration
var my_record my_array[max_strings]
var byte index, length

for max_strings using index loop 
   for max_string_length using length loop
      my_array[index].string[length] = " "
      my_array[index].length = 0
   end loop
end loop

Hope this helps.

Kind regards,

Rob



Van: jal...@googlegroups.com <jal...@googlegroups.com> namens FraserSmith51 <fra...@cairntoul.net>
Verzonden: vrijdag 20 augustus 2021 15:07
Aan: jallist <jal...@googlegroups.com>
Onderwerp: [jallist] Strings
 
--
You received this message because you are subscribed to the Google Groups "jallist" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallist+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jallist/8e67edfa-1f04-4e56-b6e9-07092c55db1en%40googlegroups.com.

FraserSmith51

unread,
Aug 20, 2021, 3:15:08 PM8/20/21
to jallist
Thanks Rob
I shall try that in the next few days. Off to visit son tomorrow and an early start so I might not get to it this evening but there will be time while away.
Thanks again as ever
Fraser
Reply all
Reply to author
Forward
0 new messages