Page 1 of 1

Not a function, Array, List, Map Or Macro

Posted: Wed Dec 03, 2025 9:20 pm
by MikeGreen99
Hi.

Yesterday I used the built in FormDesigner to create a simple 2 gadget Form called 'TestForm01.pbf". When I compile/run the program, I get this:
OpenTestForm01() is Not a function, Array, List, Map Or Macro.

Here is the first portion of my program which dies on line 4
#ProgramTitle = "TestForm01.pb"
#ProgramVersion = "v1.00.0 MG"
XIncludeFile "TestForm01.pbf"
OpenTestForm01()


I tried changing line 4 to:
OpenTestForm01.pbf()
and got this error:
Structure not found :pbf
What to do ?

Thanks,
M...

Re: Not a function, Array, List, Map Or Macro

Posted: Wed Dec 03, 2025 9:34 pm
by TI-994A
MikeGreen99 wrote: Wed Dec 03, 2025 9:20 pm...the first portion of my program which dies on line 4

If OpenTestForm01() exists and is a valid window procedure in your form file, and the form file is in the same folder as your executable, this should work:

Code: Select all

#ProgramTitle = "TestForm01.pb"
#ProgramVersion = "v1.00.0    MG"
XIncludeFile "TestForm01.pbf" 
OpenTestForm01()
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
Make sure that the snippet above is saved in the same folder as the form file, and that the form file contains a working procedure named OpenTestForm01().

Re: Not a function, Array, List, Map Or Macro

Posted: Fri Dec 05, 2025 10:15 pm
by MikeGreen99
Hi.

All files are in the same Directory.

If I add:
OpenTestForm01()
to the form "FormTest01.pbf", I will lose this line as the Form Code is continually being regenerated.

Thanks,
M..

Re: Not a function, Array, List, Map Or Macro

Posted: Sat Dec 06, 2025 2:03 am
by mk-soft
Form files are rewritten by the FormDesigner with each change. Therefore, create a Main.pb and include the form files in it.

Create the event loop in the Main.pb.

Code: Select all

;-TOP Main

#ProgramTitle = "TestForm01.pb"
#ProgramVersion = "v1.00.0    MG"

XIncludeFile "TestForm01.pbf" 

OpenTestForm01()

Repeat
  Event = WaitWindowEvent()
  If Not OpenTestForm01_Events(event) ; <- Generated Event Procedure
    Break
  EndIf
ForEver

Re: Not a function, Array, List, Map Or Macro

Posted: Sat Dec 06, 2025 5:01 am
by TI-994A
MikeGreen99 wrote: Fri Dec 05, 2025 10:15 pmIf I add:
OpenTestForm01()
to the form "FormTest01.pbf", I will lose this line as the Form Code is continually being regenerated.


We shouldn't add anything to the form code files. They are automatically-generated files and will continue to regenerate as the form is edited, purging all foreign code in the process. All program logic should be handled in separate code files.

A standard form code file should look something like this:

Code: Select all

;
; This code is automatically generated by the Form Designer.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures need to be put in another source file.
;

Global Window_0

Procedure OpenWindow_0(x = 0, y = 0, width = 600, height = 400)
  Window_0 = OpenWindow(#PB_Any, x, y, width, height, "", #PB_Window_SystemMenu | #PB_Window_SystemMenu)
EndProcedure
To open the window, you should be calling OpenWindow_0().

However, if you had changed the window variable in the form properties, by renaming it from the default Window_0, to say, MyWindow, the procedure name would also change - to OpenMyWindow().

Check the form code file and call the named procedure accordingly. Then, run the following snippet from another code file which has been saved in the same folder as the form file:

Code: Select all

XIncludeFile "TestForm01.pbf"
OpenWindow_0() ; <--- call the correct procedure here
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend

Re: Not a function, Array, List, Map Or Macro

Posted: Sun Dec 07, 2025 8:21 pm
by MikeGreen99
Okay, I sorta got it:
#ProgramTitle = "TestForm01.pb"
#ProgramVersion = "v1.00.0 MG"
; Created: Dec.02.2025
; L.R.D.: Dec.07.2025 14:20 MG

XIncludeFile "TestForm01.pbf"

OpenWindow_0()

While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend

Procedure CustNumProc(x) ;Enter Customer Number


EndProcedure

Procedure CustNameProc(y) ;Enter Customer Name


EndProcedure
Questions:
1. The FormDesigner forced the name of my Form to Window_0. Can I change this ? What if I had multiple .pbf Forms, would they all use Window_0? How would the Main Program distinguish one .pbf Form from another ?

2. And here is a silly one. TestForm01.pb runs just fine in the PureBasic IDE. But How do I execute my PureBasic program outside of the IDE ? I set the properties of the Main Program (TestForm01.pb) and the Form (TestForm01.pbf) to read/write/execute. How to execute TestForm01.pb ?


Thanks,
M....

Re: Not a function, Array, List, Map Or Macro

Posted: Sun Dec 07, 2025 8:49 pm
by TI-994A
MikeGreen99 wrote: Sun Dec 07, 2025 8:21 pmThe FormDesigner forced the name of my Form to Window_0. Can I change this ? What if I had multiple .pbf Forms, would they all use Window_0? How would the Main Program distinguish one .pbf Form from another ?
Simply change the variable name of the window in the properties window of the form. This can also be done for the gadgets.

The FormDesigner wraps its window and event code in procedures, usually named according to the window name. Just call those accordingly.

Re: Not a function, Array, List, Map Or Macro

Posted: Sun Dec 07, 2025 9:53 pm
by MikeGreen99
Easy fix re the Form Variable name - thanks.

Now re executing my test Program:

I've added the ‘pbcompiler’ Path to the ubuntu Paths. Then I tried executing my test Program:
pbcompiler TestForm01.pb

I got this error:
Error: The 'PUREBASIC_HOME' env variable needs to be set to the install directory before using PureBasic.
How do I set the 'PUREBASIC_HOME' env variable ?


Thanks,
M...

Re: Not a function, Array, List, Map Or Macro

Posted: Mon Dec 08, 2025 6:26 am
by TI-994A
MikeGreen99 wrote: Sun Dec 07, 2025 9:53 pmHow do I set the 'PUREBASIC_HOME' env variable ?
It depends on the Linux distro, but you'd usually have to export the variable in the profile or bashrc file. And preferably add PureBasic to the path variable as well.

Re: Not a function, Array, List, Map Or Macro

Posted: Mon Dec 08, 2025 6:50 pm
by MikeGreen99
Hi.

I have added PureBasic to the path variable in .bashrc.

I'm running ubuntu unity 24.04.

.....you'd usually have to export the variable in the profile or bashrc file.

I don't understand this part. What "variable" and what would the format be to add this "variable" to the .bashrc file ?

What is the "PUREBASIC_HOME' env variable" ?


Thanks,
M.....

Re: Not a function, Array, List, Map Or Macro

Posted: Mon Dec 08, 2025 9:31 pm
by MikeGreen99
I've gotten a little farther on not being able to run a PureBasic program outside of the IDE in ubuntu unity 24.04.

PureBasic _Demo3 installation is here:
/media/mg/DProgs/PureBasic_Demo3/purebasic_demo
I added the following to .bashrc:
# Add PureBasic Compiler Path to what is already there:
export PATH="$PATH:/media/mg/DProgs/PureBasic_Demo3/purebasic_demo/compilers"

# Allow PureBasic Programs to run outside of IDE:
export PUREBASIC_HOME=/media/mg/DProgs/PureBasic_Demo3/purebasic_demo
In Konsole I enter this:
pbcompiler TestForm01,pb
I still get this:
PUREBASIC_HOME' env variable needs to be set to the install directory before using PureBasic
So what exactly is the "PUREBASIC_Home env vaiable", and where does it go ?

Should I make this a New Post ?

Thanks,
M....

Re: Not a function, Array, List, Map Or Macro

Posted: Mon Dec 08, 2025 10:05 pm
by MikeGreen99
I got it working :D . After modding .bashrc I forgot to boot.

Sorry. All good and thanks,
M...

Re: Not a function, Array, List, Map Or Macro

Posted: Tue Dec 09, 2025 4:52 am
by TI-994A
MikeGreen99 wrote: Mon Dec 08, 2025 10:05 pm I got it working :D . After modding .bashrc I forgot to boot.
Perfect, then. Linux configurations can prove to be a little slippery, sometimes. :lol:

If you may require any further clarifications, as you come to grasps with the intricacies of PureBasic, we're always here.