Home
Downloads
Mach3
Plugins
CAM Post Processors
Screensets
Purchase
Support
Forum
Tutorial Videos
Documentation
Yahoo Group
Mach Wiki
Resources
Contact Us
Links
CNCZone
German Forum
Italian Forum
Korean Forum
Portugese (Brazil) Forum
Russian Forum (RSK CNCROUTER)
Thai Forum
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
May 28, 2012, 10:14:46 AM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Select from and to languages
Chinese-simp to English
Chinese-trad to English
English to Chinese-simp
English to Chinese-trad
English to Dutch
English to French
English to German
English to Greek
English to Italian
English to Japanese
English to Korean
English to Portuguese
English to Russian
English to Spanish
Dutch to English
Dutch to French
French to English
French to German
French to Greek
French to Italian
French to Portuguese
French to Dutch
French to Spanish
German to English
German to French
Greek to English
Greek to French
Italian to English
Italian to French
Japanese to English
Korean to English
Portuguese to English
Portuguese to French
Russian to English
Spanish to English
Spanish to French
Machsupport Forum
Mach Discussion
VB and the development of wizards
Multidimensional arrays in Cypress Basic?
Pages:
1
Go Down
« previous
next »
Author
Topic: Multidimensional arrays in Cypress Basic? (Read 446 times)
0 Members and 1 Guest are viewing this topic.
farmertom
Active Member
Offline
Posts: 6
Multidimensional arrays in Cypress Basic?
«
on:
November 12, 2011, 03:00:49 PM »
Hello all,
In reading the Cypress Basic (CB) reference manual I see the CB supports multidimensional arrays. But I can not find the answer to my questions.
1) How do you Dim an empty two dimensional array? Dim myarray ( , ) as integer -does not work.
2) If you get a two dimensional array declared, how do you ReDim it?
Thanks for your time and advice
farmertom
Logged
Sargon
Active Member
Offline
Posts: 99
Re: Multidimensional arrays in Cypress Basic?
«
Reply #1 on:
November 17, 2011, 06:18:59 AM »
AFAIK you cannot initialize an empty multi-dimensional array. and you cannot ReDim it either as ReDim only accepts 1 parameter.
You could use a single array to do the same job though. You just have to manage the array yourself.
e.g.
Sub Main
Dim MultiArray() As Integer
Dim I As Integer, J As Integer
Dim Dim1 As Integer, Dim2 As Integer
Dim1 = 3
Dim2 = 3
Call ReDimArray(MultiArray(), Dim1, Dim2)
For I = 0 To 3
For J = 0 To 3
Call SetArray(MultiArray, I, J, I + J)
Print GetArray(MultiArray, I, J)
Next J
Next I
End Sub
Function ReDimArray(ByRef MultiArray() As Integer, dim1 As Integer, dim2 As Integer)
ReDim MultiArray(dim1 * dim2)
End Function
Function SetArray(ByRef MultiArray() As Integer, dim1 As Integer, dim2 As Integer, value As Integer)
MultiArray(dim1 * dim2) = value
End Function
Function GetArray(ByRef MultiArray() As Integer, dim1 As Integer, dim2 As Integer) As Integer
GetArray = MultiArray(dim1 * dim2)
End Function
Logged
Sargon
Active Member
Offline
Posts: 99
Re: Multidimensional arrays in Cypress Basic?
«
Reply #2 on:
November 17, 2011, 06:34:20 AM »
Correction:
Dim DimSize1 As Integer, DimSize2 As Integer
Sub Main
Dim MultiArray() As Integer
Dim I As Integer, J As Integer
DimSize1 = 3
DimSize2 = 3
Call ReDimArray(MultiArray(), DimSize1, DimSize2)
'insert dummy data
For I = 0 To 8
MultiArray(I) = I
Next I
For I = 0 To 2
For J = 0 To 2
' Call SetArray(MultiArray, I, J, I + J)
Print GetArray(MultiArray, I, J)
Next J
Next I
End Sub
Function ReDimArray(ByRef MultiArray() As Integer, loc1 As Integer, loc2 As Integer)
ReDim MultiArray(loc1 * loc2)
End Function
Function SetArray(ByRef MultiArray() As Integer, loc1 As Integer, loc2 As Integer, value As Integer)
MultiArray(loc1 + loc2 * DimSize1) = value
End Function
Function GetArray(ByRef MultiArray() As Integer, loc1 As Integer, loc2 As Integer) As Integer
GetArray = MultiArray(loc1 + loc2 * DimSize2)
End Function
Logged
farmertom
Active Member
Offline
Posts: 6
Re: Multidimensional arrays in Cypress Basic?
«
Reply #3 on:
November 17, 2011, 08:00:08 AM »
Sargon,
Thanks for the reply. I did eventually go with a one dimensional array, but your idea of indexing the second dimension is a great idea. I will use that in future programing. Too bad CB is so limited. Thanks for the time and effort to reply to my post.
regards
farmertom
Logged
WilliamThomas
Holding
Offline
Posts: 1
Re: Multidimensional arrays in Cypress Basic?
«
Reply #4 on:
December 19, 2011, 07:57:46 AM »
Arrays should be initialized some values, we cannot left blank, whether it is a multidimensional array or one dimensional array.
Logged
software patents
Sargon
Active Member
Offline
Posts: 99
Re: Multidimensional arrays in Cypress Basic?
«
Reply #5 on:
December 19, 2011, 07:10:57 PM »
The question pertained to resizing a multidimensional array. Initializing it wouldn't help accomplish this.
Logged
Pages:
1
Go Up
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Mach Discussion
-----------------------------
=> General Mach Discussion
=> Mach3 under Vista
=> Quantum
=> Mach SDK plugin questions and answers.
===> Finished Plugins for Download
=> VB and the development of wizards
=> Brains Development
=> Video P*r*o*b*i*n*g
=> Mach Screens
===> Screen designer tips and tutorials
===> Works in progress
===> Finished Screens
===> Flash Screens
===> JetCam screen designer
===> Machscreen Screen Designer
===> CVI MachStdMill (MSM)
=> Feature Requests
=> Non English Forums
===> Italian
===> French
===> Spanish
===> Chinese
===> German
===> Russian
===> Romanian
===> Japanese
===> Vietnamese
=> FAQs
-----------------------------
*****VIDEOS*****
-----------------------------
=> *****VIDEOS*****
-----------------------------
General CNC Chat
-----------------------------
=> Share Your GCode
=> Show"N"Tell ( What you have made with your CNC machine.)
=> Building or Buying a Wood routing table.. Beginnners guide..
=> Show"N"Tell ( Your Machines)
-----------------------------
G-Code, CAD, and CAM
-----------------------------
=> G-Code, CAD, and CAM discussions
=> LazyCam (Beta)
-----------------------------
Third party software and hardware support forums.
-----------------------------
=> LazyTurn
=> GearoticMotion Preliminary testing
=> Tempest Trajectory Planner
=> Contec
=> dspMC/IP Motion Controller
=> HiCON Motion Controller
=> Third party software and hardware support forums.
=> Galil
=> Newfangled Solutions Wizards
=> Mach3 and G-Rex
=> Mesa
=> Modbus
=> NC Pod
=> PoKeys
=> SmoothStepper USB
=> Sieg Machines
=> Promote and discuss your product
-----------------------------
Tangent Corner
-----------------------------
=> Tangent Corner
=> Competitions
=> Polls
=> Bargain Basement
-----------------------------
Support
-----------------------------
=> Downloads
===> XML files
===> Post Processors
===> Macros
===> Tutorials
===> Others
===> Beta Brains
===> Screen Sets
===> Documents
===> MACH TOOL BOX
=> One on one phone support.
=> Forum suggestions and report forum problems.
-----------------------------
Mach4
-----------------------------
=> Mach4 pre-Alpha Testing
Loading...