๐ฏ What is creocc?
The creocc statement in Uniface 10.4 is a powerful tool that creates empty occurrences of specified entities. Think of it as your data structure builder - it prepares empty containers where you can later store your actual data! ๐ฆ
๐ Syntax
creocc Entity, OccurrenceNumber
Example:
creocc "P_ORDER", -1
๐ Parameters Breakdown
| Parameter | Data Type | Description |
|---|---|---|
Entity |
String | Name of the entity where an occurrence will be created |
OccurrenceNumber |
Number | Integer value (truncated if decimal) specifying position |
๐ Return Values & Error Handling
$status Values:
- < 0: โ Error occurred (check $procerror for details)
- >= 0: โ Statement executed successfully
Common Error Codes:
- -1102 (UPROCERR_ENTITY): Invalid entity name or entity not painted on component
- -1203 (UPROCERR_RANGE): Occurrence number out of range
๐ฎ How OccurrenceNumber Works
The magic happens based on the OccurrenceNumber value:
- < 0: ๐ Appends occurrence after the last one ($hits+1)
- = 0: ๐ Inserts before current occurrence (shifts sequence numbers)
- 1 to $hits+1: ๐ฏ Creates occurrence at specified position
- > $hits+1: โ ๏ธ Sets $status to -1, no occurrence created
๐ก Real-World Example: Video Database Conversion
Here's a practical example showing how creocc converts raw text data into structured occurrences:
operation exec
retrieve "VIDEO_DONE" ; get video data (text)
setocc "VIDEO_DATA", 1 ; position at first occurrence
$10 = 0 ; zero counter
repeat
message/nobeep "loop counter = %%$10"
creocc "VIDEO_DONE", -1 ; make an empty occurrence
if ($status < 0)
break
endif
; Transfer data from text to structured format
V_NUM.VIDEO_DONE = TAPE_NUM.VIDEO_DATA
; Convert start time
$1 = START
call TEXT_TO_TIME
V_START = $2
; Convert end time
$1 = end
call TEXT_TO_TIME
V_END = $2
; Concatenate title fields
V_TITLE_1.VIDEO_DONE = "%%TITLE_1.VIDEO_DATA%%TITLE_1A.VIDEO_DATA"
V_TITLE_2.VIDEO_DONE = "%%TITLE_2.VIDEO_DATA%%TITLE_2A.VIDEO_DATA"
$10 = $10 + 1
setocc "VIDEO_DATA", ($curocc + 1)
if ($status < 0)
break
endif
until ($10 = $hits)
edit
end; exec
๐ฏ Key Takeaways
- Versatility: Works in all Uniface component types ๐
- Smart Positioning: Flexible occurrence placement with negative, zero, and positive values
- Error Handling: Built-in status checking for robust applications ๐ก๏ธ
- Data Migration: Perfect for converting unstructured data to structured formats
๐ Pro Tips
Remember: If your entity only has a default empty occurrence, the first
creoccwon't add an additional one - but subsequent calls will! This behavior helps maintain clean data structures. ๐งน
Happy coding with Uniface! ๐
Based on Uniface Documentation 10.4 | Created with AI assistance
Top comments (0)