Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

Rat

Rat( <cCaractere>, <cString> )

Returns the last position of one text inside another string.

StringsSearchText
01 · OVERVIEW

Overview

Returns the last position of one text inside another string. This page was created from the historical training material and structured for quick reference, with practical notes and cautious use in current Protheus environments.

02 · SYNTAX

Syntax

Rat( <cCaractere>, <cString> )

Parameters

cCaractere
CharacterRequired

Parameter used by the function. Check the Portuguese source page for the detailed original wording while this entry remains under review.

cString
CharacterRequired

Parameter used by the function. Check the Portuguese source page for the detailed original wording while this entry remains under review.

03 · PRACTICAL EXAMPLE

Getting a file extension

User Function ExRat()
    Local cFile := "final.report.pdf"
    Local nDot := Rat(".", cFile)

    If nDot > 0
        MsgInfo("Extension: " + SubStr(cFile, nDot + 1))
    EndIf
Return
Expected result

Rat() finds the last dot and allows extracting the pdf extension.

BEST PRACTICES
  • Use At() quando quiser a primeira ocorrência.
  • Combine com SubStr() para extrair a parte final de um texto.
COMMON PITFALLS
  • This entry is under review because it was structured from historical training material.
  • Confirm behavior in the Protheus/AppServer release used in your environment.

Related content

REFERENCES
  1. Programação em ADVPL Completo. Training material recorded in the official documentation, section 4.5.4, p. 45-50. Summarized, reviewed and examples adapted.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha