Translating Purebasic in Spiderbasic problem

Just starting out? Need help? Post your questions and find answers here.
jphoarau
Posts: 22
Joined: Thu Dec 28, 2023 4:30 am

Translating Purebasic in Spiderbasic problem

Post by jphoarau »

Hello,

I have a small program in Purebasic and I want to translate it into Spiderbasic. I'm asking this question here because it concerns Spiderbasic.

I have the following piece of code:

Code: Select all

Structure MyStruct
  *CLASS
  MyCanvas.l
  x.l
  y.l
EndStructure

Procedure New(MyCanvas,x,y)
  Protected *Rec.MyStruct
  *Rec=AllocateMemory(SizeOf(MyStruct))
  With *Rec
    \MyCanvas=MyCanvas
    \x=x
    \y=y
    \CLASS=?CLASS; I have a syntax error here in SB
  EndWith
  ProcedureReturn *Rec
EndProcedure

DataSection 
  CLASS:
  Data.i @Draw() 
  Data.i @Free() 
EndDataSection

I have a Syntax Error on the line \CLASS=?CLASS.

I understand that the ? places me at the start of the DataSection, but how are the Datas read in PB? Because I would like to find a way to reproduce this mechanism in SB. I tried with Restore, writing: \CLASS=Restore CLASS replacing \CLASS=?CLASS, but it gives me the answer: "With EnableExplicit variables have to be declared". When I remove the EnableExplicit directive, it gives me the error message "A variable can't be named the same as a keyword: Restore".

My question is: How to obtain, in Spiderbasic, the address of the start of one of the data of a DataSection at any label? And is it possible in this language?
User avatar
Paul
Posts: 210
Joined: Wed Feb 26, 2014 6:46 pm
Location: Canada
Contact:

Re: Translating Purebasic in Spiderbasic problem

Post by Paul »

You might want to search the keyword: DataSection

SpiderBasic can't do everything the same as PureBasic
jphoarau
Posts: 22
Joined: Thu Dec 28, 2023 4:30 am

Re: Translating Purebasic in Spiderbasic problem

Post by jphoarau »

Paul wrote: Sat Jan 27, 2024 2:01 pm You might want to search the keyword: DataSection

SpiderBasic can't do everything the same as PureBasic
Thank you. I'm not sure if it is possible. That was my question. But there is no source example with the keyword DataSection nor the Interface one. So I can't figure how to restore labelled datas in a DataSection. There is the keyword Restore but I don't know how to use it.

Thaanks
User avatar
Peter
Posts: 1197
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Translating Purebasic in Spiderbasic problem

Post by Peter »

jphoarau wrote: Sat Jan 27, 2024 3:28 pmThere is the keyword Restore but I don't know how to use it.
place the cursor in the keyword and press <F1>. Help for the corresponding command will then appear

Online-Help for DataSection and Restore: https://www.spiderbasic.com/documentati ... /data.html
User avatar
Paul
Posts: 210
Joined: Wed Feb 26, 2014 6:46 pm
Location: Canada
Contact:

Re: Translating Purebasic in Spiderbasic problem

Post by Paul »

Sorry, I meant search this forum with the keyword: DataSection

But searching the help file as Peter suggests will also show Spider basic has fewer options than PureBasic when using DataSection
jphoarau
Posts: 22
Joined: Thu Dec 28, 2023 4:30 am

Re: Translating Purebasic in Spiderbasic problem

Post by jphoarau »

Peter wrote: Sat Jan 27, 2024 3:49 pm
jphoarau wrote: Sat Jan 27, 2024 3:28 pmThere is the keyword Restore but I don't know how to use it.
place the cursor in the keyword and press <F1>. Help for the corresponding command will then appear

Online-Help for DataSection and Restore: https://www.spiderbasic.com/documentati ... /data.html
Yes, that what I done. But I can't do or adapt the PB code to SB code. It seems that it is impossible. There is nothing I'm looking for in the help nor in the examples. But thank you for your answer.
jphoarau
Posts: 22
Joined: Thu Dec 28, 2023 4:30 am

Re: Translating Purebasic in Spiderbasic problem

Post by jphoarau »

Finally, I think I have found the solution here in this site: viewtopic.php?p=9117&hilit=DataSection#p9117

Thanks
Post Reply