I need convert string to ACII add 1 and convert back.
Next_letter = convert(char, convert(integer, Letter) + 1)
But error:
main.pro(19,48) error c504 : The expression has type 'main::letter', which is incompatible with the type '::integer'
Full program :
/* программа prog2_8.pro */
/* генерации ряда букв а…d в столбик в порядке возрастания */
implement main
open core, console
domains
letter = string.
class predicates
write_letter : (letter).
clauses
write_letter("e").
write_letter(Letter) :-
Letter < "e",
write(" ", Letter),
nl,
Next_letter = convert(char, convert(integer, Letter) + 1),
write_letter(Next_letter).
run() :-
write("letters:"),
nl,
write_letter("a"),
fail().
run() :-
nl,
write("Press Enter"),
_ = readchar(),
succeed().
end implement main
goal
console::runUtf8(main::run).
Try the following using
char_int/2:And here
NextLettershould be what you needFrom VIP documentation
Edit
Your problem is that a
stringcan not be converted in its ASCII value as it is a set of characters. You have to replaceletter = stringwithletter = charand"(around your characters) with'.