Jump to content
Sign in to follow this  
maestro

Arrays in files

Recommended Posts

That looks good, and should work, however I'm having trouble understanding:

Dim $points_A = StringSplit("10,20,20,30,40,50,60,70,80", ',', 2)
_ArrayDisplay($points_A, "Array 1") ; Display 1st array
$sFile = @ScriptDir & $FileName & ".path"
_FileWriteFromArray($sFile, $points_A, 1) ; Write array to file starting at element 1.

how exactly does it work?


Hello, World!... LAME lol

Share this post


Link to post
Share on other sites

That looks good, and should work, however I'm having trouble understanding:

Dim $points_A = StringSplit("10,20,20,30,40,50,60,70,80", ',', 2)
_ArrayDisplay($points_A, "Array 1") ; Display 1st array
$sFile = @ScriptDir & $FileName & ".path"
_FileWriteFromArray($sFile, $points_A, 1) ; Write array to file starting at element 1.

how exactly does it work?

Which part or function do you not understand?

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

"Dim $points_A = StringSplit("10,20,20,30,40,50,60,70,80", ',', 2)"

Mainly, how does it allow more then 1 set of data to be saved?

I have a GUI, and every time I click the button I want that data to be added to the file, so I'm not sure if this would work or not. but the read part does.


Hello, World!... LAME lol

Share this post


Link to post
Share on other sites

It is much easier to find the proper solution, when you provide more information.

If you just want to store some information in a file and then read them at a time into an array, then this should be easy.

If every time a user hits the button two values X,Y should be saved in a file, and when read all point should be put into one array, then also no problem.

Please take the time to describe as clearly as possible what you want to do. (No need for functions, just prosa text)

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

I believe I may have solved it with bits of different suggestions people have offered.

$xy= $Px & "," & $Py
FileWrite($FileName & ".path", $xy & @CRLF)

for the write section, and

$sFile = $FileName & ".path"
Dim $av_Array1 ; Declare the array to read to
_FileReadToArray($sFile, $av_Array1) ; Read array from file
$arr = StringSplit($av_Array1[$line], ",", 2)
$posX3 = $arr[0]
$posY3 = $arr[1]
$line += 1

for the read.

Thanks to every one for your help in this matter,

I wouldn't have been able to do it without.


Hello, World!... LAME lol

Share this post


Link to post
Share on other sites

maestro. Are you still having/talking about the same problem as stated in your first message?

$P1 = $arr[0]
$P1 = ^ERROR

Error:Variable used without being declared.

If thats the case it seems to me more of a poor (Global var?) code management problem than a array use problem.

(even if the array creation would fail, it would still set the used variable.)

Unfortunately there seems to be not enough posted code to directly pinpoint your mistake.

(+ the code displayed with the error message is not matching the code showed in the example.(?))

Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...