Information Technology - Computer Programming - Source Code - Homebrew - Open Source - Software - Hardware - 8 bit - 16 bit - 32 bit - 64 bit - x86 - x64 - DOS - Windows - Linux - Arduino - Embedded - Development - Retro - Vintage - Math - Science - History - Hobby - Beginners - Professionals - Experiment - Research - Study - Fun - Games

How to print string variable?

Questions relating to Craft Basic go here.
Post Reply
Mussel
Posts: 4
Joined: Mon Mar 06, 2023 3:48 pm

How to print string variable?

Post by Mussel »

I decided to give Craft Basic a try, this is my first app written in Craft Basic, but I don't know how to print string variable:

Code: Select all

input "Please enter you name", s
print "Welcome ", s
print s
It prints "0" instead of the input I typed. EDIT: I removed the "dim" command as it is for array declaration, and since "s" is already predefined.

Also, since there is input box, is there a message box? EDIT: I think I found it, "alert" function.

Thank you for the hard work!
admin
Site Admin
Posts: 103
Joined: Wed Feb 22, 2023 6:51 am

Re: How to print string variable?

Post by admin »

Hello, Mussel. Welcome and thank you for trying Craft Basic.

I have not added support for string variables yet. It's in the to-do list.

Currently, print, alert, title, and run commands may combine their outputs.

For example:

Code: Select all

input "How old are you?", age
alert "Hello", comma, " you are ", age, " years old.", newline, "Have a nice day!"
end
The keywords COMMA and NEWLINE may be used to add commas and newlines to your output.
Currently, there's no way to concatenate to and output a buffer of text.
Input prompts are limited to two lines of text.
Mussel
Posts: 4
Joined: Mon Mar 06, 2023 3:48 pm

Re: How to print string variable?

Post by Mussel »

Oh, I see, once you have implemented the string variable, I guess I want build a program with recursion to print all combination of letters in certain length

For example I mean with 'A,B,C" all the possible combination in 5 characters.

Code: Select all

A,A,A,A,A
A,A,A,A,B
A,A,A,A,C
A,A,A,B,B
A,A,A,B,C
A,A,A,C,C
A,A,B,B,B
A,A,B,B,C
A,A,B,C,C
A,A,C,C,C
A,B,B,B,B
A,B,B,B,C
A,B,B,C,C
A,B,C,C,C
A,C,C,C,C
B,B,B,B,B
B,B,B,B,C
B,B,B,C,C
B,B,C,C,C
B,C,C,C,C
C,C,C,C,C
I suggest you can also make this as your example code if you don't have one.
As for me, its algorithm to generate it is still unknown to me.
admin
Site Admin
Posts: 103
Joined: Wed Feb 22, 2023 6:51 am

Re: How to print string variable?

Post by admin »

Ok, I will note this as a design goal. It seems like a perfect way to test the language.

The only recursion Craft Basic supports is calling a sub from the same sub, creating a loop. Simple stuff. Subs don't accept parameters and all variable data is global.
Post Reply