Basic String type

Hello,

I have two issues :

  1. How can I cast a String into integer in basic like
    index$=“2”
    i%=index$

  2. I want to get the variable name dynamically by iteration
    FOR a% = 1 TO 5
    colN$=(columnName+STR$(a%))!
    OPEN “test.csv” FOR BINARY APPEND AS 1
    PUT 1,colN$ +CHR$(13)+CHR$(10)
    CLOSE 1
    NEXT a%
    PS: the columnName is the adress of an input text(HTML)

Thanks in advance

Hello,

I will look into this issue for you.

Hello,

You can use the FCNV function to convert strings to floats, as explained below

FCNV
Syntax
FCNV S1, EType[, ESize, SFormat]
S1 the string to be converted
EType the parameter determining the type of conversion
ESize the size of the string to convert (can be shorter than the entire S1)
SFormat the format specifier for the conversion
Description
Converts a string to a number (float or integer). The return value can be an IEEE float, an
integer, a CRC16 or a LRC. The type of conversion is determined by the EType parameter.
EType for FCNV command
Etype value Conversion type
1 convert string (MSB first) to float
2 convert string (LSB first) to float
5 compute the CRC16 on string and return an integer
6 compute the LRC on string and return an integer
10 convert string (MSB first) to integer
11 convert string (LSB first) to integer
20 convert string to a float using an SFormat specifier

I would check the get, out, and open functions that allow reading the csv files, but they must have the deliminter “;”

Use the BASIC Programming Guide below:

https://developer.ewon.biz/content/basic-1

Hello,

I use the FCNV with this format :

    index$="1"
    PRINT index$                           // 1
    b% = FCNV index$, 11, 1
    PRINT b%                                // 49 (which is the ASCII code of the number 1)

What I need is the number 1 as integer, I didn’t find what function shall I use ?

Thanks

Try the following from page 36 of the Basic programming manual.
FUNCTION TestString()
index$=“2325”
i% = FCNV index$, 30, 0, “%d”
print i%
ENDFN

1 Like

hello,

thank you @tedsch it works finally

the second issue is how to create a variable name by iteration, is that possible in basic?
example:

FOR a% = 1 TO 4
colN$=(columnName+STR$(a%))!
OPEN “test.csv” FOR BINARY APPEND AS 1
PUT 1,colN$ +CHR$(13)+CHR$(10)
CLOSE 1
NEXT a%

What I need here is to get variable names like columnName1, columnName2, columnName3 and columnName4, and the ColumnName is a HTML input text.

Thanks for help

FUNCTION Test()
FOR $a% = 1 to 4
Print $a%
coIN$=(“columnName” + STR$($a%))
Print coIN$
NEXT $a%
ENDFN

Hello @tedsch

what I need isn’t a string with value “columnName1…columnName4” but a variable with that name, and that variable is the adress of an input text.

colN$=columnName1!
colN$=columnName2!
colN$=columnName3!
colN$=columnName4!

Thanks

I am not sure I completely understand what you are looking for.

Can you show some examples?

Hello,
I need to save the data from the from in the image below which contains a button “add column” to add column 1, column 2,…, column 10 dynamically and each line has four inputs (column Name, Variable, Function, Decimal) with four address that are:

columnName1, variable1, function1, decimal1
columnName2, variable2, function2, decimal2

columnName10, variable10, function10, decimal10

to save the data in the file I use command lines in special forms that unfortunately could support only 255 character and to declare all these input in that command is an impossible mission :),
So I asked if I can create a variable (columnName1!, columnName2!, variable1!, variable2!,…) dynamically in basic by iteration ?! Or what you suggest to do for that issue ?

FOR a% = 1 to 10
coIN$=(columnName+ STR$(a%))!
//…
OPEN “test.csv” FOR BINARY APPEND AS 1
PUT 1, colN$
CLOSE 1
NEXT a%
Capture1

All thoughts will be apreciated

I haven’t seen variables being declared through iteration, and we don’t have any specific examples.

Can you print the new variable name after it’s created? This can assist with verifing that the variable is created.

This is a modified scripting language. It does not have the power as Object Oriented languages ( C++, C#, Java).

Variable name cannot contain a changing portion within the script. I would look in to the M2Wep API, specifically with Java. You may be able to accomplish what you are trying to do externally from the unit.

https://developer.ewon.biz/content/java-0