4D v12.4

ARRAY TO STRING LIST

Home

 
4D v12.4
ARRAY TO STRING LIST

 

ARRAY TO STRING LIST 


 

ARRAY TO STRING LIST ( strings ; resID {; resFile} ) 
Parameter Type   Description
strings  String array in String or Text array (new contents for the STR# resource)
resID  Longint in Resource ID number
resFile  DocRef in Resource file reference number, or current resource file, if omitted

The ARRAY TO STRING LIST command creates or rewrites the string list (“STR#”) resource whose ID is passed in resID. The contents of the resource are created from the strings passed in the array strings. The array can be a String or Text array.

If the resource cannot be added, the OK variable is set to 0 (zero).

If you pass a valid resource file reference number in resFile, the resource is added to that file. If you do not pass resFile, the resource is added to the file at the top the resource files chain (the last resource file opened).

Note: Each string of a string list resource can contain up to 255 characters.

Tip: Limit your use of string list resources to resources no more than 32K in total size, and a maximum of a few hundred strings maximum per resource.

Example  

Your database relies on a given set of fonts.

In the On Exit Database Method, you write:

  ` On Exit Database Method
 If(◊vbFontsAreOK)
    FONT LIST($atFont)
    $vhResFile:=Open resource file("FontSet")
    If(OK=1)
       ARRAY TO STRING LIST($atFont;15000;$vhResFile)
       CLOSE RESOURCE FILE($vhResFile)
    End if
 End if

In the On Startup Database Method, you write:

  ` On Startup Database Method
 ◊vbFontsAreOK:=False
 FONT LIST($atNewFont)
 If(Test path name("FontSet")#Is a document)
    $vhResFile:=Create resource file("FontSet")
 Else
    $vhResFile:=Open resource file("FontSet")
 End if
 If(OK=1)
    STRING LIST TO ARRAY(15000;$atOldFont;$vhResFile)
    If(OK=1)
       ◊vbFontsAreOK:=True
       For($vlElem;1;Size of array($atNewFont))
          If($atNewFont{$vlElem}#$atOldFont{$vlElem}))
             $vlElem:=MAXLONG
             ◊vbFontsAreOK:=False
          End if
       End for
    Else
       ◊vbFontsAreOK:=True
    End if
    CLOSE RESOURCE FILE($vhResFile)
 End if
 If(Not(◊vbFontsAreOK))
    CONFIRM("You are not using the same font set, OK?")
    If(OK=1)
       ◊vbFontsAreOK:=True
    Else
       QUIT 4D
    End if
 End if

If the resource has been written, OK is set to 1. Otherwise, it is set to 0 (zero).

 
PROPERTIES 

Product: 4D
Theme: Resources
Number: 512

The OK variable is changed by the command

 
HISTORY 

Created: 4D v6

 
SEE ALSO 

SET STRING RESOURCE
SET TEXT RESOURCE
STRING LIST TO ARRAY