プレイ日記
Trabajon Leyenda_17
Wow, this is embarrasing... So heres my theory on what DATA, READ, and RESTORE works, [especially annoying FOR TO but Ill get to it later] Is this 100% accurate or am I missing something??
0そうだね
プレイ済み
返信[1]
親投稿
Trabajon Leyenda_17
[I should make a children book that teach this. How fun it'll be to learn at young age. XD]
0そうだね
プレイ済み
返信[2]
親投稿
SıмΞоп SimeonW
If you learn assembly, especially MIPS assembly, which is so low level that you can convert it into 1s and 0s by hand, the user of data, read, and restore is very heavily used. The reason it exists in BASIC is because of how easy it is to convert it back into assembly so it can run. DATA is just user defined data, a faster way to fill up an array with manual numbers/strings rather than generated
1そうだね
プレイ済み
返信[3]
親投稿
Trabajon Leyenda_17
Then what did I did wrong? Is there limitations to using READ DATA? I kind of feel iffy on RESTORE because it works on either side as long as they're closest? Or only on top. But on the other one, 12Me23 told me about this but I still see no progress. Does usage of READ ALWAYS need to be in DIM/VAR or DEF? Do I always need WHILE [idk how it work] or FOR TO first 1 line before READ?
0そうだね
プレイ済み
返信[4]
親投稿
Trabajon Leyenda_17
-Do I always need [] for READ usages? [[ ( ) ? ]] If no array, just -1? -Why WHILE 1? If theres no coding other than lever Its 'to turn on the loop'?
0そうだね
プレイ済み
返信[5]
親投稿
SıмΞоп SimeonW
This is probably the simplest example of DATA, READ, RESTORE
0そうだね
プレイ済み
返信[6]
親投稿
Trabajon Leyenda_17
-So READ is semi-equal to DIM/VAR? -READ gets incremented if used more than once?
0そうだね
プレイ済み
返信[7]
親投稿
Trabajon Leyenda_17
Where READ is alt of DIM\DEF? Like this? READ Bob$ RESTORE @WalkieTalkie DEF A$[2] A$[0] = "Hello!" A$[1] = "How are you?" A$[2]= "I'm good! Thanks!" @WalkieTalkie DATA 1 DATA 2 DATA 3
0そうだね
プレイ済み
返信[8]
親投稿
Trabajon Leyenda_17
DEF Bob$ PRINT END I forgot this one.
0そうだね
プレイ済み
返信[9]
親投稿
SıмΞоп SimeonW
Not really RESTORE always always comes before READ, READ simply puts whatever value is next into whatever variable you want. If the variable wasnt created with VAR/DIM, it will create it automatically
1そうだね
プレイ済み
返信[10]
親投稿
SıмΞоп SimeonW
In this example, we put 100 digits of pi into an array Then because its in an array we can easily get any value of it DIGITS[0] is the first number DIGITS[79] is the 80th number DIGITS[99] is the 100th number DIGITS[100] will give you an error because there arent 101 numbers
1そうだね
プレイ済み
返信[11]
親投稿
SıмΞоп SimeonW
^ And actually in that example The FOR loop makes: I=0 I=1 I=2 I=3 ... I=97 I=98 I=99 And for each value of I, it runs whatever is inside the loop, in this case it runs READ DIGITS[0] all the way to READ DIGITS[99]
1そうだね
プレイ済み
返信[12]
親投稿
Trabajon Leyenda_17
Hold on
0そうだね
プレイ済み
返信[13]
親投稿
Trabajon Leyenda_17
So I is just a letter that I can use like BILLY instead of I?
0そうだね
プレイ済み
返信[14]
親投稿
Trabajon Leyenda_17
Heres my first comment
0そうだね
プレイ済み
返信[15]
親投稿
Trabajon Leyenda_17
Heres other
0そうだね
プレイ済み
返信[16]
親投稿
Trabajon Leyenda_17
Hotel Room number [DATA Numberx] with different furniture like chairs and things [Assignment/Abilities.] ?
0そうだね
プレイ済み
返信[17]
親投稿
SıмΞоп SimeonW
X is just a useless variable But inside the FOR loop it is the counter to know when to stop looping X=0, X=1, X=2, X=3, X=4 That NEXT X is the exact same as NEXT. Adding the X just makes it 'easier to read' but I think that's bs You used X as the FOR loop incrementer, but by convention, i is always used first, then j, then k, and so on
0そうだね
プレイ済み
返信[18]
親投稿
SıмΞоп SimeonW
The array R (or hotel room, or whatever) can only store one number each However, if you replaced R with R$ That means it is an array of strings Then in the DATA you could do DATA "Bob's room", "Bill's room", "Harry's room", "empty", "another empty room"
0そうだね
プレイ済み
返信[19]
親投稿
SıмΞоп SimeonW
Then R$[2] would be equal to "Harry's Room" To get the 5th letter of the 3rd item: PRINT R$[2][4] Output: "y"
0そうだね
プレイ済み
返信[20]
親投稿
SıмΞоп SimeonW
Strings are arrays too
0そうだね
プレイ済み
返信[21]
親投稿
Trabajon Leyenda_17
So its replacable I guess. So its "lifehack" on making infinite loop for extra DATA in future. I agree. Convention? Like popularly used?
0そうだね
プレイ済み
返信[22]
親投稿
Trabajon Leyenda_17
Indeed. One person only hotel. One Star. Could I use numbers (Aside words) inside $ DATA? Hmm...
0そうだね
プレイ済み
返信[23]
親投稿
Trabajon Leyenda_17
??? 5th letter
0そうだね
プレイ済み
返信[24]
親投稿
SıмΞоп SimeonW
Yeah because PRINT "Harry's room"[4] Output "y" the 5th letter By popularity, everyone uses i/I for FOR loops, to represent Iterator
1そうだね
プレイ済み
返信[25]
親投稿
Trabajon Leyenda_17
LAG! Oooh on the I part. Is this a new code trick? I dont get it. Heres a struggle on my other code
0そうだね
プレイ済み
返信[26]
親投稿
Stewart segludian1
READ/DATA is used to add data in with your code. If you were using a different language you might just read from file instead. However BASIC was made back in the days of puch cards and tape drives so file access was not always possible. When you first start a program, READ will find the first DATA statement and return the first value it finds then move to the next bit of data.
1そうだね
プレイ済み
返信[27]
親投稿
Stewart segludian1
If you want to control where is reads from you use RESTORE. If you don't pass a parameter it starts from the beginning. You can also pass a label to make it start at a certain spot in the code. You will need to be careful that you pass the correct variable to read, you don't want to try to put a string in a number variable.
1そうだね
プレイ済み
返信[28]
親投稿
Stewart segludian1
VAR I%, J%, FRUIT$, MAXNUM% PRINT "FAVORITE NUMBERS:" RESTORE @FAV_NUMS READ MAXNUM% FOR I% = 0 TO MAXNUM% - 1 READ J% PRINT J% NEXT I% PRINT "FAVORITE FRUITS:" RESTORE @FAV_FRUIT READ MAXNUM% FOR I% = 0 TO MAXNUM% - 1 READ FRUIT$ PRINT FRUIT$ NEXT I%
1そうだね
プレイ済み
返信[29]
親投稿
Stewart segludian1
END @FAV_FRUIT DATA 3 DATA "BANNANA" DATA "APPLE", "ORANGE" @FAV_NUMS DATA 4, 42, 13, 1, 100
1そうだね
プレイ済み
返信[30]
親投稿
Stewart segludian1
See how I used RESTORE to read the favorite numbers before the fruits even though the fruit was first in the code. RESTORE is the only reason we should use line numbers in smile basic. You declare data with the DATA statement after the statement is is just a comma separated list of numbers or strings which you can mix and match. READ just gets the next available data value
1そうだね
プレイ済み
返信[31]
親投稿
Trabajon Leyenda_17
I think I'm starting to understand READ DATA RESTORE code because of the history of BASIC. What is the % usage for?
0そうだね
プレイ済み
返信[32]
親投稿
Trabajon Leyenda_17
[Oh dear, I didnt know that image I uploaded was still copyrighted...]
0そうだね
プレイ済み
返信[33]
親投稿
SıмΞоп SimeonW
SmileBASIC runs faster without a variable after NEXT And % after a variable means that that variable is specifically an array You use it if you want to make a function that takes an array as it's parameter You should try making a game!
1そうだね
プレイ済み
返信[34]
親投稿
Leyenda_17 Leyenda_17
運営者により削除されました。 コメントのID : 3DB-NBL7-EJ9-9E38-C8W-MRV3
返信[35]
親投稿
Trabajon Leyenda_17
...classy background that Petit II people did long time with cute backgrounds, but I been struggling on how to make one text not move but make selected text move. Explain more on %? I feel a little better on DATA and READ atm though.
0そうだね
プレイ済み
返信[36]
親投稿
Trabajon Leyenda_17
???.................... ok thank you for information....
0そうだね
プレイ済み
返信[37]
親投稿
Stewart segludian1
% means an integer variable. That is a whole number like 1, 0, or -1. While # means a floating point number that can have a value after the decimal point like -1.1, 3.14159, or 1.00001. Finally $ is for strings like say "Hello". Integers have a much smaller range, and can't have fractional values but are generally faster which on a low power computer may be useful.
2そうだね
プレイ済み
返信[38]
親投稿
Stewart segludian1
Regardless of a speed boost I like to include it. It documents your intent when using a variable so when you or someone else comes back to it after a break you have a better idea of what to do with it. For loop counters you almost always want %, for SIN and COS you want #. If you don't specify you may end up with a floating point number when you wanted an integer too. It pays to be precise.
2そうだね
プレイ済み