/* ARM assembly Raspberry PI  */
/*  program incstring.s   */

/* Constantes    */
.equ BUFFERSIZE,   100
.equ STDIN,  0     @ Linux input console
.equ STDOUT, 1     @ Linux output console
.equ EXIT,   1     @ Linux syscall
.equ READ,   3     @ Linux syscall
.equ WRITE,  4     @ Linux syscall
/* Initialized data */
.data
szMessNum:           .asciz "Enter number : \n"
szCarriageReturn:  .asciz "\n"
szMessResult:       .ascii "Increment number is = "      @ message result
sMessValeur:        .fill 12, 1, ' '
                       .asciz "\n"

/* UnInitialized data */
.bss
sBuffer:    .skip    BUFFERSIZE

/*  code section */
.text
.global main
main:                /* entry of program  */
    push {fp,lr}    /* saves 2 registers */

    ldr r0,iAdrszMessNum
    bl affichageMess
    mov r0,#STDIN         @ Linux input console
    ldr r1,iAdrsBuffer   @ buffer address
    mov r2,#BUFFERSIZE   @ buffer size
    mov r7, #READ         @ request to read datas
    swi 0                  @ call system
    ldr r1,iAdrsBuffer    @ buffer address
    mov r2,#0                @ end of string
    strb r2,[r1,r0]         @ store byte at the end of input string (r0
    @
    ldr r0,iAdrsBuffer    @ buffer address
    bl conversionAtoD    @ conversion string in number in r0
    @ increment r0
    add r0,#1
    @ conversion register to string
    ldr r1,iAdrsMessValeur
    bl conversion10S       @ call conversion
    ldr r0,iAdrszMessResult
    bl affichageMess            @ display message

100:   /* standard end of the program */
    mov r0, #0                  @ return code
    pop {fp,lr}                 @restaur 2 registers
    mov r7, #EXIT              @ request to exit program
    swi 0                       @ perform the system call

iAdrsMessValeur:        .int sMessValeur
iAdrszMessNum:           .int szMessNum
iAdrsBuffer:             .int sBuffer
iAdrszMessResult:       .int szMessResult
iAdrszCarriageReturn:  .int szCarriageReturn
/******************************************************************/
/*     display text with size calculation                         */
/******************************************************************/
/* r0 contains the address of the message */
affichageMess:
    push {fp,lr}    			/* save  registres */
    push {r0,r1,r2,r7}    		/* save others registers */
    mov r2,#0   				/* counter length */
1:      /* loop length calculation */
    ldrb r1,[r0,r2]  			/* read octet start position + index */
    cmp r1,#0       			/* if 0 its over */
    addne r2,r2,#1   			/* else add 1 in the length */
    bne 1b          			/* and loop */
                                /* so here r2 contains the length of the message */
    mov r1,r0        			/* address message in r1 */
    mov r0,#STDOUT      		/* code to write to the standard output Linux */
    mov r7, #WRITE             /* code call system "write" */
    swi #0                      /* call systeme */
    pop {r0,r1,r2,r7}     		/* restaur others registers */
    pop {fp,lr}    				/* restaur des  2 registres */
    bx lr	        			/* return  */

 /******************************************************************/
/*     Convert a string to a number stored in a registry          */
/******************************************************************/
/* r0 contains the address of the area terminated by 0 or 0A */
/* r0 returns a number                           */
conversionAtoD:
    push {fp,lr}         @ save 2 registers
    push {r1-r7}         @ save others registers
    mov r1,#0
    mov r2,#10           @ factor
    mov r3,#0            @ counter
    mov r4,r0            @ save address string -> r4
    mov r6,#0            @ positive sign by default
    mov r0,#0            @ initialization to 0
1:     /* early space elimination loop */
    ldrb r5,[r4,r3]     @ loading in r5 of the byte located at the beginning + the position
    cmp r5,#0            @ end of string -> end routine
    beq 100f
    cmp r5,#0x0A        @ end of string -> end routine
    beq 100f
    cmp r5,#' '          @ space ?
    addeq r3,r3,#1      @ yes we loop by moving one byte
    beq 1b
    cmp r5,#'-'          @ first character is -
    moveq r6,#1         @  1 -> r6
    beq 3f              @ then move on to the next position
2:   /* beginning of digit processing loop */
    cmp r5,#'0'          @ character is not a number
    blt 3f
    cmp r5,#'9'          @ character is not a number
    bgt 3f
    /* character is a number */
    sub r5,#48
    umull r0,r1,r2,r0         @ multiply par factor 10
	cmp r1,#0           @ overflow ?
    bgt 99f            @ overflow error
    add r0,r5            @ add to  r0
3:
    add r3,r3,#1         @ advance to the next position
    ldrb r5,[r4,r3]     @ load byte
    cmp r5,#0            @ end of string -> end routine
    beq 4f
    cmp r5,#0x0A            @ end of string -> end routine
    beq 4f
    b 2b                 @ loop
4:
    cmp r6,#1            @ test r6 for sign
    moveq r1,#-1
    muleq r0,r1,r0       @ if negatif, multiply par -1
    b 100f
99:  /* overflow error */
    ldr r0,=szMessErrDep
    bl   affichageMess
    mov r0,#0      @ return  zero  if error
100:
    pop {r1-r7}          @ restaur other registers
    pop {fp,lr}          @ restaur   2 registers
    bx lr                 @return procedure
/* constante program */
szMessErrDep:  .asciz  "Too large: overflow 32 bits.\n"
.align 4

/***************************************************/
/*  Converting a register to a signed decimal      */
/***************************************************/
/* r0 contains value and r1 area address    */
conversion10S:
    push {r0-r4,lr}    @ save registers
    mov r2,r1       /* debut zone stockage */
    mov r3,#'+'     /* par defaut le signe est + */
    cmp r0,#0       @ negative number ?
    movlt r3,#'-'   @ yes
    mvnlt r0,r0     @ number inversion
    addlt r0,#1
    mov r4,#10       @ length area
1:  @ start loop
    bl divisionpar10
    add r1,#48   @ digit
    strb r1,[r2,r4]  @ store digit on area
    sub r4,r4,#1      @ previous position
    cmp r0,#0          @ stop if quotient = 0
    bne 1b

    strb r3,[r2,r4]  @ store signe
    subs r4,r4,#1    @ previous position
    blt  100f        @ if r4 < 0 -> end

    mov r1,#' '   @ space
2:
    strb r1,[r2,r4]  @store byte space
    subs r4,r4,#1    @ previous position
    bge 2b           @ loop if r4 > 0
100:
    pop {r0-r4,lr}   @ restaur registers
    bx lr

/***************************************************/
/*   division par 10   signé                       */
/* Thanks to http://thinkingeek.com/arm-assembler-raspberry-pi/*
/* and   http://www.hackersdelight.org/            */
/***************************************************/
/* r0 dividende   */
/* r0 quotient */
/* r1 remainder  */
divisionpar10:
    /* r0 contains the argument to be divided by 10 */
    push {r2-r4}   /* save registers  */
    mov r4,r0
    ldr r3, .Ls_magic_number_10 /* r1 <- magic_number */
    smull r1, r2, r3, r0   /* r1 <- Lower32Bits(r1*r0). r2 <- Upper32Bits(r1*r0) */
    mov r2, r2, ASR #2     /* r2 <- r2 >> 2 */
    mov r1, r0, LSR #31    /* r1 <- r0 >> 31 */
    add r0, r2, r1         /* r0 <- r2 + r1 */
    add r2,r0,r0, lsl #2   /* r2 <- r0 * 5 */
    sub r1,r4,r2, lsl #1   /* r1 <- r4 - (r2 * 2)  = r4 - (r0 * 10) */
    pop {r2-r4}
    bx lr                  /* leave function */
    .align 4
.Ls_magic_number_10: .word 0x66666667


num: "12349"

print ["The next number is:" (to :integer num)+1]


string cadena = "12345.78";
cadena = string((real)cadena + 1);
write(cadena);


numberString ::= "1080";
incremented ::= numberString (base 10) + 1;


      num$ = "567"
      REPEAT
        PRINT num$
        PROCinc$(num$)
      UNTIL FALSE
      END

      DEF PROCinc$(RETURN n$)
      LOCAL A$, I%
      I% = LEN(n$)
      REPEAT
        A$ = CHR$(ASCMID$(n$,I%) + 1)
        IF A$=":" A$ = "0"
        MID$(n$,I%,1) = A$
        I% -= 1
      UNTIL A$<>"0" OR I%=0
      IF A$="0" n$ = "1" + n$
      ENDPROC


s = "1234"
s = (int.Parse(s) + 1).ToString()


#Convert to integer, increment, then back to string
p ("100".to_i + 1).to_s  #Prints 101


#include <stdio.h>
#include <string.h>
#include <stdlib.h>

/*  Constraints: input is in the form of (\+|-)?[0-9]+
 *  and without leading zero (0 itself can be as "0" or "+0", but not "-0");
 *  input pointer is realloc'able and may change;
 *  if input has leading + sign, return may or may not keep it.
 *  The constranits conform to sprintf("%+d") and this function's own output.
 */
char * incr(char *s)
{
	int i, begin, tail, len;
	int neg = (*s == '-');
	char tgt = neg ? '0' : '9';

	/* special case: "-1" */
	if (!strcmp(s, "-1")) {
		s[0] = '0', s[1] = '\0';
		return s;
	}

	len = strlen(s);
	begin = (*s == '-' || *s == '+') ? 1 : 0;

	/* find out how many digits need to be changed */
	for (tail = len - 1; tail >= begin && s[tail] == tgt; tail--);

	if (tail < begin && !neg) {
		/* special case: all 9s, string will grow */
		if (!begin) s = realloc(s, len + 2);
		s[0] = '1';
		for (i = 1; i <= len - begin; i++) s[i] = '0';
		s[len + 1] = '\0';
	} else if (tail == begin && neg && s[1] == '1') {
		/* special case: -1000..., so string will shrink */
		for (i = 1; i < len - begin; i++) s[i] = '9';
		s[len - 1] = '\0';
	} else { /* normal case; change tail to all 0 or 9, change prev digit by 1*/
		for (i = len - 1; i > tail; i--)
			s[i] = neg ? '9' : '0';
		s[tail] += neg ? -1 : 1;
	}

	return s;
}

void string_test(const char *s)
{
	char *ret = malloc(strlen(s));
	strcpy(ret, s);

	printf("text: %s\n", ret);
	printf("  ->: %s\n", ret = incr(ret));
	free(ret);
}

int main()
{
	string_test("+0");
	string_test("-1");
	string_test("-41");
	string_test("+41");
	string_test("999");
	string_test("+999");
	string_test("109999999999999999999999999999999999999999");
	string_test("-100000000000000000000000000000000000000000000");

	return 0;
}


string s = "12345";
s = (int.Parse(s) + 1).ToString();
// The above functions properly for strings >= Int32.MinValue and
//  < Int32.MaxValue. ( -2147483648 to 2147483646 )

// The following will work for any arbitrary-length integer string.
//  (Assuming that the string fits in memory, leaving enough space
//  for the temporary BigInteger created, plus the resulting string):
using System.Numerics;
string bis = "123456789012345678999999999";
bis = (BigInteger.Parse(bis) + 1).ToString();
// Note that extremely long strings will take a long time to parse
//  and convert from a BigInteger back into a string.


// standard C++ string stream operators
#include <cstdlib>
#include <string>
#include <sstream>

// inside a function or method...
std::string s = "12345";

int i;
std::istringstream(s) >> i;
i++;
//or:
//int i = std::atoi(s.c_str()) + 1;

std::ostringstream oss;
if (oss << i) s = oss.str();


shared void run() {

	"Increments a numeric string by 1. Returns a float or integer depending on the string.
	 Returns null if the string isn't a number."
	function inc(String string) =>
			if(exists integer = parseInteger(string)) then integer + 1
			else if(exists float = parseFloat(string)) then float + 1.0
			else null;

	value a = "1";
	print(a);
	value b = inc(a);
	print(b);
	value c = "1.0";
	print(c);
	value d = inc(c);
	print(d);
}


set(string "1599")
math(EXPR string "${string} + 1")
message(STATUS "${string}")


       PROGRAM-ID. increment-num-str.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  str                    PIC X(5) VALUE "12345".
       01  num                    REDEFINES str PIC 9(5).

       PROCEDURE DIVISION.
           DISPLAY str
           ADD 1 TO num
           DISPLAY str

           GOBACK
           .


(princ-to-string (1+ (parse-integer "1234")))


MODULE Operations;
IMPORT StdLog,Args,Strings;

PROCEDURE IncString(s: ARRAY OF CHAR): LONGINT;
VAR
	resp: LONGINT;
	done: INTEGER;
BEGIN
	Strings.StringToLInt(s,resp,done);
	INC(resp);
	RETURN resp
END IncString;

PROCEDURE DoIncString*;
VAR
	p: Args.Params;
BEGIN
	Args.Get(p);
	IF p.argc > 0 THEN
		StdLog.String(p.args[0] + " + 1= ");StdLog.Int(IncString(p.args[0]));StdLog.Ln
	END
END DoIncString;

END Operations.


void main() {
    import std.string;

    immutable s = "12349".succ;
    assert(s == "12350");
}


program IncrementNumericalString;

{$APPTYPE CONSOLE}

uses SysUtils;

const
  STRING_VALUE = '12345';
begin
  WriteLn(Format('"%s" + 1 = %d', [STRING_VALUE, StrToInt(STRING_VALUE) + 1]));

  Readln;
end.


var str = "42"
str = (parse(str) + 1).ToString()

//Another option:
str = (Integer(str) + 1).ToString()

//And another option using interpolation:
str = "\(parse(str) + 1)"

print(str) //Outputs 45


var value : String = "1234";
value := IntToStr(StrToInt(value) + 1);
PrintLn(value);


(number->string (1+ (string->number "665")))
    → "666"


#import <Foundation/Foundation.h>

int main()

  i := (int)'123' + 1
  s := @(i).description

  Log( '%@', s )
  return 0


s string = "12345";
s = 1 + s;  // Note: s + 1 is a string concatenation.


class
	APPLICATION

create
	make

feature {NONE}

	make
		do
			io.put_string (increment_numerical_string ("7"))
			io.new_line
			io.put_string (increment_numerical_string ("99"))
		end

	increment_numerical_string (s: STRING): STRING
			-- String 's' incremented by one.
		do
			Result := s.to_integer.plus (1).out
		end

end


import extensions;

public program()
{
    var s := "12345";
    s := (s.toInt() + 1).toString();

    console.printLine(s)
}


increment1 = fn n -> to_string(String.to_integer(n) + 1) end
# Or piped
increment2 = fn n -> n |> String.to_integer |> +1 |> to_string end

increment1.("1")
increment2.("100")


include get.e

function val(sequence s)
    sequence x
    x = value(s)
    return x[2]
end function

sequence s

s = "12345"
s = sprintf("%d",{val(s)+1})


fansh> a := "123"
123
fansh> (a.toInt + 1).toStr
124


: >string ( d -- addr n )
  dup >r dabs <# #s r> sign #> ;

: inc-string ( addr -- )
  dup count number? not abort" invalid number"
  1 s>d d+ >string rot place ;


CHARACTER(10) :: intstr = "12345", realstr = "1234.5"
INTEGER :: i
REAL :: r

READ(intstr, "(I10)") i        ! Read numeric string into integer i
i = i + 1                      ! increment i
WRITE(intstr, "(I10)") i       ! Write i back to string

READ(realstr, "(F10.1)") r
r = r + 1.0
WRITE(realstr, "(F10.1)") r


' FB 1.05.0 Win64

Function Increment (num As String) As String
  Dim d As Double = Val(num)
  Return Str(d + 1.0)
End Function

Dim num(5) As String = {"1", "5", "81", "123.45", "777.77", "1000"}
For i As Integer = 0 To 5
  Print num(i); " + 1", " = "; Increment(num(i))
Next

Print
Print "Press any key to exit"
Sleep


a = input["Enter number: "]
toString[eval[a] + 1]


include "NSLog.incl"

CFStringRef s = @"12345"
NSInteger   i

for i = 1 to 10
NSLog( @"%ld", fn StringIntegerValue( s ) + i )
next
HandleEvents


Public Sub Main()
Dim vInput As Variant = "12345"

Inc vInput
Print vInput

End


# Using built-in functions
Incr := s -> String(Int(s) + 1);

# Implementing addition
# (but here 9...9 + 1 = 0...0 since the string length is fixed)
Increment := function(s)
  local c, n, carry, digits;
  digits := "0123456789";
  n := Length(s);
  carry := true;
  while n > 0 and carry do
    c := Position(digits, s[n]) - 1;
    if carry then
      c := c + 1;
    fi;
    if c > 9 then
      carry := true;
      c := c - 10;
    else
      carry := false;
    fi;
    s[n] := digits[c + 1];
    n := n - 1;
  od;
end;

s := "2399";
Increment(s);
s;
# "2400"


package main
import "fmt"
import "strconv"
func main() {
  i, _ := strconv.Atoi("1234")
  fmt.Println(strconv.Itoa(i + 1))
}


println ((("23455" as BigDecimal) + 1) as String)
println ((("23455.78" as BigDecimal) + 1) as String)


CHARACTER string = "123     -4567.89"

   READ( Text=string) a,   b
   WRITE(Text=string) a+1, b+1 ! 124 -4566.89


put 0 into someVar
add 1 to someVar
-- without "into [field reference]" the value will appear
-- in the message box
put someVar -- into cd fld 1


software {
	string = "1"
	string += 1
	print(string)
}


s := "123"  # s is a string
s +:= 1     # s is now an integer


Home is a room.

To decide which indexed text is incremented (T - indexed text):
	let temp be indexed text;
	let temp be the player's command;
	change the text of the player's command to T;
	let N be a number;
	if the player's command matches "[number]":
		let N be the number understood;
	change the text of the player's command to temp;
	decide on "[N + 1]".

When play begins:
	say incremented "12345";
	end the story.


String s = "12345";
s = String.valueOf(Integer.parseInt(s) + 1);


let s = '9999';
let splusplus = (+s+1)+""

console.log([splusplus, typeof splusplus]) // 10000,string


$ jq -n -M -s 'map(tonumber) | add' input.txt


import Base.+
Base.:+(s::AbstractString, n::Real) = string((x = tryparse(Int, s)) isa Int ? x + 1 : parse(Float64, s) + 1)
@show "125" + 1
@show "125.15" + 1
@show "1234567890987654321" + 1


// version 1.0.5-2

/** overload ++ operator to increment a numeric string */
operator fun String.inc(): String =
    try {
        val num = this.toInt()
        (num + 1).toString()
    }
    catch(e: NumberFormatException) {
        this  // return string unaltered
    }

fun main(args: Array<String>) {
    var ns = "12345"
    println(++ns)
    ns = "ghijk"  // not numeric, so won't be changed by increment operator
    println(++ns)
}


In lambdatalk every expression is a word or an S-expression, so:

{b hello world}     // means "boldify the words hello and world"
-> < b>hello world< /b>     // HTML expression

{+ hello world}     // means "add the words hello and world"
-> NaN              // can't do the job and returns Not a Number

{+ 123 1}           // means "add the words 123 and 1"
-> 124              // can do the job and returns the result as a word


\documentclass{minimal}
\newcounter{tmpnum}
\newcommand{\stringinc}[1]{%
    \setcounter{tmpnum}{#1}%
    \stepcounter{tmpnum}%
    \arabic{tmpnum}%
}
\begin{document}
The number 12345 is followed by \stringinc{12345}.
\end{document}


'   [RC] Increment a numerical string.

o$ ="12345"
print o$

v  =val( o$)
o$ =str$( v +1)
print o$

end


##
   Increment a numerical string, in LIL
##
set a "41"
inc a
print $a


put "0" & "1234" into myString -- I think this will result in an internal string representation
add 1 to myString -- automatically converts to a number
put "The number is:" && myString
-- outputs "The number is: 1235"


number_chars(Number, "123"), Number2 is Number+1, number_chars(Number2, String2)


HAI 1.3

I HAS A foo ITZ "1234"
foo R SUM OF foo AN 1
VISIBLE foo BTW, prints 1235

KTHXBYE


default {
	state_entry() {
		llListen(PUBLIC_CHANNEL, "", llGetOwner(), "");
		llOwnerSay("Say a Number and I'll Increment it.");
	}
	listen(integer iChannel, string sName, key kId, string sMessage) {
		llOwnerSay("You said '"+sMessage+"' + 1 = "+(string)(((integer)sMessage)+1));
	}
}


> -- A STRING THAT CAN BE IMPLICITLY CONVERTED TO A NUMBER
> s = "1234"
> s+1 -- implicitly convert to number, add 1, remain a number
1235
> type(s+1)
number
> (s+1)..'' -- implicitly convert to number, add 1, implicitly convert back to string
1235
> type((s+1)..'')
string
> tostring(s+1) -- implicitly convert to number, add 1, explicitly convert back to string
1235
> type(tostring(s+1))
string
> -- A STRING THAT CANNOT BE IMPLICITLY CONVERTED TO A NUMBER
> s = "hello"
> s+1
stdin:1: attempt to add a 'string' with a 'number'
stack traceback:
        [C]: in metamethod 'add'
        stdin:1: in main chunk
        [C]: in ?
> -- ONE-LINER EXPLICIT VERSION
> tostring(tonumber("1234")+1)
1235


Module CheckIt {
      s$ = "12345"
      s$ = STR$(VAL(s$) + 1,"")
      Print S$
      \\ using , for decimal point like in Locale 1032 for Greece
      s$ = "123,45"
      \\ we get value in Locale 1032
      S$=Str$(VAL(s$,",") + 1, 1032)
}
CheckIt


define(`V',`123')dnl
define(`VN',`-123')dnl
eval(V+1)
eval(VN+1)


s := "12345";
s := convert(parse(s)+1, string);


function numStr = incrementNumStr(numStr)
    numStr = num2str(str2double(numStr) + 1);
end


str = "12345"
str = ((str as integer) + 1) as string


string s;
s := "1234";
s := decimal(scantokens(s)+1);
message s;


MODULE addstr;

IMPORT  InOut, NumConv, Strings;

VAR     str1, str2      : Strings.String;
        num             : CARDINAL;
        ok              : BOOLEAN;

BEGIN
  str1 := "12345";
  InOut.Write ('"');    InOut.WriteString (str1);       InOut.WriteString ('" + 1 = ');
  NumConv.Str2Num (num, 10, str1, ok);
  INC (num);
  NumConv.Num2Str (num, 10, str2,  ok);
  InOut.WriteString (str2);
  InOut.WriteLn
END addstr.


MODULE StringInt EXPORTS Main;

IMPORT IO, Fmt, Scan;

VAR string: TEXT := "1234";
    num: INTEGER := 0;

BEGIN
  num := Scan.Int(string);
  IO.Put(string & " + 1 = " & Fmt.Int(num + 1) & "\n");
END StringInt.


var str = "123";
var str = $string($int(str) + 1);

$print(str);


mutable str = "12345";
str = $"$(Int32.Parse(str)+1)";


/* NetRexx */

options replace format comments java crossref savelog symbols nobinary

numbers = '12345'
say numbers
numbers = numbers + 1
say numbers

return


import strutils
let next = $(parseInt("123") + 1)


MODULE addstr;

IMPORT  Out, Strings;

VAR     str1, str2      : ARRAY 9 OF CHAR;
        num, pos        : INTEGER;
        carry           : BOOLEAN;
        ch              : CHAR;

BEGIN
  str1 := "9999";
  Out.Char ('"');       Out.String (str1);      Out.String ('" + 1 = ');
  num := Strings.Length (str1) - 1;
  pos := num;
  IF  str1 [0] = '9'  THEN  INC (pos)  END;
  str2 [pos + 1] := 0X;
  carry := TRUE;
  REPEAT
    ch := str1 [num];
    IF  carry  THEN
      ch := CHR (ORD (ch) + 1)
    END;
    IF  ch > '9'  THEN
      carry := TRUE;
      ch := '0'
    ELSE
      carry := FALSE
    END;
    str2 [pos] := ch;
    DEC (num);
    DEC (pos)
  UNTIL num < 0;
  IF  carry  THEN  str2 [0] := '1'  END;
  Out.String (str2);
  Out.Ln
END addstr.


NSString *s = @"12345";
int i = [s intValue] + 1;
s = [NSString stringWithFormat:@"%i", i]


string_of_int (succ (int_of_string "1234"))


nstring = "123";
nstring = sprintf("%d", str2num(nstring) + 1);
disp(nstring);


"999" 1 + println
"999" asInteger 1 + asString println


DEFINE VARIABLE cc AS CHARACTER INITIAL "12345".

MESSAGE
   INTEGER( cc ) + 1
VIEW-AS ALERT-BOX.


{Int.toString {String.toInt "12345"} + 1}


program TestIncNumString;
type
	tMyNumString = string(20);

procedure IncMyString(var NumString: tMyNumString);
var
	i: integer;
begin
	readStr(NumString, i);
	writeStr(NumString, succ(i))
end;
//example
var
  MyNumString :tMyNumString;
BEGIN
  MyNumString := '12345';
  write(MyNumString,' turns into ');
  IncMyString(MyNumString);
  write(MyNumString);
END.


go =>

  % integer
  Int = "123",
  println(int=Int),
  println(parse_term=Int.parse_term+1),
  println(to_int=Int.to_int+1), % assumes integer
  nl,

  % float
  Float = "122.5",
  println(float=Float),
  println(parse_term=Float.parse_term+1),
  println(to_float=Float.to_float+1),
  nl.


string number = "0";
number = (string)((int)number+1);
Result: "1"


To increment a numerical string:
Convert the numerical string to a number.
Add 1 to the number.
Put the number into the numerical string.


\newcount\acounter
\def\stringinc#1{\acounter=#1\relax%
\advance\acounter by 1\relax%
\number\acounter}
The number 12345 is followed by \stringinc{12345}.
\bye


incr_numerical_string(S1, S2) :-
	string_to_atom(S1, A1),
	atom_number(A1, N1),
	N2 is N1+1,
	atom_number(A2, N2),
	string_to_atom(S2, A2).


string$="12345"
string$=Str(Val(string$)+1)
Debug string$


/O> $ "1.2.3.4.5" $->n
... not if [ $ "not a valid integer" fail ]
... 1+
... number$ echo$
...

       Problem: not a valid integer
Quackery Stack: 12345
  Return stack: {[...] 0} {quackery 1} {[...] 11} {shell 5} {quackery 1} {[...] 4}

/O> $ "12345" $->n
... not if [ $ "not a valid integer" fail ]
... 1+
... number$ echo$
...
12346
Stack empty.


s = "12345"
s <- as.character(as.numeric(s) + 1)


#lang racket
(define next (compose number->string add1 string->number))


import String;

public str IncrNumStr(str s) = "<toInt(s) + 1>";


rebol [
	Title: "Increment Numerical String"
	URL: http://rosettacode.org/wiki/Increment_numerical_string
]

; Note the use of unusual characters in function name. Also note that
; because REBOL collects terms from right to left, I convert the
; string argument (s) to integer first, then add that result to one.

s++: func [s][to-string 1 + to-integer s]

; Examples. Because the 'print' word actually evaluates the block
; (it's effectively a 'reduce' that gets printed space separated),
; it's possible for me to assign the test string to 'x' and have it
; printed as a side effect. At the end, 'x' is available to submit to
; the 's++' function. I 'mold' the return value of s++ to make it
; obvious that it's still a string.

print [x: "-99" "plus one equals" mold s++ x]
print [x: "42" "plus one equals" mold s++ x]
print [x: "12345" "plus one equals" mold s++ x]


/*REXX program demonstrates a method how to increment a numerical string*/
count = "3"      /*REXX variables (and constants) are character strings.*/
count =  3       /*(identical to the above statement.)                  */
count = count+1  /*strings in a numerical context are treated as numbers*/
say 'sum=' count /*display the value of  COUNT  to the terminal (screen)*/

/*────────────────── The default numeric digits for REXX is  9  digits. */
/*────────────────── However, that can be increased with NUMERIC DIGITS.*/

numeric digits 15000   /*let's go ka-razy with fifteen thousand digits. */

count=copies(2,15000)  /*stressing REXX's brains with lots of  two's,   */
                       /*the above is considered a number in REXX.      */
count=count+3          /*make that last digit of  COUNT  a  "5".        */

if 1==0  then          /*let's not display this gihugeic number to term,*/
say  'count='  count   /*ya most likely don't want to display this thing*/

                       /* [↓]  show the six leftmost and rightmost digs.*/
say  'count='  left(count,6)'···'right(count,6)
                                       /*stick a fork in it, we're done.*/


string$ = "12345"
numeric = val(string$)
numeric = numeric + 1
string$ = str$(numeric)
print string$


fn next_string(input: &str) -> String {
    (input.parse::<i64>().unwrap() + 1).to_string()
}

fn main() {
    let s = "-1";
    let s2 = next_string(s);
    println!("{:?}", s2);
}


implicit def toSucc(s: String) = new { def succ = BigDecimal(s) + 1 toString }


(number->string (+ 1 (string->number "1234")))


var string: s is "12345";

s := str(succ(integer parse s));


import <Utilities/Conversion.sl>;

increment(input(1)) := intToString(stringToInt(input) + 1);


((Integer readFrom: '123') + 1) printString


     output = trim(input) + 1
     output = "123" + 1
end


function numStrIncmt(s) {
    return fmtstr("%d", toint(s) + 1);
}

spn:1> numStrIncmt("12345")
= 12346


put 0 into someVar
add 1 to someVar
-- without "into [field reference]" the value will appear
-- in the message box
put someVar -- into cd fld 1


:"1"→Str1
:expr(Str1)+1→A
:{0,1}→L₁
:{0,A}→L₂
:LinReg(ax+b) Y₁
:Equ►String(Y₁,Str1)
:sub(Str1,1,length(Str1)-3)→Str1


$$ MODE TUSCRIPT
teststring="0'1'-1'12345'10000000'-10000000"
LOOP/CLEAR n=teststring
n=n+1
PRINT n
ENDLOOP


@(do (defun inc-num-str (str-in)
       (let ((len (length str-in))
             (str (copy-str str-in)))
         (for ((i (- len 1)))
              ((>= i 0) `[email protected]`)
              ((dec i))
           (if (<= (inc [str i]) #\9)
             (return str)
             (set [str i] #\0))))))
@(bind a @(inc-num-str "9999"))
@(bind b @(inc-num-str "1234"))


# All variables are strings within the shell
# Although num look like a number, it is in fact a numerical string
num=5
num=`expr $num + 1`    # Increment the number


decl string num
set num "123"
set num (int (+ (int num) 1))


#import nat

instring = ~&h+ %nP+ successor+ %[email protected]      # convert, do the math, convert back


Public Function incr(astring As String) As String
'simple function to increment a number string
   incr = CStr(CLng(astring) + 1)
End Function


    Dim s As String = "123"

    s = CStr(CInt("123") + 1)
    ' or
    s = (CInt("123") + 1).ToString


// Increment a numerical string in V
module main

// V int conversion will give 0 for nonnumeric strings
pub fn main() {
    mut numstr := "-5"
    print("numstr: ${numstr:-5} ")
    numstr = (numstr.int()+1).str()
    println("numstr: $numstr")

    // Run a few tests
    for testrun in ["0", "100", "00110", "abc", "41"] {
        print("numstr: $testrun  ")
        numstr = (testrun.int()+1).str()
        println("numstr: $numstr")
    }
}


var ns = "41"
var n = Num.fromString(ns) + 1
var ns2 = "%(n)"
System.print("%(ns) + 1 = %(ns2)")


(DEFUN INCREMENT-STRING (X)
    (NUMBER->STRING (+ (STRING->NUMBER X) 1)))


string 0;               \use zero-terminated string convention
code Text=12;

func StrLen(A);         \Return number of characters in an ASCIIZ string
char A;
int  I;
for I:= 0 to -1>>1-1 do
        if A(I) = 0 then return I;

proc IncStr(S);         \Increment a numeric string
char S;
int  I;
[for I:= StrLen(S)-1 downto 0 do
        [S(I):= S(I)+1;
        if S(I) > ^9 then S(I):= S(I)-10 else return;
        ];
];

char Str;
[Str:= "0123999999999"; \MSD first (big endian)
IncStr(Str);  IncStr(Str);
Text(0, Str);
]


fcn numStringPlusOne(s){1+s}
numStringPlusOne("123") //-->124


program: increment_a_numerical_string
  case: 1
    input: '1234'
    output: '1235'
  case: 2
    input: '19'
    output: '20'


;main.asm
org $8000
include "foo.txt"
;eof


'file constant include : includeConstantesARM64.inc'
/*******************************************/
/* Constantes                              */
/*******************************************/
.equ STDIN,  0                // Linux input console
.equ STDOUT, 1                // linux output console
.equ OPEN,   56               // call system Linux 64 bits
.equ CLOSE,  57               // call system Linux 64 bits
.equ READ,   63               // call system Linux 64 bits
.equ WRITE,  64               // call system Linux 64 bits
.equ EXIT,   93               // call system Linux 64 bits
.equ HEAPSIZE,   100000
.equ CHARPOS,       '@'       // position character

/*  file */
.equ O_RDONLY, 0
.equ O_WRONLY, 0x0001
.equ O_RDWR,   0x0002          // open for reading and writing

.equ O_CREAT,  0x040           // create if nonexistant
.equ O_TRUNC,  0x0400          // truncate to zero length
.equ O_EXCL,   0x0800          // error if already exists

.equ AT_FDCWD,    -100
'file fonctions include : includeARM64.inc'
/*   File include fonctions   */
.data
ptzZoneHeap:   .quad zZoneHeap
.bss
.align 8
zZoneHeap:              .skip HEAPSIZE
zEndZoneHeap:
.text
/******************************************************************/
/*     String display with  size compute                          */
/******************************************************************/
/* x0 contains string address (string ended with zero binary) */
affichageMess:
    stp x0,x1,[sp,-16]!        // save  registers
    stp x2,x8,[sp,-16]!        // save  registers
    mov x2,0                   // size counter
1:                             // loop start
    ldrb w1,[x0,x2]            // load a byte
    cbz w1,2f                  // if zero -> end string
    add x2,x2,#1               // else increment counter
    b 1b                       // and loop
2:                             // x2 =  string size
    mov x1,x0                  // string address
    mov x0,STDOUT              // output Linux standard
    mov x8,WRITE               // code call system "write"
    svc 0                      // call systeme Linux
    ldp x2,x8,[sp],16          // restaur  2 registres
    ldp x0,x1,[sp],16          // restaur  2 registres
    ret                        // retour adresse lr x30
/******************************************************************/
/*     Decimal conversion unsigned                             */
/******************************************************************/
/* x0 contains the value  */
/* x1 contains the address of receiving area  length >= 21 */
/* the receiving area return a string ascii left aligned */
/* and with final zero */
/* x0 return length string whitout zero final  */
.equ LGZONECONV,   20
conversion10:
    stp x5,lr,[sp,-16]!        // save  registers
    stp x3,x4,[sp,-16]!        // save  registers
    stp x1,x2,[sp,-16]!        // save  registers
    mov x4,#LGZONECONV         // position last digit
    mov x5,#10                 // decimal conversion
1:                             // loop begin
    mov x2,x0                  // copy starting number or successive quotients
    udiv x0,x2,x5              // division by ten
    msub x3,x0,x5,x2           //compute remainder
    add x3,x3,#48              // digit
    sub x4,x4,#1               // previous position
    strb w3,[x1,x4]            // store digit ascii
    cbnz x0,1b                 // end if quotient = zero
    mov x2,LGZONECONV          // compute string length (20 - dernière position)
    sub x0,x2,x4               // no instruction rsb in 64 bits !!!
                               // move result to area begin
    cbz x4,3f                  // full area ?
    mov x2,0                   // start position
2:
    ldrb w3,[x1,x4]            // load digit
    strb w3,[x1,x2]            // store digit
    add x4,x4,#1               // next position origin
    add x2,x2,#1               // and next position destination
    cmp x4,LGZONECONV - 1      // end ?
    ble 2b                     // else loop
3:
    mov w3,0
    strb w3,[x1,x2]             // zero final
100:
    ldp x1,x2,[sp],16          // restaur des  2 registres
    ldp x3,x4,[sp],16          // restaur des  2 registres
    ldp x5,lr,[sp],16          // restaur des  2 registres
    ret                        // retour adresse lr x30
/******************************************************************/
/*     Decimal conversion signed                             */
/******************************************************************/
/* x0 contains the value  */
/* x1 contains the address of receiving area  length >= 21 */
/* the receiving area return a string ascii left aligned */
/* et avec un zero final */
/* x0 return length string whitout zero final  */
.equ LGZONECONVS,   21
conversion10S:
    stp x5,lr,[sp,-16]!        // save  registers
    stp x3,x4,[sp,-16]!        // save  registers
    stp x1,x2,[sp,-16]!        // save  registers
    cmp x0,0                   // is negative ?
    bge 11f                    // no
    mov x3,'-'                 // yes
    neg x0,x0                  // number inversion
    b 12f
11:
    mov x3,'+'                 // positive number
12:
    strb w3,[x1]
    mov x4,#LGZONECONVS         // position last digit
    mov x5,#10                 // decimal conversion
1:                             // loop conversion start
    mov x2,x0                  // copy starting number or successive quotients
    udiv x0,x2,x5              // division by ten
    msub x3,x0,x5,x2           //compute remainder
    add x3,x3,#48              // conversion ascii
    sub x4,x4,#1               // previous position
    strb w3,[x1,x4]            // store digit
    cbnz x0,1b                 // end if quotient = zero

    mov x2,LGZONECONVS          // compute string length (21 - dernière position)
    sub x0,x2,x4               // no instruction rsb in 64 bits !!!
                               // move result to area begin
    cmp x4,1
    beq 3f                     // full area ?
    mov x2,1                   // no -> begin area
2:
    ldrb w3,[x1,x4]            // load a digit
    strb w3,[x1,x2]            // and store at begin area
    add x4,x4,#1               // last position
    add x2,x2,#1               // et begin last postion
    cmp x4,LGZONECONVS - 1      // end ?
    ble 2b                     // no -> loop
3:
    mov w3,0
    strb w3,[x1,x2]            // zero final
    add x0,x0,1                // string length must take into account the sign
100:
    ldp x1,x2,[sp],16          // restaur  2 registers
    ldp x3,x4,[sp],16          // restaur  2 registers
    ldp x5,lr,[sp],16          // restaur  2 registers
    ret                        // return address lr x30
/******************************************************************/
/*     conversion  hexadecimal register                           */
/******************************************************************/
/* x0 contains value and x1 address zone receptrice   */
conversion16:
    stp x0,lr,[sp,-48]!        // save  registres
    stp x1,x2,[sp,32]          // save  registres
    stp x3,x4,[sp,16]          // save  registres
    mov x2,#60                 // start bit position
    mov x4,#0xF000000000000000 // mask
    mov x3,x0                  // save entry value
1:                             // start loop
    and x0,x3,x4               // value register and mask
    lsr x0,x0,x2               // right shift
    cmp x0,#10                 // >= 10 ?
    bge 2f                     // yes
    add x0,x0,#48              // no is digit
    b 3f
2:
    add x0,x0,#55              // else is a letter A-F
3:
    strb w0,[x1],#1            // load result  and + 1 in address
    lsr x4,x4,#4               // shift mask 4 bits left
    subs x2,x2,#4              // decrement counter 4 bits <= zero  ?
    bge 1b                     // no -> loop

100:                           // fin standard de la fonction
    ldp x3,x4,[sp,16]          // restaur des  2 registres
    ldp x1,x2,[sp,32]          // restaur des  2 registres
    ldp x0,lr,[sp],48          // restaur des  2 registres
    ret
/******************************************************************/
/*     conversion ascii string to number                          */
/******************************************************************/
/* x0 contains string address ended by 0x0 or 0xA */
/* x0 return the number  */
conversionAtoD:
    stp x5,lr,[sp,-16]!        // save  registers
    stp x3,x4,[sp,-16]!        // save  registers
    stp x1,x2,[sp,-16]!        // save  registers
    mov x1,#0
    mov x2,#10             // factor ten
    mov x4,x0              // save address in x4
    mov x3,#0              // positive signe by default
    mov x0,#0              // init résult to zéro
    mov x5,#0
1:                         // loop to remove space at begin of string
    ldrb w5,[x4],1         // load in w5 string octet
    cbz w5,100f            // string end -> end routine
    cmp w5,#0x0A           // string end -> end routine
    beq 100f
    cmp w5,#' '            // space ?
    beq 1b                 // yes -> loop
2:
    cmp x5,#'-'            // first character is -
    bne 3f
    mov x3,#1              // negative number
    b 4f                   // previous position
3:                         // begin loop compute digit
    cmp x5,#'0'            // character not a digit
    blt 4f
    cmp x5,#'9'            // character not a digit
    bgt 4f
                           // character is a digit
    sub w5,w5,#48

    mul x0,x2,x0           // multiply last result by factor
    smulh x1,x2,x0         // hight
    cbnz x1,99f            // overflow ?
    add x0,x0,x5           // no -> add to result
4:
    ldrb w5,[x4],1         // load new octet and increment to one
    cbz w5,5f              // string end -> end routine
    cmp w5,#0xA            // string end ?
    bne 3b                 // no -> loop
5:
    cmp x3,#1              // test register x3 for signe
    cneg x0,x0,eq          // if equal egal negate value
    cmn x0,0               // carry to zero no error
    b 100f
99:                        // overflow
    adr x0,szMessErrDep
    bl  affichageMess
    cmp x0,0               // carry to one  error
    mov x0,#0              // if error return zéro
100:
    ldp x1,x2,[sp],16      // restaur  2 registers
    ldp x3,x4,[sp],16      // restaur  2 registers
    ldp x5,lr,[sp],16      // restaur  2 registers
    ret                    // retur address lr x30
szMessErrDep:      .asciz "Number too large: overflow of 64 bits. :\n"
.align 4                   // instruction to realign the following routines
/***************************************************/
/*   reserve heap area                             */
/***************************************************/
// x0 contains size in byte to reserve */
// x0 returne  begin address of area */
reserverPlace:              // INFO: reserverPlace
    stp x1,lr,[sp,-16]!     // save  registers
    stp x2,x3,[sp,-16]!     // save  registers
    mov x1,x0
    tst x1,#0b111           // size multiple of 8 ?
    beq 1f                  // yes
    and x1,x1,0xFFFFFFFFFFFFFFF8 // else align to 8 superior
    add x1,x1,8
1:
    ldr x2,qAdrptzZoneHeap
    ldr x0,[x2]
    add x1,x1,x0            //  size too large ?
    ldr x3,qAdrzEndZoneHeap
    cmp x1,x3
    blt 2f                  // no it is ok
    adr x0,szMessErrTas     // yes -> error
    bl affichageMess
    mov x0,#-1
    b 100f
2:
    str x1,[x2]            // store new pointer
100:                       // fin standard de la fonction
    ldp x2,x3,[sp],16      // restaur  2 registers
    ldp x1,lr,[sp],16      // restaur  2 registers
    ret                    // retur address lr x30
qAdrptzZoneHeap:       .quad ptzZoneHeap
qAdrzEndZoneHeap:      .quad zEndZoneHeap
szMessErrTas:          .asciz "Error : heap not large !!!\n"
.align 4
/***************************************************/
/*   liberer place sur le tas                     */
/***************************************************/
// r0 contains begin address area
libererPlace:               // INFO: libererPlace
    stp x1,lr,[sp,-16]!     // save  registers
    ldr x1,qAdrzZoneHeap
    cmp x0,x1
    blt 99f
    ldr x1,qAdrzEndZoneHeap
    cmp x0,x1
    bge 99f
    ldr x1,qAdrptzZoneHeap
    str x0,[x1]
    b 100f
99:
    adr x0,szMessErrTas1
    bl affichageMess
    mov x0,-1
100:
    ldp x1,lr,[sp],16      // restaur  2 registers
    ret                    // retur address lr x30
qAdrzZoneHeap:    .quad zZoneHeap
szMessErrTas1:    .asciz "Error : address  < or > heap addresses !!!\n"
.align 4

/******************************************************************/
/*   insert string at character insertion  */
/******************************************************************/
/* x0 contains the address of string 1 */
/* x1 contains the address of insertion string   */
/* x0 return the address of new string  on the heap */
/* or -1 if error   */
strInsertAtCharInc:
    stp x2,lr,[sp,-16]!                      // save  registers
    stp x3,x4,[sp,-16]!                      // save  registers
    stp x5,x6,[sp,-16]!                      // save  registers
    stp x7,x8,[sp,-16]!                      // save  registers
    mov x3,#0                                // length counter
1:                                           // compute length of string 1
    ldrb w4,[x0,x3]
    cmp w4,#0
    cinc  x3,x3,ne                           // increment to one if not equal
    bne 1b                                   // loop if not equal
    mov x5,#0                                // length counter insertion string
2:                                           // compute length to insertion string
    ldrb w4,[x1,x5]
    cmp x4,#0
    cinc  x5,x5,ne                           // increment to one if not equal
    bne 2b                                   // and loop
    cmp x5,#0
    beq 99f                                  // string empty -> error
    add x3,x3,x5                             // add 2 length
    add x3,x3,#1                             // +1 for final zero
    mov x6,x0                                // save address string 1
    mov x0,x3
    bl reserverPlace
    cmp x0,#-1                               // allocation error
    beq 99f
    mov x5,x0                                // save address heap for output string
    mov x2,0
    mov x4,0
3:                                           // loop copy string begin
    ldrb w3,[x6,x2]
    cmp w3,0
    beq 99f
    cmp w3,CHARPOS                           // insertion character ?
    beq 5f                                   // yes
    strb w3,[x5,x4]                          // no store character in output string
    add x2,x2,1
    add x4,x4,1
    b 3b                                     // and loop
5:                                           // x4 contains position insertion
    add x8,x4,1                              // init index character output string
                                             // at position insertion + one
    mov x3,#0                                // index load characters insertion string
6:
    ldrb w0,[x1,x3]                          // load characters insertion string
    cmp w0,#0                                // end string ?
    beq 7f                                   // yes
    strb w0,[x5,x4]                          // store in output string
    add x3,x3,#1                             // increment index
    add x4,x4,#1                             // increment output index
    b 6b                                     // and loop
7:                                           // loop copy end string
    ldrb w0,[x6,x8]                          // load other character string 1
    strb w0,[x5,x4]                          // store in output string
    cmp x0,#0                                // end string 1 ?
    beq 8f                                   // yes -> end
    add x4,x4,#1                             // increment output index
    add x8,x8,#1                             // increment index
    b 7b                                     // and loop
8:
    mov x0,x5                                // return output string address
    b 100f
99:                                          // error
    mov x0,#-1
100:
    ldp x7,x8,[sp],16                        // restaur  2 registers
    ldp x5,x6,[sp],16                        // restaur  2 registers
    ldp x3,x4,[sp],16                        // restaur  2 registers
    ldp x2,lr,[sp],16                        // restaur  2 registers
    ret

'Main program '
/* ARM assembly AARCH64 Raspberry PI 3B */
/*  program include.s   */

/*******************************************/
/* Constantes file                             */
/*******************************************/
.include "../includeConstantesARM64.inc"

/*******************************************/
/* Initialized data                        */
/*******************************************/
.data
szMessResult:  .asciz "Number = "
szRetourLigne: .asciz "\n"
/*******************************************/
/* Uninitialized data                       */
/*******************************************/
.bss
sZoneConv:                   .skip 100
.text
.global main
main:

    mov x0,1000                  // number
    ldr x1,qAdrsZoneConv
    bl conversion10S              // result decimal conversion
    ldr x0,qAdrszMessResult
    bl affichageMess              // call function display
    ldr x0,qAdrsZoneConv
    bl affichageMess              // call function display
    ldr x0, qAdrszRetourLigne
    bl affichageMess
    mov x0,0                      // return code OK
100:                              // standard end programm
    mov x8,EXIT                   // request to exit program
    svc 0                         // perform the system call
qAdrszMessResult:            .quad szMessResult
qAdrsZoneConv:               .quad sZoneConv
qAdrszRetourLigne:           .quad szRetourLigne
/********************************************************/
/*        File Include fonctions                        */
/********************************************************/
.include "../includeARM64.inc"


INCLUDE "D2:REAL.ACT" ;from the Action! Tool Kit

PROC Main()
RETURN


with Ada.Text_IO, Another_Package; use Ada.Text_IO;
  -- the with-clause tells the compiler to include the Text_IO package from the Ada standard
  -- and Another_Package. Subprograms from these packages may be called as follows:
  --               Ada.Text_IO.Put_Line("some text");
  --               Another_Package.Do_Something("some text");
  -- The use-clause allows the program author to write a subprogram call shortly as
  --               Put_Line("some text");


 10  REMPROGRAM TWO
 20  DEF  FN A(X) = X * Y
 30  PRINT  FN A(2)

SAVE PROGRAM TWO


'file constantes.inc'
/************************************/
/* Constantes                       */
/************************************/
.equ STDOUT, 1              @ Linux output console
.equ EXIT,   1              @ Linux syscall end program
.equ WRITE,  4              @ Linux syscall write
.equ BRK,    0x2d           @ Linux syscall heap
.equ MKDIR, 0x27            @ Linux Syscal  create directory
.equ CHGDIR, 0xC            @ Linux Syscal  change directory
.equ CREATE, 0x8            @ Linux Syscal  create file
.equ CLOSE,   0x6           @ Linux Syscal  close file

.equ HEAPSIZE,  100000
.equ CHARPOS, '@'           @ character insertion

'file source include '
/* file affichage.inc */
.data
/*************************************************/
szMessErr: .ascii "Error code hexa : "
sHexa:     .space 9,' '
           .ascii "  decimal :  "
sDeci:     .space 15,' '
           .asciz "\n"
ptzZoneHeap:   .int zZoneHeap
/*************************************************/
.bss
.align 4
zZoneHeap:              .skip HEAPSIZE
zEndZoneHeap:
.text
/******************************************************************/
/*     display text with size calculation                         */
/******************************************************************/
/* r0 contains the address of the message */
affichageMess:
    push {r0,r1,r2,r7,lr}                          @ save  registres
    mov r2,#0                                      @ counter length
1:                                                 @ loop length calculation
    ldrb r1,[r0,r2]                                @ read octet start position + index
    cmp r1,#0                                       @ if 0 its over
    addne r2,r2,#1                                 @ else add 1 in the length
    bne 1b                                         @ and loop
                                                    @ so here r2 contains the length of the message
    mov r1,r0                                       @ address message in r1
    mov r0,#STDOUT                                 @ code to write to the standard output Linux
    mov r7, #WRITE                                 @ code call system "write"
    svc #0                                         @ call systeme
    pop {r0,r1,r2,r7,lr}                            @ restaur des  2 registres */
    bx lr                                           @ return
/******************************************************************/
/*     Converting a register to a decimal unsigned                */
/******************************************************************/
/* r0 contains value and r1 address area   */
/* r0 return size of result (no zero final in area) */
/* area size => 11 bytes          */
.equ LGZONECAL,   10
conversion10:
    push {r1-r4,lr}                                 @ save registers
    mov r3,r1
    mov r2,#LGZONECAL
1:                                                  @ start loop
    bl divisionpar10U                               @ unsigned  r0 <- dividende. quotient ->r0 reste -> r1
    add r1,#48                                      @ digit
    strb r1,[r3,r2]                                 @ store digit on area
    cmp r0,#0                                       @ stop if quotient = 0
    subne r2,#1                                     @ else previous position
    bne 1b                                          @ and loop
                                                    @ and move digit from left of area
    mov r4,#0
2:
    ldrb r1,[r3,r2]
    strb r1,[r3,r4]
    add r2,#1
    add r4,#1
    cmp r2,#LGZONECAL
    ble 2b
                                                      @ and move spaces in end on area
    mov r0,r4                                         @ result length
    mov r1,#' '                                       @ space
3:
    strb r1,[r3,r4]                                   @ store space in area
    add r4,#1                                         @ next position
    cmp r4,#LGZONECAL
    ble 3b                                            @ loop if r4 <= area size

100:
    pop {r1-r4,lr}                                    @ restaur registres
    bx lr
/***************************************************/
/*  Converting a register to a signed decimal      */
/***************************************************/
/* r0 contains value and r1 area address    */
conversion10S:
    push {r0-r4,lr}       @ save registers
    mov r2,r1             @ debut zone stockage
    mov r3,#'+'           @ par defaut le signe est +
    cmp r0,#0             @ negative number ?
    movlt r3,#'-'         @ yes
    mvnlt r0,r0           @ number inversion
    addlt r0,#1
    mov r4,#10            @ length area
1:                        @ start loop
    bl divisionpar10U
    add r1,#48            @ digit
    strb r1,[r2,r4]       @ store digit on area
    sub r4,r4,#1          @ previous position
    cmp r0,#0             @ stop if quotient = 0
    bne 1b

    strb r3,[r2,r4]       @ store signe
    subs r4,r4,#1         @ previous position
    blt  100f             @ if r4 < 0 -> end

    mov r1,#' '           @ space
2:
    strb r1,[r2,r4]       @store byte space
    subs r4,r4,#1         @ previous position
    bge 2b                @ loop if r4 > 0
100:
    pop {r0-r4,lr}        @ restaur registers
    bx lr

/***************************************************/
/*   division par 10   unsigned                    */
/***************************************************/
/* r0 dividende   */
/* r0 quotient */
/* r1 remainder  */
divisionpar10U:
    push {r2,r3,r4, lr}
    mov r4,r0                                          @ save value
    //mov r3,#0xCCCD                                   @ r3 <- magic_number lower  raspberry 3
    //movt r3,#0xCCCC                                  @ r3 <- magic_number higter raspberry 3
    ldr r3,iMagicNumber                                @ r3 <- magic_number    raspberry 1 2
    umull r1, r2, r3, r0                               @ r1<- Lower32Bits(r1*r0) r2<- Upper32Bits(r1*r0)
    mov r0, r2, LSR #3                                 @ r2 <- r2 >> shift 3
    add r2,r0,r0, lsl #2                               @ r2 <- r0 * 5
    sub r1,r4,r2, lsl #1                               @ r1 <- r4 - (r2 * 2)  = r4 - (r0 * 10)
    pop {r2,r3,r4,lr}
    bx lr                                              @ leave function
iMagicNumber:  	.int 0xCCCCCCCD
/***************************************************/
/*   display error message                        */
/***************************************************/
/* r0 contains error code  r1 : message address */
displayError:
    push {r0-r2,lr}                         @ save registers
    mov r2,r0                               @ save error code
    mov r0,r1
    bl affichageMess
    mov r0,r2                               @ error code
    ldr r1,iAdrsHexa
    bl conversion16                         @ conversion hexa
    mov r0,r2                               @ error code
    ldr r1,iAdrsDeci                        @ result address
    bl conversion10S                        @ conversion decimale
    ldr r0,iAdrszMessErr                    @ display error message
    bl affichageMess
100:
    pop {r0-r2,lr}                          @ restaur registers
    bx lr                                   @ return
iAdrszMessErr:                 .int szMessErr
iAdrsHexa:                     .int sHexa
iAdrsDeci:                     .int sDeci
/******************************************************************/
/*     Convert a string to a number stored in a registry          */
/******************************************************************/
/* r0 contains the address of the area terminated by 0 or 0A */
/* r0 returns a number                           */
conversionAtoD:
    push {fp,lr}         @ save 2 registers
    push {r1-r7}         @ save others registers
    mov r1,#0
    mov r2,#10           @ factor
    mov r3,#0            @ counter
    mov r4,r0            @ save address string -> r4
    mov r6,#0            @ positive sign by default
    mov r0,#0            @ initialization to 0
1:     /* early space elimination loop */
    ldrb r5,[r4,r3]     @ loading in r5 of the byte located at the beginning + the position
    cmp r5,#0            @ end of string -> end routine
    beq 100f
    cmp r5,#0x0A        @ end of string -> end routine
    beq 100f
    cmp r5,#' '          @ space ?
    addeq r3,r3,#1      @ yes we loop by moving one byte
    beq 1b
    cmp r5,#'-'          @ first character is -
    moveq r6,#1         @  1 -> r6
    beq 3f              @ then move on to the next position
2:   /* beginning of digit processing loop */
    cmp r5,#'0'          @ character is not a number
    blt 3f
    cmp r5,#'9'          @ character is not a number
    bgt 3f
    /* character is a number */
    sub r5,#48
    ldr r1,iMaxi       @ check the overflow of the register
    cmp r0,r1
    bgt 99f            @ overflow error
    mul r0,r2,r0         @ multiply par factor 10
    add r0,r5            @ add to  r0
3:
    add r3,r3,#1         @ advance to the next position
    ldrb r5,[r4,r3]     @ load byte
    cmp r5,#0            @ end of string -> end routine
    beq 4f
    cmp r5,#0x0A            @ end of string -> end routine
    beq 4f
    b 2b                 @ loop
4:
    cmp r6,#1            @ test r6 for sign
    moveq r1,#-1
    muleq r0,r1,r0       @ if negatif, multiply par -1
    b 100f
99:  /* overflow error */
    ldr r0,=szMessErrDep
    bl   affichageMess
    mov r0,#0      @ return  zero  if error
100:
    pop {r1-r7}          @ restaur other registers
    pop {fp,lr}          @ restaur   2 registers
    bx lr                 @return procedure
/* constante program */
iMaxi: .int 1073741824
szMessErrDep:  .asciz  "Too large: overflow 32 bits.\n"
.align 4
/******************************************************************/
/*     Converting a register to hexadecimal                      */
/******************************************************************/
/* r0 contains value and r1 address area   */
conversion16:
    push {r1-r4,lr}                                    @ save registers
    mov r2,#28                                         @ start bit position
    mov r4,#0xF0000000                                 @ mask
    mov r3,r0                                          @ save entry value
1:                                                     @ start loop
    and r0,r3,r4                                       @value register and mask
    lsr r0,r2                                          @ move right
    cmp r0,#10                                         @ compare value
    addlt r0,#48                                       @ <10  ->digit
    addge r0,#55                                       @ >10  ->letter A-F
    strb r0,[r1],#1                                    @ store digit on area and + 1 in area address
    lsr r4,#4                                          @ shift mask 4 positions
    subs r2,#4                                         @  counter bits - 4 <= zero  ?
    bge 1b                                             @  no -> loop

100:
    pop {r1-r4,lr}                                     @ restaur registers
    bx lr                                              @return
/***************************************************/
/* integer division unsigned                       */
/***************************************************/
division:
    /* r0 contains dividend */
    /* r1 contains divisor */
    /* r2 returns quotient */
    /* r3 returns remainder */
    push {r4, lr}
    mov r2, #0                                         @ init quotient
    mov r3, #0                                         @ init remainder
    mov r4, #32                                        @ init counter bits
    b 2f
1:                                                     @ loop
    movs r0, r0, LSL #1                                @ r0 <- r0 << 1 updating cpsr (sets C if 31st bit of r0 was 1)
    adc r3, r3, r3                                     @ r3 <- r3 + r3 + C. This is equivalent to r3 ? (r3 << 1) + C
    cmp r3, r1                                         @ compute r3 - r1 and update cpsr
    subhs r3, r3, r1                                   @ if r3 >= r1 (C=1) then r3 <- r3 - r1
    adc r2, r2, r2                                     @ r2 <- r2 + r2 + C. This is equivalent to r2 <- (r2 << 1) + C
2:
    subs r4, r4, #1                                    @ r4 <- r4 - 1
    bpl 1b                                             @ if r4 >= 0 (N=0) then loop
    pop {r4, lr}
    bx lr
/***************************************************/
/*   reserve heap area                             */
/***************************************************/
// r0 contains size in byte to reserve */
// r0 returne  begin address of area */
reserverPlace:              @ INFO: reserverPlace
    push {r1,r2,r3,lr}      @ save des registres
    mov r1,r0
    tst r1,#0b11            @ size multiple of 4 ?
    beq 1f                  @ yes
    and r1,#0xFFFFFFFC      @ else align to 4 superior
    add r1,#4
1:
    ldr r2,iAdrptzZoneHeap
    ldr r0,[r2]
    add r1,r1,r0            @  size too large ?
    ldr r3,iAdrzEndZoneHeap
    cmp r1,r3
    blt 2f                  @ no it is ok
    adr r0,szMessErrTas     @ yes -> error
    bl affichageMess
    mov r0,#-1
    b 100f
2:
    str r1,[r2]           @ store new pointer
100:                      @ fin standard de la fonction
    pop {r1,r2,r3,lr}     @ restaur des registres
    bx lr                 @ retour de la fonction en utilisant lr
iAdrptzZoneHeap:       .int ptzZoneHeap
iAdrzEndZoneHeap:      .int zEndZoneHeap
szMessErrTas:          .asciz "Error : heap not large !!!\n"
.align 4
/***************************************************/
/*   liberer place sur le tas                     */
/***************************************************/
// r0 contains begin address area
libererPlace:               @ INFO: libererPlace
    push {r1,lr}            @ save des registres
    ldr r1,iAdrzZoneHeap
    cmp r0,r1
    blt 99f
    ldr r1,iAdrzEndZoneHeap
    cmp r0,r1
    bge 99f
    ldr r1,iAdrptzZoneHeap
    str r0,[r1]
    b 100f
99:
    adr r0,szMessErrTas1
    bl affichageMess
    mov r0,#-1
100:
    pop {r1,lr}                          @ restaur registers
    bx lr
iAdrzZoneHeap:    .int zZoneHeap
szMessErrTas1:    .asciz "Error : address  < or > heap addresses !!!\n"
.align 4
/******************************************************************/
/*   insert string at character insertion                         */
/******************************************************************/
/* r0 contains the address of string 1 */
/* r1 contains the address of insertion string   */
/* r0 return the address of new string  on the heap */
/* or -1 if error   */
strInsertAtCharInc:
    push {r1-r7,lr}                         @ save  registres
    mov r3,#0                                // length counter
1:                                           // compute length of string 1
    ldrb r4,[r0,r3]
    cmp r4,#0
    addne r3,r3,#1                           // increment to one if not equal
    bne 1b                                   // loop if not equal
    mov r5,#0                                // length counter insertion string
2:                                           // compute length to insertion string
    ldrb r4,[r1,r5]
    cmp r4,#0
    addne r5,r5,#1                           // increment to one if not equal
    bne 2b                                   // and loop
    cmp r5,#0
    beq 99f                                  // string empty -> error
    add r3,r3,r5                             // add 2 length
    add r3,r3,#1                             // +1 for final zero
    mov r6,r0                                // save address string 1
    mov r0,r3
    bl reserverPlace
    mov r5,r0                                // save address heap for output string
    cmp r0,#-1                               // allocation error
    beq 99f

    mov r2,#0
    mov r4,#0
3:                                           // loop copy string begin
    ldrb r3,[r6,r2]
    cmp r3,#0
    beq 99f
    cmp r3,#CHARPOS                           // insertion character ?
    beq 5f                                   // yes
    strb r3,[r5,r4]                          // no store character in output string
    add r2,r2,#1
    add r4,r4,#1
    b 3b                                     // and loop
5:                                           // r4 contains position insertion
    add r7,r4,#1                              // init index character output string
                                             // at position insertion + one
    mov r3,#0                                // index load characters insertion string
6:
    ldrb r0,[r1,r3]                          // load characters insertion string
    cmp r0,#0                                // end string ?
    beq 7f                                   // yes
    strb r0,[r5,r4]                          // store in output string
    add r3,r3,#1                             // increment index
    add r4,r4,#1                             // increment output index
    b 6b                                     // and loop
7:                                           // loop copy end string
    ldrb r0,[r6,r7]                          // load other character string 1
    strb r0,[r5,r4]                          // store in output string
    cmp r0,#0                                // end string 1 ?
    beq 8f                                   // yes -> end
    add r4,r4,#1                             // increment output index
    add r7,r7,#1                             // increment index
    b 7b                                     // and loop
8:
    mov r0,r5                                // return output string address
    b 100f
99:                                          // error
    mov r0,#-1
100:
    pop {r1-r7,lr}                          @ restaur registers
    bx lr                                   @ return

'File Main program'

/* ARM assembly Raspberry PI  */
/*  program include.s   */

/* Constantes               */
.include "./constantes.inc"
/* Initialized data */
.data
szMessageOK:        .asciz "Hello \n"

/*  code section */
.text
.global main
main:                                   @ entry of program
    push {fp,lr}                        @ saves registers
    ldr r0,iAdrszMessageOK
    bl affichageMess

100:                                    @ standard end of the program
    mov r0, #0                          @ return code
    pop {fp,lr}                         @restaur  registers
    mov r7, #EXIT                       @ request to exit program
    swi 0                               @ perform the system call

iAdrszMessageOK:           .int szMessageOK

/*********************************/
/* include source display        */
/*********************************/
.include "./affichage.inc"


; import a file
do.import {file.art}

; import another file
; from relative folder location
do.import relative "another_file.art"


#Include FileOrDirName
#IncludeAgain FileOrDirName


REM $INCLUDE: 'file.bi'
'$INCLUDE: 'file.bi'


/* Standard and other library header names are enclosed between chevrons */
#include <stdlib.h>

/* User/in-project header names are usually enclosed between double-quotes */
#include "myutil.h"


/* The C# language specification does not give a mechanism for 'including' one source file within another,
 * likely because there is no need - all code compiled within one 'assembly' (individual IDE projects
 * are usually compiled to separate assemblies) can 'see' all other code within that assembly.
 */


# usage: gawk -f Idiomatically_determine_all_the_characters_that_can_be_used_for_symbols.awk

function is_valid_identifier(id,  rc) {
    fn = "is_valid_identifier.awk"
    printf("function unused(%s) { arr[%s] = 1 }\n", id, id, id) >fn
	printf("BEGIN { exit(0) }\n") >>fn
    close(fn)

    rc = system("gawk -f is_valid_identifier.awk 2>errors")
    return rc == 0
}

BEGIN {
    for (i = 0; i <= 255; i++) {
        c = sprintf("%c", i)

        if (is_valid_identifier(c))
            good1 = good1 c;
        else
            bad1 = bad1 c

        if (is_valid_identifier("_" c "_"))
            good2 = good2 c;
        else
            bad2 = bad2 c;
    }

    printf("1st character: %d bad, %d ok: %s\n",
        length(bad1), length(good1), good1)
    printf("2nd..nth char: %d bad, %d ok: %s\n",
        length(bad2), length(good2), good2)
    exit(0)
}


COPY "copy.cpy". *> The full stop is mandatory, wherever the COPY is.
COPY "another-copy.cpy" REPLACING foo BY bar
                                  SPACE BY ZERO
                                  ==text to replace== BY ==replacement text==.


USING: parser see ;
\ scan-word-name see


package main

import (
	"fmt"
	"go/ast"
	"go/parser"
	"strings"
	"unicode"
)

func isValidIdentifier(identifier string) bool {
	node, err := parser.ParseExpr(identifier)
	if err != nil {
		return false
	}
	ident, ok := node.(*ast.Ident)
	return ok && ident.Name == identifier
}

type runeRanges struct {
	ranges   []string
	hasStart bool
	start    rune
	end      rune
}

func (r *runeRanges) add(cp rune) {
	if !r.hasStart {
		r.hasStart = true
		r.start = cp
		r.end = cp
		return
	}

	if cp == r.end+1 {
		r.end = cp
		return
	}

	r.writeTo(&r.ranges)

	r.start = cp
	r.end = cp
}

func (r *runeRanges) writeTo(ranges *[]string) {
	if r.hasStart {
		if r.start == r.end {
			*ranges = append(*ranges, fmt.Sprintf("%U", r.end))
		} else {
			*ranges = append(*ranges, fmt.Sprintf("%U-%U", r.start, r.end))
		}
	}
}

func (r *runeRanges) String() string {
	ranges := r.ranges
	r.writeTo(&ranges)
	return strings.Join(ranges, ", ")
}

func main() {
	var validFirst runeRanges
	var validFollow runeRanges
	var validOnlyFollow runeRanges

	for r := rune(0); r <= unicode.MaxRune; r++ {
		first := isValidIdentifier(string([]rune{r}))
		follow := isValidIdentifier(string([]rune{'_', r}))
		if first {
			validFirst.add(r)
		}
		if follow {
			validFollow.add(r)
		}
		if follow && !first {
			validOnlyFollow.add(r)
		}
	}

	_, _ = fmt.Println("Valid first:", validFirst.String())
	_, _ = fmt.Println("Valid follow:", validFollow.String())
	_, _ = fmt.Println("Only follow:", validOnlyFollow.String())
}


     varid → (small {small | large | digit | ' }) / reservedid
     conid → large {small | large | digit | ' }
reservedid → case | class | data | default | deriving | do | else
           | foreign | if | import | in | infix | infixl
           | infixr | instance | let | module | newtype | of
           | then | type | where | _

     small → ascSmall | uniSmall | _
  ascSmall → a | b | … | z
  uniSmall → any Unicode lowercase letter

     large → ascLarge | uniLarge
  ascLarge → A | B | … | Z
  uniLarge → any uppercase or titlecase Unicode letter

     digit → ascDigit | uniDigit
  ascDigit → 0 | 1 | … | 9
  uniDigit → any Unicode decimal digit


   a.#~1=#@;: ::0:"1 'b',.a.,.'c'
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz


require "socket"   # includes a file from standard library or /lib relative to current directory
require "./myfile" # includes a file relative to current directory


uses SysUtils;    // Lets you use the contents of SysUtils.pas from the current unit

{$Include Common} // Inserts the contents of Common.pas into the current unit
{$I Common}       // Same as the previous line, but in a shorter form


func my(){
  showln "hello"
  //this is program.dgn
}


{$INCLUDE Common}      // Inserts the contents of Common.pas into the current unit
{$I Common}            // Same as the previous line, but in a shorter form
{$INCLUDE_ONCE Common} // Inserts the contents of Common.pas into the current unit only if not included already
{$FILTER Common}       // Inserts the contents of Common.pas into the current unit after filtering
{$F Common}            // Same as the previous line, but in a shorter form


import java.util.function.IntPredicate;
import java.util.stream.IntStream;

public class Test {
    public static void main(String[] args) throws Exception {
        print("Java Identifier start:     ", 0, 0x10FFFF, 72,
                Character::isJavaIdentifierStart, "%c");

        print("Java Identifier part:      ", 0, 0x10FFFF, 25,
                Character::isJavaIdentifierPart, "[%d]");

        print("Identifier ignorable:      ", 0, 0x10FFFF, 25,
                Character::isIdentifierIgnorable, "[%d]");

        print("Unicode Identifier start:  ", 0, 0x10FFFF, 72,
                Character::isUnicodeIdentifierStart, "%c");

        print("Unicode Identifier part :  ", 0, 0x10FFFF, 25,
                Character::isUnicodeIdentifierPart, "[%d]");
    }

    static void print(String msg, int start, int end, int limit,
        IntPredicate p, String fmt) {

        System.out.print(msg);
        IntStream.rangeClosed(start, end)
                .filter(p)
                .limit(limit)
                .forEach(cp -> System.out.printf(fmt, cp));
        System.out.println("...");
    }
}


for i in 1:0x200000 - 1
    Symbol("x" * Char(i))
end


// version 1.1.4-3

typealias CharPredicate = (Char) -> Boolean

fun printChars(msg: String, start: Int, end: Int, limit: Int, p: CharPredicate, asInt: Boolean) {
    print(msg)
    (start until end).map { it.toChar() }
                     .filter { p(it) }
                     .take(limit)
                     .forEach { print(if (asInt) "[${it.toInt()}]" else it) }
    println("...")
}

fun main(args: Array<String>) {
    printChars("Kotlin Identifier start:     ", 0, 0x10FFFF, 72,
                Char::isJavaIdentifierStart, false)

    printChars("Kotlin Identifier part:      ", 0, 0x10FFFF, 25,
                Character::isJavaIdentifierPart, true)

    printChars("Kotlin Identifier ignorable: ", 0, 0x10FFFF, 25,
                Character::isIdentifierIgnorable, true)
}


chars = Characters[FromCharacterCode[Range[0, 1114111]]];
out = Reap[Do[
     If[Quiet[Length[Symbol[c]] == 0],
      Sow[c]
      ]
     ,
     {c, chars}
     ]][[2, 1]];
Print["Possible 1st characters: ", out // Length]
out = Reap[Do[
     If[Quiet[Length[Symbol["a" <> c]] == 0],
      Sow[c]
      ]
     ,
     {c, chars}
     ]][[2, 1]];
Print["Possible 2nd-nth characters: ", out // Length]


#with the module system:
!import!foo

#passing a file name (only works with compiled bytecode files):
!run-file "/path/file.vu"


-include("my_header.hrl"). % Includes the file at my_header.erl


import sequtils, strutils

echo "Allowed starting characters for identifiers:"
echo toSeq(IdentStartChars).join()
echo ""
echo "Allowed characters in identifiers:"
echo toSeq(IdentChars).join()


/*REXX program determines what characters are valid for REXX symbols.*/
/* copied from REXX version 2                                        */
Parse Version v
Say v
symbol_characters=''                   /* start with no chars        */
do j=0 To 255                          /* loop through all the chars.*/
  c=d2c(j)                             /* convert number to character*/
  if datatype(c,'S') then              /* Symbol char                */
    symbol_characters=symbol_characters || c  /* add to list.        */
  end
say 'symbol characters:' symbol_characters /*display all             */


# When not using the use utf8 pragma, any word character in the ASCII range is allowed.
# the loop below returns: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz
for $i (0..0x7f) {
    $c = chr($i);
    print $c if $c =~ /\w/;
}

# When 'use utf8' is in force, the same holds true, but the Unicode-aware version of the 'word-character' test is used.
# not supplying output, too much of it
use utf8;
binmode STDOUT, ":utf8";
for (0..0x1ffff) {
    $c = chr($_);
    print $c if $c =~ /\p{Word}/;
}


without js -- file i/o, system_exec, \t and \r chars
function run(string ident)
    integer fn = open("test.exw","w")
    printf(fn,"object %s",ident)
    close(fn)
    return system_exec("p -batch test.exw")
end function

function check(integer lo, hi)
    string ok1 = "", ok2 = ""
    integer ng1 = 0, ng2 = 0
    for ch=lo to hi do
        printf(1,"%d/%d...\r",{ch,hi})
        if find(ch,"\t\r\n \0\x1A;") then
            ng1 += 1
            ng2 += 1
        else
            string c = sprintf("%c",ch)
            if run(c)==0 then ok1 &= c else ng1 += 1 end if
            if run("_"&c)==0 then ok2 &= c else ng2 += 1 end if
        end if
    end for
    return {{ng1,length(ok1),ok1},
            {ng2,length(ok2),ok2}}
end function

sequence r = check(0,127)
printf(1,"ansi characters:\n===============\n")
printf(1,"1st character: %d bad, %d OK %s\n",r[1])
printf(1,"2nd..nth char: %d bad, %d OK %s\n\n",r[2])
r = check(128,255)
integer ok8 = 0, ng8 = 0
for i=#80 to #10FFFF do
    if i<#D800 or i>#DFFF then
        printf(1,"#%x/#10FFFF...\r",i)
        string utf8 = utf32_to_utf8({i})
        bool ok = true
        if not find(utf8[1],r[1][3]) then
            ok = false
        else
            for j=2 to length(utf8) do
                if not find(utf8[j],r[2][3]) then
                    ok = false
                    exit
                end if
            end for
        end if
        if ok then
            ok8 += 1
        else
            ng8 += 1
        end if
    end if
end for
printf(1,"utf8 characters:   \n===============\n")
printf(1,"bad:%,d, good:%,d\n",{ng8,ok8})


' person.bi file
Type Person
  name As String
  age As UInteger
  Declare Operator Cast() As String
End Type

Operator Person.Cast() As String
  Return "[" + This.name + ", " + Str(This.age) + "]"
End Operator


include resources "SomeImage.png"
include resources "SomeMovie.mpeg"
include resources "SomeSound.aiff"
include resources "SomeIcon.icns"
include resources "Info.plist"   //Custom preference file to replace FB's generic app preferences


Public Sub Form_Open()
Dim sFile As String

sFile = File.Load("FileToLoad")

End


[ $ "0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrS"
  $ QsTtUuVvWwXxYyZz()[]{}<>~=+-*/^\|_.,:;?!'"`%@&#$Q
  join ] constant                                     is tokenchars (   --> $ )

( The first non-whitespace character after the word $
  (pronounced "string") is deemed to be the delimiter
  for the string that follows it. In the first string
  the conventional character " is used, so cannot
  appear as a character in that string. In the second
  string all the reasonable delimiters are used, so Q
  is used as the delimiter.

  As it is not possible to make a string that uses all
  the characters, two strings are concatenated (join)
  to make the string during compilation. (Which is why
  $ "0...S" $ Qs...$Q join is nested (inside [ ... ])
  and followed by the word constant, which causes the
  nest to be evaluated during compilation.)

  Regardless of operating system, Quackery only knows
  the characters in the string tokenchars, plus space
  and carriage return.

  The characters in tokenchars are in QACSFOT order
  (the Quackery Arbitrary Character Sequence For
   Ordered Text) which it uses for string comparison,
   but the valid tokens (which is all of them) will
   be printed by alltokens in the order native to the
   operating system. (In this instance, Unicode.)     )

[ tokenchars find
  tokenchars found ]                                  is validtoken ( c --> b )

[ 256 times
  [ i^ validtoken if [ i^ emit ] ] ]                  is alltokens  (   -->   )

alltokens


#lang racket
;; Symbols that don't need to be specially quoted:
(printf "~s~%" '(a a-z 3rd ...---... .hidden-files-look-like-this))

;; Symbols that do need to be specially quoted:
(define bar-sym-list
  `(|3|
    |i have a space|
    |i've got a quote in me|
    |i'm not a "dot on my own", but my neighbour is!|
    |.|
    ,(string->symbol "\u03bb")
    ,(string->symbol "my characters aren't even mapped in unicode \U10e443")))
(printf "~s~%" bar-sym-list)
(printf "~a~%" bar-sym-list)

(define (main)
  (for
      ((c (sequence-map
           integer->char
           (in-sequences (in-range 0 (add1 55295))
                         (in-range 57344 (add1 1114111)))))
       (i (in-naturals 1)))
    (when (zero? (modulo i 80)) (newline))
    (display (list->string (list c)))))


sub postfix:<𒋦>($n) { say "$n trilobites" }

sub term:<𝍧> { unival('𝍧') }

𝍧𒋦


/*REXX program determines what  characters  are valid for REXX symbols. */
@=                                     /*set   symbol characters "   "  */
   do j=0  for 2**8                    /*traipse through all the chars. */
   _=d2c(j)                            /*convert decimal number to char.*/
   if datatype(_,'S')  then @[email protected] || _   /*Symbol char?  Then add to list.*/
   end   /*j*/                         /* [↑] put some chars into a list*/

say '     symbol characters: '  @      /*display all  symbol characters.*/
                                       /*stick a fork in it, we're done.*/


object IdiomaticallyDetermineSymbols extends App {

  private def print(msg: String, limit: Int, p: Int => Boolean, fmt: String) =
    println(msg + (0 to 0x10FFFF).filter(p).take(limit).map(fmt.format(_)).mkString + "...")

  print("Java Identifier start:    ", 72, cp => Character.isJavaIdentifierStart(cp), "%c")
  print("Java Identifier part:     ", 25, cp => Character.isJavaIdentifierPart(cp), "[%d]")
  print("Identifier ignorable:     ", 25, cp => Character.isIdentifierIgnorable(cp), "[%d]")
  print("Unicode Identifier start: ", 72, cp => Character.isUnicodeIdentifierStart(cp), "%c")
  print("Unicode Identifier part : ", 25, cp => Character.isUnicodeIdentifierPart(cp), "[%d]")

}


for {set c 0;set printed 0;set special {}} {$c <= 0xffff} {incr c} {
    set ch [format "%c" $c]
    set v "_${ch}_"
    #puts "testing variable named $v"
    if {[catch {set $v $c; set $v} msg] || $msg ne $c} {
	puts [format "\\u%04x illegal in names" $c]
	incr printed
    } elseif {[catch {subst $$v} msg] == 0 && $msg eq $c} {
	lappend special $ch
    }
}
if {$printed == 0} {
    puts "All Unicode characters legal in names"
}
puts "Characters legal after \$: $special"


// main.go
package main

import "fmt"

func hello() {
    fmt.Println("Hello from main.go")
}

func main() {
    hello()
    hello2()
}


-- Due to Haskell's module system, textual includes are rarely needed. In
-- general, one will import a module, like so:
import SomeModule
-- For actual textual inclusion, alternate methods are available. The Glasgow
-- Haskell Compiler runs the C preprocessor on source code, so #include may be
-- used:
#include "SomeModule.hs"


<iframe src="foobar.html">
Sorry: Your browser cannot show the included content.</iframe>


for (i in 97..122) System.write(String.fromByte(i))
for (i in 65..90)  System.write(String.fromByte(i))
System.print("_")


char C, C1;
[Text(0, "First character set: ");
for C:= 0 to 255 do
        if C>=^A then if C<=^Z ! C=^_ then
                ChOut(0, C);
CrLf(0);
Text(0, "Next characters set: ");
for C:= 0 to 255 do
        [if C>=^a & C<=^z then C1:= C & $DF     \to uppercase
                          else C1:= C;
        case of
          C1>=^A & C1<=^Z,  C1>=^0 & C1<=^9,  C1=^_ :
                ChOut(0, C)
        other [];
        ];
CrLf(0);
]


[0..255].filter(fcn(n){
   try{ Compiler.Compiler.compileText("var "+n.text) }
   catch{ False }
}).apply("text").concat()


public class Class1 extends Class2
{
	//code here
}


var s = document.createElement('script');
s.type = 'application/javascript';

// path to the desired file
s.src = 'http://code.jquery.com/jquery-1.6.2.js';
document.body.appendChild(s);


-- load Lingo code from file
fp = xtra("fileIO").new()
fp.openFile(_movie.path&"someinclude.ls", 1)
code = fp.readFile()
fp.closeFile()

-- create new script member, assign loaded code
m = new(#script)
m.name = "someinclude"
m.scriptText = code

-- use it instantly in the current script (i.e. the script that contained the above include code)
script("someinclude").foo()


:- object(foo).

    :- include(bar).

:- end_object.


Document A$={
Module Global Beta {
      Print "This is Beta"
      x=10
      Print x
      }
      Print "This is statement to execute"
      Beta  ' this call not happen
}
Save.Doc A$, "TestThis.Gsb"
Module checkit {
      \\ we can delete Global
      \\ usinf New Modules we get latest TestThis, excluding statements calling modules.
      Load New Modules TestThis
      \\ check if Beta exist
      Print Module(Beta)=True
      \\ so now we call Beta
      Beta
      Print Valid(x)=False ' x is local to beta
}
Checkit
\\ now Beta erased (after return form Checkit)
Print Module(Beta)=False


  % add a new directory at the end of the path
  path(path,newdir);
  addpath(newdir,'-end');  % same as before

  % add a new directory at the beginning
  addpath(newdir);
  path(newdir,path);       % same as before


load("c:/.../source.mac")$

/* or if source.mac is in Maxima search path (see ??file_search_maxima), simply */
load(source)$


IMPORT IO, Text AS Str;
FROM Str IMPORT T


;; local file
(load "file.lsp")

;; URLs (both http:// and file:// URLs are supported)
(load "http://www.newlisp.org/code/modules/ftp.lsp")


import someModule
import strutils except parseInt
import strutils as su, sequtils as qu # su.x works
import pure/os, "pure/times" # still strutils.x


//Include and run the file foo.scad
include <foo.scad>;

//Import modules and functions, but do not execute
use <bar.scad>;


#!/usr/bin/perl
do "include.pl";        # Utilize source from another file
sayhello();


#INCLUDE "Win32API.inc"
#INCLUDE ONCE "Win32API.inc"


<#
    A module is a set of related Windows PowerShell functionalities, grouped together as a convenient unit (usually saved in a
    single directory). By defining a set of related script files, assemblies, and related resources as a module, you can
    reference, load, persist, and share your code much easier than you would otherwise.
#>

Import-Module -Name MyModule

<#
    When you dot source a script (or scriptblock), all variables and functions defined in the script (or scriptblock) will
    persist in the shell when the script ends.
#>
. .\MyFunctions.ps1


 MySketch/
   MySketch.pde
   one.pde
   two.pde
   MyClass.java


      // fully qualified syntax:
      /include library/file,member

      // most sensible; file found on *libl:
      /include file,member

      // shortest one, the same library and file:
      /include member

      // and alternative:
      /copy library/file,member

      //... farther like "include"


run SomeProgram.bas",#include         ' this gives it a handle of #include
render #include                       ' render will RUN the program with handle #include


mod test;

fn main() {
    test::some_function();
}


. myfile.sh    # Include the contents of myfile.sh


Include "D:\include\pad.vbs"

Wscript.Echo lpad(12,14,"-")

Sub Include (file)
   dim fso: set fso = CreateObject("Scripting.FileSystemObject")
   if fso.FileExists(file) then ExecuteGlobal fso.OpenTextFile(file).ReadAll
End Sub


/*******************************************************************************
*   /#   @INCLUDE file:"filename.filetype"
*        - file: is just the filename
*        - actual full pathname is VERBEXX_INCLUDE_PATH\filename.filetype
*          where VERBEXX_INCLUDE_PATH is the contents of an environment variable
*
*   /#   @INCLUDE file:"E:\xxx\xxx\xxx\filename.filetype"
*        - file: specifies the complete pathname of file to include
*
*   @INCLUDE verb can appear only in pre-processor code (after /#  /{  etc.)
*******************************************************************************/

/{  //////////////////////////////////////////////// start of pre-processor code

    @IF (@IS_VAR include_counter)
        else:{@VAR include_counter global: = 0};  // global, so all code sees it

    include_counter++;
    @SAY "    In pre-processor -- include counter = " include_counter;

    @IF (include_counter < 3)
        then:{@INCLUDE file:"rosetta\include_a_file.txt"};     // include self

}/  ////////////////////////////////////////////////// end of pre-processor code

@SAY "Not in pre-processor -- include_counter = " include_counter;
/]
Output:      In preprocessor -- include_counter = 1
             In preprocessor -- include_counter = 2
             In preprocessor -- include_counter = 3
         Not in preprocessor -- include_counter = 3
         Not in preprocessor -- include_counter = 3
         Not in preprocessor -- include_counter = 3


import "./fmt" for Fmt   // imports the Fmt module and makes the 'Fmt' class available
import "./math" for Int  // imports the Math module and makes the 'Int' class available

Fmt.print("The maximum safe integer in Wren is $,d.", Int.maxSafe)


include c:\cxpl\stdlib;
DateOut(0, GetDate)


include(vm.h.zkl, compiler.h.zkl, zkl.h.zkl, opcode.h.zkl);


10 GO TO 9950
5000 REM We reserve line numbers 5000 to 8999 for merged code
9000 STOP: REM In case our line numbers are wrong
9950 REM Merge in our module
9955 MERGE "MODULE"
9960 REM Jump to the merged code. Pray it has the right line numbers!
9965 GO TO 5000


INCLUDE "H6:LOADPPM5.ACT"

DEFINE HISTSIZE="256"

PROC PutBigPixel(INT x,y BYTE col)
  IF x>=0 AND x<=79 AND y>=0 AND y<=47 THEN
    y==LSH 2
    col==RSH 4
    IF col<0 THEN col=0
    ELSEIF col>15 THEN col=15 FI
    Color=col
    Plot(x,y)
    DrawTo(x,y+3)
  FI
RETURN

PROC DrawImage(GrayImage POINTER image INT x,y)
  INT i,j
  BYTE c

  FOR j=0 TO image.gh-1
  DO
    FOR i=0 TO image.gw-1
    DO
      c=GetGrayPixel(image,i,j)
      PutBigPixel(x+i,y+j,c)
    OD
  OD
RETURN

INT FUNC Clamp(INT x,min,max)
  IF x<min THEN
    RETURN (min)
  ELSEIF x>max THEN
    RETURN (max)
  FI
RETURN (x)

PROC Convolution3x3(GrayImage POINTER src,dst
  INT ARRAY kernel INT divisor)
  INT x,y,i,j,ii,jj,index,sum
  BYTE c

  FOR j=0 TO src.gh-1
  DO
    FOR i=0 TO src.gw-1
    DO
      sum=0 index=0
      FOR jj=-1 TO 1
      DO
        y=Clamp(j+jj,0,src.gh-1)
        FOR ii=-1 TO 1
        DO
          x=Clamp(i+ii,0,src.gw-1)
          c=GetGrayPixel(src,x,y)
          sum==+c*kernel(index)
          index==+1
        OD
      OD
      c=Clamp(sum/divisor,0,255)
      SetGrayPixel(dst,i,j,c)
    OD
  OD
RETURN

PROC Main()
  BYTE CH=$02FC ;Internal hardware value for last key pressed
  BYTE ARRAY dataIn(900),dataOut(900)
  GrayImage in,out
  INT ARRAY sharpenKernel=[
    65535 65535 65535
    65535     9 65535
    65535 65535 65535]
  INT size=[30],x,y,sharpenDivisor=[1]

  Put(125) PutE() ;clear the screen

  InitGrayImage(in,size,size,dataIn)
  InitGrayImage(out,size,size,dataOut)
  PrintE("Loading source image...")
  LoadPPM5(in,"H6:LENA30G.PPM")
  PrintE("Convolution...")
  Convolution3x3(in,out,sharpenKernel,sharpenDivisor)

  Graphics(9)
  x=(40-size)/2
  y=(48-size)/2
  DrawImage(in,x,y)
  DrawImage(out,x+40,y)

  DO UNTIL CH#$FF OD
  CH=$FF
RETURN


type Float_Luminance is new Float;

type Float_Pixel is record
   R, G, B : Float_Luminance := 0.0;
end record;

function "*" (Left : Float_Pixel; Right : Float_Luminance) return Float_Pixel is
   pragma Inline ("*");
begin
   return (Left.R * Right, Left.G * Right, Left.B * Right);
end "*";

function "+" (Left, Right : Float_Pixel) return Float_Pixel is
   pragma Inline ("+");
begin
   return (Left.R + Right.R, Left.G + Right.G, Left.B + Right.B);
end "+";

function To_Luminance (X : Float_Luminance) return Luminance is
   pragma Inline (To_Luminance);
begin
   if X <= 0.0 then
      return 0;
   elsif X >= 255.0 then
      return 255;
   else
      return Luminance (X);
   end if;
end To_Luminance;

function To_Pixel (X : Float_Pixel) return Pixel is
   pragma Inline (To_Pixel);
begin
   return (To_Luminance (X.R), To_Luminance (X.G), To_Luminance (X.B));
end To_Pixel;


image filter(image img, double *K, int Ks, double, double);


(load "rgb-pixel-buffer")
(load "ppm-file-io")

(defpackage #:convolve
  (:use #:common-lisp #:rgb-pixel-buffer #:ppm-file-io))

(in-package #:convolve)
(defconstant +row-offsets+ '(-1 -1 -1 0 0 0 1 1 1))
(defconstant +col-offsets+ '(-1 0 1 -1 0 1 -1 0 1))
(defstruct cnv-record descr width kernel divisor offset)
(defparameter *cnv-lib* (make-hash-table))
(setf (gethash 'emboss *cnv-lib*)
      (make-cnv-record :descr "emboss-filter" :width 3
                       :kernel '(-2.0 -1.0 0.0 -1.0 1.0 1.0 0.0 1.0 2.0) :divisor 1.0))
(setf (gethash 'sharpen *cnv-lib*)
      (make-cnv-record :descr "sharpen-filter" :width 3
                       :kernel '(-1.0 -1.0 -1.0 -1.0 9.0 -1.0 -1.0 -1.0 -1.0) :divisor 1.0))
(setf (gethash 'sobel-emboss *cnv-lib*)
      (make-cnv-record :descr "sobel-emboss-filter" :width 3
                       :kernel '(-1.0 -2.0 -1.0 0.0 0.0 0.0 1.0 2.0 1.0 :divisor 1.0 :offset 0.5)))
(setf (gethash 'box-blur *cnv-lib*)
      (make-cnv-record :descr "box-blur-filter" :width 3
                       :kernel '(1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0) :divisor 9.0))

(defun convolve (filename params)
  (let* ((buf (read-ppm-file-to-rgb-pixel-buffer filename))
         (width (first (array-dimensions buf)))
         (height (second (array-dimensions buf)))
         (obuf (make-rgb-pixel-buffer width height)))

    ;;; constrain a value to some range
    ;;; (int,int,int)->int
    (defun constrain (val minv maxv)
      (declare (type integer val minv maxv))
      (min maxv (max minv val)))

    ;;; convolve a single channel
    ;;; list ubyte8->ubyte8
    (defun convolve-channel (band)
      (constrain (round (apply #'+ (mapcar #'* band (cnv-record-kernel params)))) 0 255))

    ;;; return the rgb convolution of a list of pixels
    ;;; list uint24->uint24
    (defun convolve-pixels (pixels)
      (let ((reds (list)) (greens (list)) (blues (list)))
        (dolist (pel (reverse pixels))
          (push (rgb-pixel-red pel) reds)
          (push (rgb-pixel-green pel) greens)
          (push (rgb-pixel-blue pel) blues))
        (make-rgb-pixel (convolve-channel reds) (convolve-channel greens) (convolve-channel blues))))

    ;;; return the list of pixels to which the kernel will be applied
    ;;; (int,int)->list uint24
    (defun kernel-pixels (c r)
      (mapcar (lambda (coff roff) (rgb-pixel buf (constrain (+ c coff) 0 (1- width)) (constrain (+ r roff) 0 (1- height))))
              +col-offsets+ +row-offsets+))

    ;;; body of function
    (dotimes (r height)
      (dotimes (c width)
        (setf (rgb-pixel obuf c r) (convolve-pixels (kernel-pixels c r)))))

    (write-rgb-pixel-buffer-to-ppm-file (concatenate 'string (format nil "convolve-~A-" (cnv-record-descr params)) filename) obuf)))

(in-package #:cl-user)
(defun main ()
  (loop for pars being the hash-values of convolve::*cnv-lib*
    do (princ (convolve::convolve "lena_color.ppm" pars)) (terpri)))


import std.string, std.math, std.algorithm, grayscale_image;

struct ConvolutionFilter {
    double[][] kernel;
    double divisor, offset_;
    string name;
}

Image!Color convolve(Color)(in Image!Color im,
                            in ConvolutionFilter filter)
pure nothrow in {
    assert(im !is null);
    assert(!filter.divisor.isNaN && !filter.offset_.isNaN);
    assert(filter.divisor != 0);
    assert(filter.kernel.length > 0 && filter.kernel[0].length > 0);
    foreach (const row; filter.kernel) // Is rectangular.
        assert(row.length == filter.kernel[0].length);
    assert(filter.kernel.length % 2 == 1); // Odd sized kernel.
    assert(filter.kernel[0].length % 2 == 1);
    assert(im.ny >= filter.kernel.length);
    assert(im.nx >= filter.kernel[0].length);
} out(result) {
    assert(result !is null);
    assert(result.nx == im.nx && result.ny == im.ny);
} body {
    immutable knx2 = filter.kernel[0].length / 2;
    immutable kny2 = filter.kernel.length / 2;
    auto io = new Image!Color(im.nx, im.ny);

    static if (is(Color == RGB))
        alias CT = typeof(Color.r); // Component type.
    else static if (is(typeof(Color.c)))
        alias CT = typeof(Color.c);
    else
        alias CT = Color;

    foreach (immutable y; kny2 .. im.ny - kny2) {
        foreach (immutable x; knx2 .. im.nx - knx2) {
            static if (is(Color == RGB))
                double[3] total = 0.0;
            else
                double total = 0.0;

            foreach (immutable sy, const kRow; filter.kernel) {
                foreach (immutable sx, immutable k; kRow) {
                    immutable p = im[x + sx - knx2, y + sy - kny2];
                    static if (is(Color == RGB)) {
                        total[0] += p.r * k;
                        total[1] += p.g * k;
                        total[2] += p.b * k;
                    } else {
                        total += p * k;
                    }
                }
            }

            immutable D = filter.divisor;
            immutable O = filter.offset_ * CT.max;
            static if (is(Color == RGB)) {
                io[x, y] = Color(
                    cast(CT)min(max(total[0]/ D + O, CT.min), CT.max),
                    cast(CT)min(max(total[1]/ D + O, CT.min), CT.max),
                    cast(CT)min(max(total[2]/ D + O, CT.min), CT.max));
            } else static if (is(typeof(Color.c))) {
                io[x, y] = Color(
                    cast(CT)min(max(total / D + O, CT.min), CT.max));
            } else {
                // If Color doesn't have a 'c' field, then Color is
                // assumed to be a built-in type.
                io[x, y] =
                    cast(CT)min(max(total / D + O, CT.min), CT.max);
            }
        }
    }

    return io;
}

void main() {
    immutable ConvolutionFilter[] filters = [
        {[[-2.0, -1.0, 0.0],
          [-1.0,  1.0, 1.0],
          [ 0.0,  1.0, 2.0]], divisor:1.0, offset_:0.0, name:"Emboss"},

        {[[-1.0, -1.0, -1.0],
          [-1.0,  9.0, -1.0],
          [-1.0, -1.0, -1.0]], divisor:1.0, 0.0, "Sharpen"},

        {[[-1.0, -2.0, -1.0],
          [ 0.0,  0.0,  0.0],
          [ 1.0,  2.0,  1.0]], divisor:1.0, 0.5, "Sobel_emboss"},

        {[[1.0, 1.0, 1.0],
          [1.0, 1.0, 1.0],
          [1.0, 1.0, 1.0]], divisor:9.0, 0.0, "Box_blur"},

        {[[1,  4,  7,  4, 1],
          [4, 16, 26, 16, 4],
          [7, 26, 41, 26, 7],
          [4, 16, 26, 16, 4],
          [1,  4,  7,  4, 1]], divisor:273, 0.0, "Gaussian_blur"}];

    Image!RGB im;
    im.loadPPM6("Lenna100.ppm");

    foreach (immutable filter; filters)
        im.convolve(filter)
        .savePPM6(format("lenna_%s.ppm", filter.name));

    const img = im.rgb2grayImage();
    foreach (immutable filter; filters)
        img.convolve(filter)
        .savePGM(format("lenna_gray_%s.ppm", filter.name));
}