Handle a bad value in BASIC
LANGUAGE GUIDE · BASIC
PCA3D BASIC spells the same idea TRY, CATCH and END TRY. A guard lets a function report the problem before it changes anything in the game.
FUNCTION Run()
DIM count = -1
TRY
ASSERT count >= 0
RETURN "Ready"
CATCH problem
RETURN "Check the count"
END TRY
END FUNCTIONThis complete BASIC record returned Check the count. The assertion interrupts the normal path. In a catch block, PRINT problem.message can give the author the original reason while the caller receives a shorter reply.
When a helper reports failure itself#
IF NOT WriteTextFile("user://notes.txt", note_text) THEN
PRINT "journal | write failed"
RETURN FALSE
END IFThis fragment belongs inside a function where note_text already contains the intended text. A file write returns a Boolean. Checking it handles an unsuccessful write even when no catchable error occurs. Tell the player the journal was saved only on the success path.
For a BASIC record, use Validate and PRINT to trace the path. The interactive Step and watch controls shown on page 9 are in the PCA Script workspace.
