PrefixSuffixRound

Short description

Purpose: Add or remove prefixes and suffixes (with wildcard patterns) and round numeric text content for TEXT/MTEXT/ATTRIB/INSERT attributes Core idea: Use fixed-string and wildcard-based string comparisons to strip or template-rebuild text, plus optional rounding of numeric strings Persistence: Remembers last-used settings in environment variables (PSOT_*) for fast reuse across sessions and commands
prefixsuffixround 000

Command:

Main command: PREF_SUFF_OKR_TXT — opens the Prefix/Suffix/Round dialog and applies the chosen operation Quick commands:PREF — uses stored prefix Add/Remove values and applies prefix operation directlySUFF — uses stored suffix Add/Remove values and applies suffix operation directlyOKR_TXT — uses stored digit count and rounds numeric text directly Selection: Prompts to select TEXT, MTEXT, INSERT (first ATTRIB only), and standalone ATTRIB entities for processing

Description:

The routine provides a DCL-based interface where you can choose between three actions: Prefix, Suffix, or Digits (rounding). Depending on the row selected, you can specify Add and Remove templates for prefix or suffix, or a number of digits for rounding numeric text. Prefix and Suffix operations support both fixed strings and wildcard templates that can capture parts of the original text and reinsert them using “*” and “?” placeholders, while the Remove side can strip matching patterns or wildcards from the beginning or end. The rounding option scans text content and converts numeric-only strings to rounded values with the specified number of decimal digits, leaving nonnumeric text unchanged. All operations can be reused without reopening the dialog by calling the PREF, SUFF, or OKR_TXT helper commands that rely on stored values.

Helper function: (if any)​

PSOT-Get / PSOT-Put — Read and write persistent settings (PSOT_ACT, PSOT_PFX_ADD, PSOT_PFX_REM, PSOT_SFX_ADD, PSOT_SFX_REM, PSOT_DIG) via environment variablesPSOT-Starts-With / PSOT-Ends-With — Simple string prefix/suffix checks for non-wildcard patternsPSOT-Reverse — Reverses a string to help implement suffix wildcard matching via prefix logicPSOT-Pattern-All-Stars — Verifies if the rest of the wildcard pattern consists only of “*” charactersPSOT-WC-Match-CAP-Core — Core recursive wildcard matcher with capture, handling “*” and “?” and returning match length and captured substringPSOT-WC-Prefix-Match-CAP / PSOT-WC-Suffix-Match-CAP — Anchored wildcard matching at start or end of a string, with capture supportPSOT-Has-Wild — Detects whether a string contains “*” or “?” wildcardsPSOT-ReplaceAllChar — Replaces all occurrences of a single character in a string with a replacement substringPSOT-Template-Apply — Applies a template string to a source text by replacing “?” and “*” with the original textPSOT-AddPrefix / PSOT-AddSuffix — Adds fixed or wildcard-templated prefix/suffix to the textPSOT-RemovePrefix / PSOT-RemoveSuffix — Removes fixed or wildcard-templated prefix/suffix, keeping captured wildcard portions where appropriatePSOT-RoundNumberString — Parses a numeric string with distof and formats it with rtos to a given number of decimal digitsPSOT-EntType / PSOT-ReadText / PSOT-WriteText — Small wrappers for reading/writing DXF group 1 text content based on entity typePSOT-FirstAttribOfInsert — Finds the first ATTRIB under an INSERT by walking entnext links until ATTRIB or SEQEND is foundPSOT-Transform — Dispatches text through the appropriate transform operation (prefix add/remove, suffix add/remove, or rounding)PSOT-ProcessOne-Op — Applies the chosen transform to a single entity, including first attribute of a block insert when applicablePSOT-Iterate-Selection-Op — Prompts selection and loops through the selection set, calling PSOT-ProcessOne-Op for each entityPSOT-TempDclFile / PSOT-RunDialog — Build, load, and manage the temporary DCL dialog, including enabling/disabling inputs based on selected radio button and saving the user’s last choices

Functionalities:

Prefix add/remove — Add or strip prefixes to/from text, with either literal strings or wildcard patterns that can embed or preserve parts of the original textSuffix add/remove — Add or strip suffixes similarly, with anchored wildcard matching at the end of the stringWildcard templates — Patterns can use “*” and “?” such that the original text is reinserted into a new structured form (e.g., “PRE_*_SUF”, “?OLD?”)Safe numeric rounding — Numeric-only texts are converted to rounded values with a given number of decimal digits, while non-numeric text is left unchangedPer-entity text source — For INSERT, only the first attribute’s text is modified; for TEXT/MTEXT/ATTRIB, the DXF 1 text string is directly editedDialog radio logic — Uses USERR1 system variable and radio buttons to switch between Prefix, Suffix, and Digits modes, enabling/disabling relevant input fields dynamicallyPersistent UI state — Stores the last active mode and input values (prefix/suffix add/remove strings and rounding digits) so they appear pre-filled next timeOne-shot and quick commands — You can run the full dialog via PREF_SUFF_OKR_TXT or quickly reapply the last stored prefix, suffix, or rounding via PREF, SUFF, OKR_TXT

Result:

Transformed text entities — Selected TEXT, MTEXT, ATTRIB, and first attributes of INSERTs have their string content updated based on the chosen prefix, suffix, or rounding rulesCleaned prefixes/suffixes — Unwanted leading or trailing patterns can be removed, even when partially matched with wildcards, while keeping important captured segmentsFormatted numeric text — Number-only labels can be normalized to a consistent decimal precision using the Digits modeBatch processing summary — After selection, the routine reports how many items were processed, giving quick feedback on scopeReusable configuration — Users can repeat transformations on new selections without reconfiguring, thanks to stored PSOT_* environment values and helper commands PREF, SUFF, and OKR_TXT

Images, animations etc.

Pixel

Additional info:

Share this page:

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x