Page 1 of 1
UID & Decision Legal characters and Length limit 07/12/2021 at 23:34 #142804 | |
rfw
177 posts |
Again a question really for core code devs, but belongs here due to topic. The Wiki describes UIDs to beQuote: Unique ID(https://www.SimSig.co.uk/Wiki/Show?page=usertrack:ssrun:func:f4:wttnew) The Wiki decribes decision name advice as Quote: A decision or choice name can be any string, except that leading and trailing spaces are ignored and names cannot begin with a square bracket. Names are case-sensitive, so "SpecialTrain", "Specialtrain", "SPECIALTRAIN", "Special Train", and "Special train" are all different decisions. You can have consecutive spaces, so "A B" and "A B" are different decisions, but the timetable analyser will warn you if you do this since it's hard to spot.(https://www.SimSig.co.uk/Wiki/Show?page=usertrack:ttuse:ttdecisions) A) What are the legally allowed characters that can be used in a UID? (alpha-numeric?) B) What is the maximum legal length for a UID? C) What are the legally allowed characters that can be used in a Decision name? (alpha-numeric plus special characters?) D) What is the maximum legal length for a Decision name? E) What are the legally allowed characters that can be used in a Decision Choice? (alpha-numeric plus special characters?) F) What is the maximum legal length for a Decision Choice? G) For the above, which character set is being used? Reason for asking. I'm planning my Friday 13th timetable and want to embed some train characteristic info in the UID (using a custom format) that will be referenced by decisions & choices in a logical manner, so I want to know what my restraints are for this. -RFW The train now standing on platform 2, should be on the rails Last edited: 07/12/2021 at 23:39 by rfw Reason: Removed URLs from [Quote] tag as they didn't work as anticipated. Is there a way to quote the wiki like when quoting a user? Log in to reply |
UID & Decision Legal characters and Length limit 08/12/2021 at 11:41 #142815 | |
clive
2789 posts |
Okay, this isn't trivial to answer and I don't have everything I need in front of me, but I'll try. The programming language the Loader is written in treats strings as a first-class type and does not put a limit on their length (I suspect it uses a 32-bit length indicator internally). So the immediate answer to D and F is "no limit". That may well also be the answer for B, but I haven't done a specific check as UIDs aren't one of my things. Any code that I've written just does a straight compare. In general we don't use fixed buffers in our code for things that can be strings. However, the dialogue boxes used for entering and displaying the strings may have limits in them or may make it hard to see long strings. I also know that some code used to truncate strings for display (e.g. station names in some timetable displays were truncated to 20 characters; I don't know if that ever got fixed). You will have to live with this, though if something is particularly painful mention it on the forum and someone will raise a Mantis bug for it. To answer G, strings are treated as sequences of bytes that are at least 8 bits wide. I have never tried entering a character that isn't in the range U+0020 to U+007E (such as an accented letter or a thorn) as a UID, decision, or choice, so I don't what will happen. Feel free to try it and report back. Characters in that range are ASCII/UTF-8. I can't answer A because I haven't looked at that code to see it there's anything odd in it. I suspect, however, that it just compares strings so won't care. For C and E, what the manual says is correct as far as it goes: after trimming off leading and trailing spaces, if the name doesn't begin with an open bracket ("["} then it can contain any characters you want - all that happens is that the code does a string compare for equality. HOWEVER, some features won't work with decisions or choices containing certain characters. For example, you can include vertical bar ("|"in a choice but you can't use that choice with "[any]" or "[not]" because those use vertical bar as a delimiter. Stuff in the pipeline might also have problems with embedded brackets. So I would *suggest* that you limit yourself to: * letters in either case * digits * single spaces * the punctuation characters: ! # $ % & ( ) * + , - . / _ I guarantee that if you don't start the name with an opening bracket it will work as a simple decision or choice. But I reserve the right to use characters outside the above list as part of special decisions or choices, so such names might not be usable everywhere that names limited to that character set are. Log in to reply The following users said thank you: bill_gensheet, rfw |